Probability of a Run of Heads
Work out the chance of getting at least k heads in a row in n coin tosses, counted exactly by dynamic programming rather than simulated.
P
—
Longest run of tails in coin tosses
Toss a fair coin n times and ask how likely you are to hit at least one run of k tails in a row. There's no tidy closed form for this, but once n gets large the approximation P ≈ (n − k + 1) · (1/2)^k works well. The longest run you'd expect to see is roughly log₂(n). Take 100 tosses: a streak of 6 or 7 tails is perfectly ordinary and says nothing about a biased coin. Most people picture random sequences as neatly alternating (HTHTHT…), yet genuine randomness clumps together. That's the randomness paradox. Long runs argue for randomness, not against it.
Applications
Researchers use it in studies of perceived randomness. Runs tests like Wald–Wolfowitz flag non-randomness in binary sequences, and the same idea audits random number generators and validates the entropy of passwords and tokens. It also catches fraud in data that's supposed to be random, such as forged coin-toss logs that conveniently lack the long runs you'd expect.
FAQ
If I just got 5 tails, is heads "due"? No. Every toss stands alone, so what came before has zero pull on the next one. Believing otherwise is the gambler's fallacy.
Why log₂(n)? Because each extra tail halves the probability — doubling the number of tosses adds roughly one to the expected longest run.
How accurate is the approximation? For small k it overestimates slightly (overlapping windows are counted), but for k ≥ 4 and n ≥ 50 it is within a few percent of the exact value.
Related Tools
Protein Molecular Weight from Amino Acid Sequence
Adds the residue masses of a one-letter amino acid sequence and subtracts 18.015 Da per peptide bond, returning protein molecular weight in daltons.
Dice Sum Probability Calculator
Enter how many six-sided dice and a target total to get P(sum = s) by convolution, plus the raw count over 6^n. Two dice landing on 7 give 6/36.
Common-Language Effect Size (CLES)
Computes the common-language effect size (CLES), also called the probability of superiority. It's the most intuitive way to communicate a difference between groups: the probability that a value drawn from the first group is larger than a value drawn from the second. A CLES of 0.70 means that, in 70% of random comparisons, the first group wins. Ties count as half. It's the friendly version of Cliff's delta. Enter the two groups of values.
Probable Stops
Calculate the probable number of stops of an elevator, S = N × (1 − (1 − 1/N)^P), from the number of served floors N and the number of passengers P in the car. The result is how many floors, on average, the elevator actually stops at during a trip (probabilistically, two passengers may go to the same floor). It is an essential parameter of the round trip time calculation: more stops raise the RTT. The formula assumes passengers choose destination floors randomly and uniformly. With a full car, S approaches N (stops at almost all). Enter the number of floors and passengers.
Arithmetic Progression
Calculate the general term and sum of an Arithmetic Progression. Enter the first term, common difference and number of terms.
Conditional Probability Calculator
Works out P(A|B) by dividing the joint probability P(A∩B) by P(B), the rule behind Bayes theorem and behind any update made after new evidence arrives.
The results provided by this tool are for general informational and educational purposes only and do not constitute professional, financial, medical, legal, tax or accounting advice. Always confirm important decisions with a qualified professional and official sources.