Streak probability calculator
How likely is a run of k wins, heads or misses in a row? Exact odds, the longest streak to expect, and the HH vs HT coin puzzle.
Trials must be independent with the same chance each time, like coin flips or free throws from a steady shooter.
Use H and T, up to 8 flips. The coin is flipped until one of the two patterns appears.
What the calculator works out
Streaks look rare, and they are not. Ten made free throws in a row, five losing days in a row, six defective parts in a row on a line: each seems to demand an explanation, but in a long enough series such runs happen by chance alone. This page puts a number on it. For n independent trials with chance p each, it gives the exact probability of at least one run of k successes (or failures), the average wait for the first one, the number of such runs to expect and the average longest streak. A second tab does the coin-flip puzzle that surprises almost everyone: why HH takes 6 flips on average and HT only 4.
The method
Let u(m) be the probability that m trials contain no run of k successes. Then u(m) = 1 for m < k, u(k) = 1 − pk, and u(m) = u(m − 1) − (1 − p) pk u(m − k − 1) afterwards (Feller, vol. 1, chapter XIII). The probability of a run is 1 − u(n), with no simulation. The mean wait for the first run is (1 − pk) ÷ ((1 − p) pk). The expected number of separate runs of at least k is pk [1 + (n − k)(1 − p)] (MathWorld, “Run”). The expected longest run is found exactly by adding up the chances that the longest run is at least 1, 2, 3 and so on, and compared with the formula log1/p n(1 − p) (Gordon, Schilling and Waterman, 1986; Schilling, 1990). For patterns in coin flips the waiting time and the race follow Conway's leading numbers and Li's martingale proof (1980).
Worked example: a streak of 6 in 100 flips
The chance of 6 heads in a row starting at a given flip is (1/2)6 = 1.56%. In 100 flips the chance that a run of 6 or more appears somewhere is 54.61%, and you should expect 0.75 such runs; on average it takes 126 flips to see the first. For a shooter who makes 70% of shots, the chance of at least one run of 10 makes in 100 attempts is 58.01%, and the chance of at least four misses in a row is 43.26%.
Common mistakes and limits
Mixing “this run” and “some run”. The chance that the next 6 flips are all heads is 1.56%. The chance that 100 flips contain such a run is 54.61%. They answer different questions, and the second is what people usually mean by “is this streak unusual?”.
Believing a tail is due. With independent trials the past does not change the next one. A streak is not a sign that the process has changed unless the series is much longer or the streaks much more frequent than this calculator says.
Assuming real trials are independent. A shooter's chance varies with fatigue and defenders; a machine's with wear. The calculator assumes the same chance every time, so a real record with more or longer streaks than the model predicts suggests that the chance is not constant, not that the math is wrong.
Limits. Up to 20,000 trials and streaks up to 200. In the pattern tab, each pattern is at most 8 flips and neither may contain the other (HH inside HHT, for example, because then the shorter pattern always appears first).
Penney's game in numbers
HH takes 6 flips on average and HT only 4, yet a race between them is 50% each. For three flips the second player can always choose a pattern that beats the first: against HHH, THH wins 87.5%; against HHT, THH wins 75%. The same odds appear in Wikipedia's table for Penney's game. For longer patterns the tab finds the best reply by checking every pattern of the same length.
What is the chance of getting 6 heads in a row in 100 coin flips?
54.61%, a little over half. A specific run of 6 starting right now has probability (1/2)⁶ = 1/64 = 1.56%, but with 100 chances to start a run, and a new chance after every tail, the odds of a run somewhere add up fast. The same math says that a streak of 5 is very likely in 100 flips (81.0%), and one of 8 is less likely (17.0%). A real series of 100 flips therefore contains a run of 6 or more more often than not.
How long is the longest streak you should expect?
About log base 1/p of n(1 − p), plus a small correction. For a fair coin in 200 flips that is log₂ 100 = 6.64, and with the correction 6.98. The calculator also adds up the exact chances that the longest run is at least 1, 2, 3 and so on, which gives 6.984. This is why “about 7 in a row” is the typical answer for 200 flips. Doubling the number of flips adds just one to the longest streak, since the logarithm grows slowly.
How many flips does it take to get 6 heads in a row?
On average 126 flips. The mean wait for k successes in a row is (1 − pᵏ) ÷ ((1 − p)pᵏ): for 2 heads it is 6, for 3 heads 14, for 6 heads 126. It roughly doubles with each extra flip in the run. A streak is also much harder for a biased coin: a 30% shooter needs 175 shots on average to make 4 in a row.
Why does HH take longer than HT?
Both patterns have the same chance, 1/4, at any given position, but they are spread differently. HH can overlap itself (HHH contains it twice), so its appearances come in clumps and leave longer gaps between the clumps; HT cannot overlap itself, so it is spread more evenly. Waiting for HH, a tail right after an H throws your progress away; waiting for HT, a second H costs nothing, because the last H is still the start of an HT. The average wait is therefore 6 flips for HH and 4 for HT. Yet in a race, where the first to appear wins, they are equal: 50% each. After the first H, the next flip decides it, heads for HH or tails for HT.
What is Penney's game?
Two players each pick a sequence of three coin flips; the coin is tossed until one of the sequences appears. With three flips, the second player, who chooses after seeing the first pattern, can always do better than 50%. If the first picks HHH the best reply is THH, which wins 87.5%; against HHT it is THH, winning 75%. The game is non-transitive, like rock-paper-scissors: TTH beats THH 67%, HTT beats TTH 75%, HHT beats HTT 67%, THH beats HHT 75%; the last one closes the circle back to THH. Conway's leading-number algorithm gives these odds, and Li (1980) proved a general result with martingales.
Does a streak make the next trial more or less likely to succeed?
No, not when the trials are independent, as with fair coins, dice and roulette. The chance of a streak of 6 somewhere in 100 flips is high, but after 5 heads in a row the chance of a sixth head is still exactly 1/2. The “gambler's fallacy” is the belief that a tail is due. If a real process, such as a basketball shooter or a machine, shows more or longer streaks than the independent model predicts, then the model's assumption that every trial has the same chance, independently of the others, is what is wrong. This calculator assumes it holds.
How are the streak probabilities calculated?
Exactly. Let u(m) be the probability of no run of k successes in m trials. Then u(m) = 1 for m < k, u(k) = 1 − pᵏ, and for larger m, u(m) = u(m − 1) − (1 − p)pᵏ u(m − k − 1): a run-free sequence of length m is a run-free one of length m − 1, minus those that end with a failure followed by exactly k successes. The chance of at least one run is 1 − u(n). For a fair coin and k = 2 this gives (2ⁿ − F(n+2)) ÷ 2ⁿ, with F the Fibonacci numbers, a classical check. The calculator works up to 20,000 trials and streaks of 200.
Sources: Wolfram MathWorld, “Run” (the fair-coin result (2ⁿ − F(n+2))/2ⁿ for k = 2, the expected number of runs, the expected longest run log1/p(nq) with references to Gordon et al. 1986 and Schilling 1990); W. Feller, An Introduction to Probability Theory and Its Applications, vol. 1, chapter XIII (recurrence for runs and their mean waiting time); S.-Y. R. Li, “A martingale approach to the study of occurrence of sequence patterns in repeated experiments,” Annals of Probability 8(6), 1980, 1171–1176; Wikipedia, “Penney's game” (the table of odds for three-flip patterns). Our results are checked against an enumeration of every sequence of up to 14 trials and against an independent Markov-chain calculation. For random sequences in other settings see the birthday paradox calculator and the dice probability calculator; for exact counts of successes see the binomial probability calculator, and for a quick check of a single event the probability calculator. How we check our calculators.