# How many flips to get at least one heads and at least one tails?

A coin having probability $p$ of coming up heads is continually flipped until both heads and tails have appeared. Find the expected number of flips.

Here's my guess: $$E[\text{at least one head and at least one tails]}=E[\text{number of flips until first heads, given the first flip is a tails}]*P(\text{first flip is tails})+E[\text{number of flips until first tails, given the first flip is a heads}]*P(\text{first flip is heads})=\left({1+\frac{1}{p}}\right)(1-p)+\left({1+\frac{1}{1-p}}\right)p$$

Does this look right? If so, can you help me understand why it's right? I mainly came up with this on intuition. If it's wrong, where did I go wrong?

Thanks

• You may be uncertain about arguing that if the probability of success is $a\ne 0$, then the expected number of trials until the first success is $\frac{1}{a}$. This is a standard result about the geometric distribution, with a relatively easy proof, that does not involve any guessing. The rest of your argument is a conditional expectation argument, perfectly correct. – André Nicolas Dec 5 '13 at 23:58

## 1 Answer

Your logic is correct and I think well explained. I don't know why you don't like it.