Skip to main content
2 of 2
added 7 characters in body; edited title
Michael Hardy
  • 1
  • 12
  • 85
  • 126

Probability of winning game whereby $T+1$ heads in a row of a coin flip is required to win where $T$ is the number of cumulative tails flipped

I have a weird question which probably seems out of place here but it has proven more difficult than anticipated. I am going to describe the game without showing work toward a solution. Numerically, the solution is easy - it is about $71\%.$ A simple Python script to determine this is included at the end of the question.

Say I flip a coin. If I get heads, then I win the game I am describing. However, if I get tails, then I need two heads in a row to win the game. If instead I flip a tails while trying to get the necessary number of heads in a row, then I then need three heads in a row. That is, to win, I need to flip $T + 1$ heads consecutively, where $T$ is the cumulative number of tails flipped. I hope this is clear. If not, the script below is very explicit.

I want to find the overall probability of winning. Obviously, there is no losing condition, but the game quickly devolves into infinite flips as the probability of winning decreases rapidly. What is the overall probability of winning before the first coin flip? I want to derive an expression for this number.

I know this is weird and particularly 'unacademic', but any help would be appreciated to infinity and beyond.

Thank you.

import random
# number of games to play (should be infinity)
g = 100000
def game():
    # number of heads needed in a row before we give up (should also be infinity)
    N = 100
    # cumulative sum of tails
    T = 0
    # heads needed to win
    H = 1
    while H < N:
        # simulate flip
        flip = random.randint(0, 1)
        # 1 for h, 0 for t
        if flip == 1:
            H -= 1
        if flip == 0:
            T += 1
            H = T + 1
        # won
        if H == 0:
            return 1
    # not yet won
    return 0
outcomes = [game() for a in range(g)]
print(sum(outcomes)/len(outcomes))
user504691