Expected number of tosses until showing differently from first result

What is the expected number of coin tosses (heads comes with probability 0.5) until we get a result which is different from the first toss?

My first intuition is 3: we need to toss once, and then we have a geometric distribution with expectation of 2.

But, there are 2 possible scenarios: one scenario is when the first toss is heads and the other scenario is when the first toss is tails. So, this might suggest that the expectation is less than 3.... A bit confusing...

PMF I got: enter image description here

enter image description here


Solution 1:

Your intuition is right.

This because your pmf is

$$P(Y=y)=\left(\frac{1}{2} \right)^{y-1}$$

Where $y=2,3,4\dots$

This rv is $Y=X+1$ where $X$ is a geometric rv counting the trials before the first success.

Thus

$$\mathbb{E}[Y]=1/p+1=3$$

Solution 2:

I've used the conditional probability for this question. I hope this point of view helps.

Let $Y_k$ the number of tosses until you get a result which is different from the first toss. And $X_k$ is the random variable for the first toss. $k$ is the index for tail ($t$) or head ($h$). I make a case decision:

a) The probability to get a head at the n-th toss, given a tail has been thrown at the first toss is $P(Y_h=n|X_t=1)=p^{n-1}$.

Then $P(Y_h=n\cap X_t=1)=P(Y_h=n|X_t=1)\cdot P(X_t=1)=p^{n-1}\cdot (1-p)$

b) The probability to get a tail at the n-th toss, given a head has been thrown at the first toss is $P(Y_t=n|X_h=1)=(1-p)^{n-1}$.

Then $P(Y_t=n\cap X_h=1)=P(Y_t=n|X_h=1)\cdot P(X_h=1)=(1-p)^{n-1}\cdot p$

Finally we have to sum the two probabilities. It confirms your result and indeed the expected value is $3$, if $p=0.5$.