Choosing random numbers with biased probabilities.

38 Views Asked by At

I had a following sets $A=\{1,\,2,\,3\},\, B=\{4,\,5,\,6\}$ and $C=\{7,\,8,\,9\}$ and I have probabilities of choosing a number from the above sets randomly with probabilities biasing for $A=\frac13,\, B=\frac29$ and $C=\frac19$. How should I achieve that?

1

There are 1 best solutions below

0
On BEST ANSWER

Select a random integer $1$ through $9$ inclusive. Call this number $x$.

If $1 \leq x \leq 3$, select a random element from $A$.

If $4 \leq x \leq 5$, select a random element from $B$.

If $x=6$, select a random element from $C$.

How this works: a probability of $\frac n9$ means that you have $n$ opportunities for success out of $9$ total.

So for $p(A) = \frac 39$, $3$ of the $9$ numbers will cause an $A$-element to be chosen. Likewise, since $p(B) = \frac 29$, $2$ of the $9$ numbers will cause an $B$-element to be chosen. Lastly, $p(C) = \frac 19$, so only $1$ of the $9$ numbers will cause an $C$-element to be chosen.