We have two coins, A and B. For each toss of coin A, we obtain Heads with probability 1/2 and for each toss of coin B, we obtain Heads with probability 1/3 . All tosses of the same coin are independent.

We toss coin A until Heads is obtained for the first time. We then toss coin B until Heads is obtained for the first time with coin B. Calculate expected value of the total number of tosses?

  • $\begingroup$ Hint : Use the property of Linearity of Expectations and then use geometric distribution. $\endgroup$ Commented Jun 9, 2019 at 14:14

2 Answers 2


When you toss the first coin, you will get expected value, from definition $$\mathbb{E}[X] =\sum_{i=1}^\infty x_i\,p_i=x_1p_1 + x_2p_2 + \dots$$

so 1 toss with probability 1/2 + 2 tosses with prob 1/2*1/2 and so on, gives:

$$\mathbb{E}[A] = 1*\frac{1}{2} + 2*\Big(\frac{1}{2}\Big)^2 + 3*\Big(\frac{1}{2}\Big)^3+\dots$$

which gives Arithmetico-geometric sequence

with $a = 0$ and $d = 1$ the infinite sum formula is simplifies to: $$S=\frac{b r}{(1-r)^2}$$ in this $b=1/2$ and $r=1/2$, so $$\mathbb{E}[A] = 2$$

Now the second toss simirarly: $$\mathbb{E}[B] = 1*\frac{1}{3} + 2*\Big(\frac{2}{3}\Big)*\Big(\frac{1}{3}\Big) +3*\Big(\frac{2}{3}\Big)^2*\Big(\frac{1}{3}\Big)+\dots$$

which again gives Arithmetico-geometric sequence

in this case $b=1/3$ and $r=2/3$ gives $$\mathbb{E}[B] = 3$$

second tossing will happen right after the first so you can add tosses giving $$\mathbb{E}(A)+\mathbb{E}(B)=5$$

Hereby a short python script that can validate the result:

from random import random
import numpy as np

def toss_til_heads(p):
    n = 0
    while True:
        heads = random() < p
        n += 1
        if heads:
            print('H', end=' ')
            return n
            print('T', end=' ')

NUM_TRIES = 1000
tries = np.zeros(NUM_TRIES, np.uint32)

for i in range(len(tries)):
    tries[i] = toss_til_heads(1/2.) + toss_til_heads(1/3.)


A and B are both geometric distributions, so by definiton: $$E(A+B)=E(A)+E(B)=\frac{1}{1/2}+\frac{1}{1/3}=2+3$$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .