# Generalizing the Probability Function of a coin-toss and ball-draw experiment

In this exact problem: Probability of choose the same marble again

Initial Conditions
Box I: 4 red and 8 blue balls.
Box II: 5 red and 3 blue balls.

Unfair Coin: 40% Heads (Choose Box I), 60% Tails (Choose Box II).

Experiment
1. Coin-flip outcome decides which box.
2. Ball is drawn without replacement.
3. Repeat.

The answer in the linked question calculated all probabilities for a simple case of 2 experiment iterations (the event was "ball 2 is the same color as ball 1").
I am wondering if there is a way to generalize this for any number of iterations by using known distributions.

It is clear that the coin (i.e. box choice) is modeled by a binomial distribution $$B(n=20, p=0.4)$$, and the ball selection in each box is modeled by two distinct hypergeometric distributions $$H_\mathrm{I}(N=12, K=4,k=1)$$ and $$H_\mathrm{II}(N=8, K=5,k=1)$$.

Note: $$n=20$$ for the binomial distribution, since there are 20 balls to draw at most, and thus 20 experiment iterations.

It seems like a non-trivial task to generalize, as I am not sure how to put these pieces together. My question may be ill-defined even, I am unsure.

Insight and help are appreciated.

• With the edit, I'm not sure of the procedure: (a) Does '3.Repeat' mean to repeat 2 or to put the ball back and repeat 1 & 2? (b) If the latter, do you mean to get exactly the same ball or a ball of the same color?// My Answer is for one coin toss followed by two balls drawn from the same box without replacement, looking for same color. Commented Sep 22, 2019 at 5:20

I think you have the wrong model for the coin toss because it is tossed only once. Otherwise, this seems started on the right track.

For Box I, the number $$R$$ of red balls drawn, when two are drawn at random without replacement, is hypergeometric as you say.

$$P(R = k) = \frac{{4 \choose k}{8 \choose 2-k}}{12 \choose 2},$$ for $$k = 0, 1, 2.$$

In R statistical software, these three probabilities can be found, using a hypergeometric PDF dhyper, as follows:

dhyper(0:2, 4, 8, 2)
[1] 0.42424242 0.48484848 0.09090909


Without software, you could compute $$[1-(4/12)(8/11)].$$

The two balls cannot be of the same color if $$R = 1$$ Thus $$P(\text{Same}) = 0.5151515 = 17/33.$$ Without software, you could compute $$[1-2(4/12)(8/11)]$$ or $$(4/12)(3/11)+(8/12)(7/11)$$

Similarly, the probability of getting two balls of the same color from Box II is $$1 - 15/28 = 13/28 = 0.4642857.$$

dhyper(0:2, 5, 3, 2)
[1] 0.1071429 0.5357143 0.3571429


Then the probability of getting two balls of the same color after the coin toss is.

$$P(\text{Same}) = P(I)P(\text{Same}|I) + P(II)P(\text{Same}|II)\\ = (.4)(17/33) + (.6)(13/28) = 0.484632.$$

I hope the general idea of combining the two hypergeometric probabilities is clear, but I'm not sure just what else you want to generalize. You would still need to specifiy in detail how many balls of each color are in each urn.

• Fixed a couple of typos. But did not change answer to match slightly changed problem. Commented Sep 22, 2019 at 5:09
• Thank you so much for your help. I apologize for causing confusion. I was confused myself at the problem. The coin is being tossed at every step to determine what box to choose. Your answer gave me an idea on how to solve it. Commented Sep 22, 2019 at 6:04
• The idea is using a Binomial distribution in selecting Box I $k$ times, and thus Box II $n-k$ times. Since I have $k$ choices of Box I, then I am drawing $k$ balls from it which is its Hypergeometric distribution. The same happens for Box II but with $n-k$ balls. Commented Sep 22, 2019 at 6:07
• If I do the above process for Red balls alone, and then Blue balls alone, and then I sum them, then I can obtain for a preset $k$, the probability of getting the same color at each step. Commented Sep 22, 2019 at 6:09
• Mathematically, I think this can be written as: $\mathbb{P}(R) = \sum^n_k H_\mathrm{I} (N_\mathrm{I}, K_\mathrm{I}, k, k) H_\mathrm{II} (N_\mathrm{II}, K_\mathrm{II}, n-k, n-k) B(k,p)$ Commented Sep 22, 2019 at 6:12