# Implementing a sampling scheme that satisfies certain probabilities

Suppose we have two boxes of balls. Balls can be blu or red.

In the first box:

• the probability of drawing (at random with replacement - this is assumed everywhere) a red ball is $$p^1_R=0.4$$

• the probability of drawing a blue ball is $$p^1_B=0.6$$

In the second box:

• the probability of drawing a red ball is $$p^2_R=0.3$$

• the probability of drawing a blue ball is $$p^2_B=0.7$$

Now, I want to implement a drawing scheme such that:

• the probability of drawing a red ball from the first box AND a red ball from the second box is $$p_{RR}=0.1$$

• the probability of drawing a red ball from the first box AND a blue ball from the second box is $$p_{RB}=0.3$$

• the probability of drawing a blue ball from the first box AND a red ball from the second box is $$p_{BR}=0.2$$

• the probability of drawing a blue ball from the first box AND a blue ball from the second box is $$p_{BB}=0.4$$

Note that a drawing scheme featuring the above probabilities is feasible because $$p_{RR}+p_{RB}=p^1_R \hspace{1cm} (0.1+0.3=0.4)\\ p_{BR}+p_{BB}=p^1_B\hspace{1cm} (0.2+0.4=0.6)\\ p_{RR}+p_{BR}=p^2_R\hspace{1cm} (0.1+0.2=0.3)\\ p_{RB}+p_{BB}=p^2_B\hspace{1cm} (0.3+0.4=0.7)$$ How can I do that?

A) A book I'm reading suggest to: form red-red matches by 1) drawing a ball at random from the subpopulation of red balls in the first box and 2) assigning this ball to a ball drawn at random from the subpopulation of red balls in the second box. Proceed similarly for other colour matches.

How can this work? I don't understand where it uses the desired $$p_{RR}, p_{RB}, p_{BR}, p_{BB}$$.

B) Some answers to the questions below

• Would we be allowed to draw more times from one box than another, or is it required that we always draw independently from both boxes each time? I would prefer that we always draw independently from both boxes each time. I don't know if that is possible, though.

• Do we need to actually observe these balls or is it enough to use these boxes to create a distribution with the four given probabilities and associate the four outcomes of that distribution with the ball pairs you describe? We need to actually observe the balls.

• stats.stackexchange.com/questions/354678 is closely related. But could you clarify the constraints? For instance, in order to achieve this result would we be allowed to draw more times from one box than another, or is it required that we always draw independently from both boxes each time? Do we need to actually observe these balls or is it enough to use these boxes to create a distribution with the four given probabilities and associate the four outcomes of that distribution with the ball pairs you describe?
– whuber
Sep 29, 2020 at 14:53
• Thanks. I have tried to give some answers to your questions.
– TEX
Sep 29, 2020 at 15:00
• Thank you, but I think we're not communicating about the second issue. Clearly you want to use draws from the boxes as your randomization mechanism. My question is, in order to state, e.g., "The outcome is two red balls," whether you must have seen two red balls. There are solutions that create the probability distribution you desire but without requiring the red balls be actually observed. As an example of what I mean, suppose you wanted to use the first box to generate a distribution where the chance of red is 0.6 and of blue is 0.4. Draw one ball and announce the opposite color!
– whuber
Sep 29, 2020 at 15:29
• Thanks, I see. We must observe the two red balls.
– TEX
Sep 29, 2020 at 15:37

Sample a 4-way categorical random variable $$K$$ with probabilities $$(0.1, 0.3, 0.2, 0.4)$$ and then do the following:

• if $$K = 1$$, then announce both balls are red;
• if $$K = 2$$, then announce the first ball is red, the second one is blue;
• if $$K = 3$$, then announce the first ball is blue, the second one is red;
• if $$K = 4$$, then announce both balls are blue.

Note that we did not use original bins, rather we sorta designed a "joint" bin from scratch given desired probabilities. I don't think it's possible to take the two original independent bins as "black boxes" and entangle them somehow.

UPD: @whuber has suggested Rejection Sampling as a way to solve the "black box" formulation, which I believe should work.

• I think your belief about impossibility is not correct: consider rejection sampling. The spirit of this question is that you must use the processes of drawing from these boxes as your randomization method; you cannot invoke some kind of alternative random process as a deus ex machina to avoid the problem. One can go deeper into this: because the difference in entropies between independent draws of the two original boxes (on the one hand) and the new box (on the other hand) is less than 0.006 bits, there must exist an efficient method involving a very low rejection rate.
– whuber
Sep 29, 2020 at 14:47
• @whuber, indeed, the rejection sampling looks like a viable approach in this case. Sep 29, 2020 at 14:49
• Thanks. I understand that the sampling you proposed works, but I would like some mechanism such that I draw from the original two boxes.
– TEX
Sep 29, 2020 at 14:51