The maximum run (or longest run) in n Bernoulli trials is the length of the longest consecutive block of successes. It is not the same as the total number of successes: two sequences can contain the same number of successes but have very different longest runs.
For independent trials with constant success probability p, the longest run typically grows on a logarithmic scale, roughly like log1/p(n) for large n. For a specific finite n and p, use an exact finite-state calculation when accuracy matters.
What “maximum run” means
Let X1, …, Xn be independent Bernoulli trials, with success probability p in every trial. A success might be heads in a coin-toss sequence. Define Ln as the largest number of consecutive successes anywhere in the sequence.
For example, the sequence S F S S F S S S contains six successes in total, but its maximum success run is three. The ordering matters as much as the count.
#1 Best Overall
This definition concerns success runs only. The longest block of either successes or failures is a different statistic and requires a different calculation.
Choose the probability question first
“The probability of a run” can refer to several different events. State the event, the number of trials, and the success probability before calculating.
- Longest run at most k: P(Ln ≤ k).
- Longest run at least k: P(Ln ≥ k) = 1 − P(Ln ≤ k − 1).
- Exactly k: P(Ln = k) = P(Ln ≤ k) − P(Ln ≤ k − 1).
These are not binomial probabilities. A binomial calculation gives the probability of a total number of successes, not their longest consecutive block.
Exact finite-sample calculation
To calculate P(Ln ≤ k), require that every block of k + 1 consecutive trials contain at least one failure. A finite-state recurrence tracks the current terminal success streak and discards any sequence that reaches k + 1.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11State definition
After each trial, keep probabilities for states 0, 1, …, k. State j means that the sequence currently ends with exactly j consecutive successes, while no run longer than k has occurred.
Transition rule
- A failure, with probability 1 − p, sends every state to state 0.
- A success, with probability p, sends state j to state j + 1 when j < k.
- A success from state k is excluded, because it creates a run of k + 1.
Recurrence
Let at,j be the probability that after t trials the current streak is j and no run exceeds k. Start with a0,0 = 1 and a0,j = 0 for j > 0. For each new trial:
Rank #3
- at+1,0 = (1 − p) Σj=0k at,j
- at+1,j = pat,j−1 for 1 ≤ j ≤ k
Then P(Ln ≤ k) = Σj=0k an,j. This recurrence is exact for the stated iid model and can be implemented with an array of k + 1 numbers; it does not require enumerating all 2n sequences.
Practical algorithm
- Set an array
state[0..k]to zero and assignstate[0] = 1. - Repeat n times: compute the next array, putting
(1-p) * sum(state)in index 0 andp * state[j-1]in index j for each j from 1 through k. - Sum the final array to obtain P(Ln ≤ k).
- Use complements or differences for “at least” and “exactly” events.
When the total number of successes is fixed
Sometimes the question is conditional: exactly r of the n trials are successes, and the order is random. That is the event Sn = r, where Sn is the total success count.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The relevant quantity is then P(Ln ≤ k | Sn = r). This is an arrangement problem over sequences containing r successes, not an unconditional iid calculation with success probability p. Philippou and Makri’s 1986 paper, Successes, runs and longest runs, gives a formula for this conditional distribution.
Do not replace a fixed-count question with a binomial model. The binomial model determines how likely each value of Sn is; once Sn is fixed, the calculation must account for the possible arrangements and their runs.
How the longest run grows for large n
For iid Bernoulli trials with constant p, the nominal large-sample scale is
Ln ≈ log1/p(n).
This is an asymptotic order-of-growth statement, not a guarantee that an observed sequence will contain exactly that run length. The discrete distribution can show integer effects and oscillations, and small samples can differ substantially from the logarithmic scale.
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- Brand New Textbook
- U.S Edition
- Fast shipping
The 2015 paper Laplace transform asymptotics and large deviation principles for longest success runs in Bernoulli trials develops this asymptotic behavior and gives an expansion for the mean containing a log1/p(n) term, a correction involving log1/p(1 − p), Euler’s constant γ ≈ 0.5772, and a residual described as small. That expansion is useful for asymptotic analysis; it should not be treated as an exact finite-sample mean.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.A quick heuristic for the typical scale
A rule of thumb asks when the expected number of long runs is about one. A commonly cited approximation for the expected number of runs of length at least R is n(1 − p)pR. Setting this near one gives
R ≈ log1/p[n(1 − p)].
This estimate is a convenient intuition, not an exact distribution or a universal formula for the expected longest run. Its run-counting convention is approximate, and boundary effects, integer rounding, and dependence between overlapping candidate runs can matter.
Exact method or logarithmic estimate?
| Method | Best use | Strength | Limitation |
|---|---|---|---|
| Finite-state recurrence | Concrete n, p, and a specified event | Exact finite-sample probability under iid assumptions | Requires a separate calculation for each threshold or distribution value |
| Logarithmic scale | Large-n intuition and order-of-magnitude estimates | Shows how the longest run changes with n and p | Not an exact probability, and less reliable for small n or boundary values of p |
| Conditional arrangement calculation | Total successes fixed at r | Matches the information that the count is known | Not interchangeable with the unconditional Bernoulli model |
Assumptions and common pitfalls
- Independence: The recurrence and logarithmic results assume trials do not influence one another.
- Constant probability: Every trial uses the same p. If probabilities vary by trial, use a time-dependent model.
- Correct outcome: A longest-success-run result does not automatically describe the longest run of either outcome.
- Finite versus asymptotic: Logarithmic formulas describe large-sample behavior; exact recurrences are preferable when a decision depends on a particular finite probability.
- Extreme probabilities: Very small or very large p, and short sequences, make rough heuristics especially unreliable.
If outcomes are dependent, such as results generated by a changing physical process or a Markov chain, model that dependence directly rather than applying the iid Bernoulli formula by default.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

