Finding the expected number of flips needed for a coin having probability $p$ of landing on heads

2.2k Views Asked by At

A coin, having probability $p$ of landing on heads and probability of $q=1-p$ of landing on tails. It is continuously flipped until at least one head and one tail have been flipped.
a) Find the expected number of flips needed.

This is not part of a homework assignment. I am studying for a final and don't understand the professors solutions. Since this is clearly geometric, I would think the solution would be: $$E(N)=\sum_{i=0}^{\infty}ip^{n-1}q+\sum_{i=0}^{\infty}iq^{n-1}p=\frac{1}{q}+\frac{1}{p}.$$ However, I am completely wrong. The answer is $$E(N)=p\left(1+\frac{1}{q}\right)+q\left(1+\frac{1}{p}\right).$$ For example, consider we flip for heads first. Then we have $$E(N\mid H)=p+p\sum_{i=0}^{\infty}np^{n-1}q.$$ I am not sure why this makes sense. I am not entirely sure why we have an added $1$ and a factored $p$, $q$. Could someone carefully explain why it makes sense that this is the right answer?

2

There are 2 best solutions below

0
On

If you get a head with probability $p$ then the expected number of throws is $1+E(X)$ where $X$ is a geometric distribution requiring a tail to be thrown with probability $q$ so $1+E(X)=1+\frac1q$. Similarly if you throw a tail with probability $q$ then the expected number of throws is $1+E(Y)$ where $Y$ is a geometric distribution requiring a head to be thrown with probability $p$ so $1+E(Y)=1+\frac1p$. This means that the overall expected number of throws is $$p\left(1+\frac1q\right)+q\left(1+\frac1p\right)$$ because there is a probability $p$ that the expected number of throws is given by $1+E(X)$ and probability $q$ that it is given by $1+E(Y)$.

0
On

Let $X$ be the time of the first head, and $Y$ the time of the first tail, and $W$ the first time when a head and a tail has been flipped.

You are right in assuming that $E[X]=\frac{1}{p}$ and $E[Y]=\frac{1}{q}$, But you are wrong in assuming that $W=X+Y$, that's simply not true, actually $W=\max(X,Y)$.

A possible approach. Let $A$ be the indicator variable of the event: "first coin was a head" (hence $X=1$).

Then use $$E[W]=E[E[W | A ]] = P(A=1) E[W|A=1]+P(A=0) E[W|A=0]=\\=p(E[Y]+1)+q(E[X]+1)$$