Variance of the number of coin flips until we see a head

Faraz Gerrard Jamal
2 min readFeb 6, 2023

[This article is for a fair coin, p (head) = 0.5]

There are different techniques we can use to calculate the variance of the number of coin flips until we see a head :-

Technique #1 ->

We know, Var(n) = E(n²) — (E(n))² [:-n is number of flips until we see a head]

We know, E(n) = 2 so we want to estimate E(n²)

E(n²) = 0.5*1² + 0.5*E((n+1)²) [:- As we have wasted one flip, we need to estimate expected value of E((n+1)²)]

In case of E(n) we do,

E(n) = 0.5*1 + 0.5*(E(n+1)) => 0.5 + 0.5*(E(n) + 1))

=> E(n) = 2

Similarly, we have for the E(n²) case,

E(n²) = 0.5*¹² + 0.5*E((n+1)²)

x = 0.5 + 0.5*x + 0.5*1 + 2*0.5*1*y [Here x -> E(n²), y-> E(n) | (n+1)² = n² + 1 + 2*n and expectation is linear]

0.5*x = 1 + 1*y

0.5*x = 3

x = 6

=> Variance(n) = E(n²) — [E(n)]² = 6–4 = 2

Technique #2 ->

Second way is that this is a geometric distribution ~ geom(p = 1/2)

We know variance of a geometric distribution is => (1-p)/(p²)

Therefore, variance is 2.

Technique #3 ->

Third way is through writing it out as a series and then taking the difference twice =>

E(n²) = 0.5*1² + (0.5)²*2² + (0.5)³*3²…. -> (i)

0.5*E(n²) = 0.5²*1² + 0.5³*4 + 0.5⁴*9…… 0> (ii)

(i) — (ii),

0.5*E(n²) = 0.5 + 0.5²(1)(3) + 0.5³*(1)(5) + 0.5⁴(1)(7) + 0.5⁵(1)(9)… -> (iii)

0.5*0.5*E(n²) = 0.5² + 0.5³(3) + 0.5⁴(5) + 0.5⁵(7)… -> (iiii)

(iii) — (iiii),

0.5*0.5*E(n²) = 0.5 + 2*(0.5² + 0.5³ + 0.5⁴…)

0.5*0.5*y = 0.5 + 2*(0.5²/0.5) [:- y => E(n²)]

0.5*0.5*y = 1.5

y = 6 => E(n²) = 6

--

--