# Finding the PMF, expected value, and variance of getting one heads and one tails when flipping a coin

As the title suggests, this is a discrete random variable with a countably infinite number of possibilities. I am trying to find the number of coins flips it takes to get a least 1 heads and 1 tails. So my first flip is either heads or tails, then my second flip is heads or tails, and so on. So my sample space would be {(H,T),(T,H),(T,T,H),(H,H,T)...} So it looks there is 1/2 chance that my experiment ends in 2 flips, 1/4 it ends in 3 flips, 1/8 it ends in 4 flips, and so on. So my PMF would seem to take the form of $$p(x)={1/2^{n-1} , n=2,3,4,5,...}$$ and 0 otherwise.

So the expected value would be $$E[X]=\sum_{n=2}^{\infty}n{\frac1{2^{n-1}}}$$

So to solve this I let m=n-1 to get $$E[X]=\sum_{m=1}^{\infty}(m+1){\frac1{2^{m}}}$$

I feel like this should equal 3 but I am not sure exactly how to express that.

• Your question is not clearly posed. You are asking for a PMF, expectation, and variance--which apply to a random variable. But "one heads and one tail" is not a random variable; it is an event. Moreover, this event is not clearly defined because you've not stated how many times the coin is flipped. – heropup Sep 29 '19 at 23:59
• Hero, you are flipping the coin up to an infinite number of times. You stop when you have flipped a heads and a tails. – mattsprestige Sep 30 '19 at 4:58
• And what is the random variable of interest? The total number of coin flips? – heropup Sep 30 '19 at 5:18
• @heropup I worked on the problem last night and I think tried to clarify the experiment. Hopefully, it is more clear what I am trying to do – mattsprestige Sep 30 '19 at 17:38

\begin{align} \sum_{m=1}^\infty \frac{m+1}{2^m} &= \sum_{m=1}^\infty \frac{m}{2^m} + \sum_{m=1}^\infty\frac{1}{2^m} \\ &=\sum_{m=1}^\infty m (0.5)^{m-1}(0.5) + \frac12 \cdot \frac{1}{1-0.5}\\ &= \frac1{0.5}+\frac12 \cdot \frac{1}{0.5} \\ &= 3 \end{align}
The first term is due to that is the expression of the expected value of geometric distribution with success probability $$0.5$$ and the second term is just a geometric sum.
A faster working is actually identifying it as $$1+X$$
where $$X$$ is a geometric distribution with success probability $$0.5$$. $$1$$ comes from the first toss and the success event is to get a different outcome from the first toss. From there you can obtain the expected value, pmf, and the variance.
We have $$E[1+X]=E[X]+1$$ and $$Var(X+1)=Var(X)$$.