Is there a standard formula for calculating the maximum, minimum and average number of times you need to flip a coin before observing a desired sequence?
Suppose you have a coin that has a 95% chance of landing on HEADS and a 5% chance of landing on TAILS. Suppose you are interested in knowing the maximum, minimum and average number of times you need to flip a coin before observing HEADS, TAILS, HEADS.
It is straightforward to find out the probability of this sequence : P(H,T,H) = 0.95 * 0.05 * 0.95 = 0.045.
But for some reason, I don't think that this means that :if you were to consider 3 flips as a "run" - in 100 "runs", on average 4.5 of these runs would result in HEADS, TAILS, HEADS
My question: Is there an exact formula that can answer these kinds of questions?
- The maximum number of "runs" before observing HEADS, TAILS, HEADS
- The minimum number of "runs" before observing HEADS, TAILS, HEADS
- The average number of "runs" before observing HEADS, TAILS, HEADS
Or can such a question only be solved using simulation methods? (e.g. program a computer to simulate many such "runs" and answer the above questions through simulation)
Thanks!
Your intuition about the meaning of the probabilities is wrong. $P(H,T,H)=p$ does mean that, considering a sequence of 3 flips, $H,T,H$ will appear with probability $p$.
As for the maximum number of runs before you observe your desired run: there are no such numbers. In any finite number of runs, there will be a positive probability that you did not observe your desired run. The minimum is simply 1 - you might observe it the first time.
To calculate the average number of runs before observing $H,T,H$: we can treat each run as a Bernoulli trial or coin flip by itself. We observe $H,T,H$ with probability $p$ and fail to with probability $1-p$. The number of runs is then described by the Geometric distribution. The average number of runs is then its mean: $1/p$.