Four balls with different colors in a box, how many times do I need to pick to see all four colors?

This is known as the coupon collector's problem.

The average number of tries needed to see each of 4 colors is $$ \frac44+\frac43+\frac42+\frac41 = 8\frac{1}{3} $$

The terms are $4/4$ for the time to take one ball; then $4/3$ for the average time it takes after the first ball until you see another code; $4/2$ for the average time it takes after the first time you see the second color until you see a third, and finally $4/1$ for the time you then have to wait until you see the last color. (These can just be added due to the additivity of expectations).


Denote by $E(n)$ the expected number of additional draws when $n$ of the four balls have not been drawn so far. Then $E(0)=0$, and $$E(n)=1+{n\over4} E(n-1)+{4-n\over 4}E(n)\qquad(n\geq1)\ .$$ This immediately implies $$E(n)=E(n-1)+{4\over n}\qquad(n\geq1)\ ,$$ from which we get $E(4)={25\over3}$ by going through the motions.