(This is not a homework question; I just want to understand how this works)

Let's say I am playing a game, where I need to flip a coin. I need to get $X$ number of heads in a row in order to win. The coin is unbalanced, and has $p$ probability of landing on heads and $1-p$ probability of landing on tails. Consecutive flips are independent of previous ones.

The game ends when I flip $X$ heads in a row; if I flip only heads the game ends in $X$ flips, if I flip $X-1$ heads, then one tail, then $X$ heads, the game ends in $2X$ flips.

  1. What is the expected value of coin flips?
  2. What is this distribution called?

I understand that this can probably be defined as some sum of binomial distributions; just curious if there's another way to do it.


1 Answer 1


I am not sure if the distribution has a name, or explicit form of probability mass function ...

For calculating the expectation it can be solved using classic stochastic process approach. Let us just calculate the expected number of flips to get "HH" as an example.

Possible states in the process are:

S: starting state, you haven't started flipping yet

H: get one head

T: get one tail

HH: get two heads and game over

Transition probability:

$T \xleftarrow{1-p} S \xrightarrow{p} H$

$T \xleftarrow{1-p} H \xrightarrow{p} HH$

$T \xleftarrow{1-p} T \xrightarrow{p} H$

Let $\mu_{state}$ be the expected number of flips to get to HH starting from $state$. Then we can get a series of linear equations regarding $\mu_{state}$ using transition probabilities.

For example, after 1 move from $S$, we can get to $H$ with probability $p$, and to $T$ with $1-p$. Therefore we have: $ \mu_{S} = 1 + p\mu_{H} + (1-p)\mu_{T} $

Derive the others following similar logic:

$\mu_{H} = 1 + p\mu_{HH} + (1-p)\mu_{T}$

$\mu_{T} = 1 + p\mu_{T} + (1-p)\mu_{H}$

$\mu_{HH} = 0$ since it is already the goal state.

There are 4 equations and 4 variables. You can solve for $\mu_{S}$ and get the answer.


Not the answer you're looking for? Browse other questions tagged or ask your own question.