# Expected number of picked balls

Suppose I have a bag of 4 balls, labeled A, B, C and D. I pick a ball randomly from the bag. If it’s A, B or C, I’ll stop. Otherwise I put the D ball back and pick again. What is the expected number of balls I’ll pick?

Somehow I know the answer is 4/3, but I can’t get to the answer.

I also know it’s the sum $$1\times\frac{3}{4}+2\times\frac{1}{4}\times\frac{3}{4}+3\times\left(\frac{1}{4}\right)^2\times\frac{3}{4}+4\times\left(\frac{1}{4}\right)^3\times\frac{3}{4}+\cdots.$$ But I can’t evaluate it.

• en.wikipedia.org/wiki/Arithmetico%E2%80%93geometric_sequence Aug 22, 2022 at 6:33
• I'm not aware if you know about geometric random variables, but if you can recognize it : the number of balls you pick is $1+X$ where $X$ is a geometric random variable of success probability $\frac 34$. Aug 22, 2022 at 6:33
• If a random variable $X$ takes values in natural numbers then $E[X]=\sum_{k\geq 1} P[X\geq k]$. Aug 22, 2022 at 6:39
• @SarveshRavichandranIyer Thanks for the hint that it’s a geometric distribution. I searched the web for its expectation and saw an answer that I’ll post as an answer. Aug 22, 2022 at 10:46
• @ZiruiWang Great to know I could be of service. Aug 22, 2022 at 10:50

You could use a recursive equation: $$E[X] = \frac{3}{4}(1) + \frac{1}{4}(1 + E[X])$$.

The left-hand side is obviously just the expected # of balls picked; the right-hand side however represents the same quantity, as the first term contains the expected value given that the first ball is A, B, or C and the second term contains the expected value given that the first ball is D, each multiplied by its respective probability.

Simplify & solve and you get $$E[X] = \frac{4}{3}$$.

You can observe the parallels between such a solution and solving the geometric series: both rely on the memorylessness of the process.

• My favourite. By calculation of expectation try to avoid distribution AMAP. Aug 22, 2022 at 9:14

I read this answer from this website. The expectation is $$E(X)=\frac34\sum_{k>0}k\left(\frac14\right)^{k-1}.$$ The sum on the right hand side is of the form: $$\sum_{k>0}k(1-x)^{k-1},\tag{1}$$ where $$x=3/4$$. Integrating the expression, we get $$C-\sum_{k>0}(1-x)^k,$$ of which the sum is a geometric series. So the value of the expression is $$C-\frac{1-x}{1-(1-x)}=C+\frac{x-1}{x}=C+1-\frac1x.$$ Differentiate this back and get $$1/x^2=16/9$$ as the value of the original sum (1). Substitute it back and obtain the expectation as $$E(X)=\frac34\cdot\frac{16}9=\frac43.$$

Here's an easier way to do it.

If we let $$X$$ be a variable representing the number of balls that were picked, then it is clear that $$X$$ is a geometric random variable with a $$3/4$$ probability of "success". In this case, success indicates picking one of the three balls: A, B, or C. One property of geometric distributions is that the expected value for the number of trials needed to obtain the first success, which is denoted as $$E(X)$$, is $$1/p$$, where $$p$$ is the probability of success. In this case, $$p=3/4$$, so $$E(X)=1/(3/4)=4/3$$.