# Expected value of ejecting balls from a jar

in a jar there are $n_1$ black balls,$n_2$ white balls and $n_3$ red. ($n_1,n_2,n_3\ge2$). The balls are ejected one by another and after they are returned to the jar. What is the expected value of drawing a ball until it's in the same color of the first?

I defined X=number of balls after the first until I got ball in the same color. Then I wangt to find $P(X=n)$, where n is the number of times until I got the desired ball. Without the loss of generality we can find the expected value for black balls (after we can just add the results to get the general expected value of all jar).We muliply the probability for getting black twice (first and last ball in the sequence) by n-1 attempts that failed ($\frac{1}{n_{1}^2}\cdot(\frac{n_2+n_3}{n_1+n_2+n_3})^{n-1}$). Is it correct? If it's correct: Why the probability for getting a black is $\frac{1}{n_1}$ and not $\frac{{n_1+n_2+n_3}\choose{n_1}}?{n_1}$

• When a ball is drawn, is it immediately returned to the jar? (So are we sampling with replacement?) Aug 3, 2013 at 6:53
• If I understood correct, that's exactly what happens.
– user65985
Aug 3, 2013 at 7:40
• I don't see why $1/n_1$ is the probability for getting black. It is rather the probability to pick a particular black ball out of all black balls. Since you return the balls to the jar, the probabilities (getting black, not getting black) remain the same and the experiment is an ongoing Bernoulli experiment with the prob. of getting black $p=\frac{n_1}{n_1+n_2+n_3}$ (probability of success in the Bernoulli terminology). Yet this is not the approach to answer your question, since you don't want to calculate the probability of the event "Black + n-times no black + black again". Aug 3, 2013 at 8:35
• but if i unite the events of "color_i+n times no color_i+color_i again" won't it give me the correct result?
– user65985
Aug 3, 2013 at 8:50
• the correct result to what problem exactly? Aug 3, 2013 at 9:58

If I understand your question correctly, you are asking for $E[X]$ where $X$ is the number of balls drawn until you get a ball the same color as the first ball you drew. The answer is $E[X] = 3$.

Here is the reasoning. Like you said, suppose that the first ball is black. Let $N = n_1 + n_2 + n_3$. Since you are drawing with replacement, the number of trials until you get another black ball is a geometric random variable with success probability $p = n_1/N$. The expected value of this is $1/p = N/n_1$. Similarly, if the first ball is red then the expected number of trials until you get another red ball is $N/n_3$ and similarly for white. All together, splitting it up into three cases by conditioning on the color of the first ball, you get $$E[X] = P(\text{first ball black})\frac{N}{n_1} + P(\text{first ball white})\frac{N}{n_2}+ P(\text{first ball red})\frac{N}{n_3}$$ and so, since $P(\text{first ball black}) = n_1/N$ ($n_1$ equally likely possibilities out of $N$ balls) and similiarly for the other colors, you get $$E[X] = \frac{n_1}{N} \frac{N}{n_1} + \frac{n_2}{N} \frac{N}{n_2}+ \frac{n_3}{N} \frac{N}{n_3} = 3.$$

There might exist a more elegant solution, but I've come up with the following.

Let $p_1,p_2,p_3$ be probabilities to draw black, white or red resp. Define the process $(X_i : i\geq 0$ which takes values in $\{1,2,3\}$ designating the color of the i-th ball you have drawn. Define $Y_1,Y_2,Y_3$ to be random variables designating the number of draws one needs to get the resp. color $1,2$ or $3$.

Note that $$P(Y_j=n) = \prod_{k=1}^{n}P(X_k \neq j) P(X_{n+1}=j) = p_j(1-p_j)^n.$$

Let $E$ be the expected value you are looking for, then we have $$E = \sum_{j=1,2,3} P(X_0=j) \sum_{n=0}^\infty n P(Y_j=n) = \sum_{j=1,2,3}p_j^2\sum_{n=0}^\infty (1-p_j)^n n\\ = \sum_{j=1,2,3}p_j^2\frac{1-p_j}{p_j^2} = 2.$$

Pay attention to how I have defined the "number until you get there again".

Edit: fixed a mistake