TOPICS
Search

Run


A run is a sequence forming a maximal nonempty block of consecutive identical outcomes, also known as a clump.

Let R_p(r,n) be the probability that a run of r or more consecutive heads appears in n independent tosses of a coin (i.e., n Bernoulli trials), where r is a positive integer and n is a nonnegative integer. This is equivalent to repeated picking from an urn containing two distinguishable objects with replacement after each pick. Let the probability of obtaining a head be 0<p<1. Then there is a formula for R_p(r,n) given in terms of the coefficients of the generating function

 F_p(r,s)=(p^rs^r(1-ps))/(1-s+(1-p)p^rs^(r+1))=sum_(i=r)^inftyc_i^ps^i
(1)

(Feller 1968, p. 300). Then

 R_p(r,n)=sum_(i=r)^nc_i^p.
(2)

The sum is zero when n<r. The following table gives the number triangle of numbers 2^nR_(1/2)(r,n) for n=1, 2, ... and r=1, 2, ..., n (OEIS A050227).

SloaneA000225A008466A050231A050232
n\r12345678
110000000
231000000
373100000
4158310000
53119831000
663432083100
71279447208310
82552011074820831

The special case r=2 gives the sequence

 R_(1/2)(2,n)=(2^n-F_(n+2))/(2^n),
(3)

where F_n is a Fibonacci number. Similarly, the probability that no k consecutive tails will occur in n tosses is given by F_(n+2)^((k))/2^n, where F_l^((k)) is a Fibonacci k-step number and k is a positive integer.

Feller (1968, pp. 278-279) proved that for w(n)=1-R_(1/2)(3,n),

 lim_(n->infty)w(n)alpha^(n+1)=beta,
(4)

where

alpha=(x^3+2x^2+4x-8)_1
(5)
=1.087378025...
(6)

(OEIS A086253) is the positive root of the above polynomial and

beta=(2-alpha)/(4-3alpha)
(7)
=(11x^3-22x^2+12x-2)_1
(8)
=1.236839844...
(9)

(OEIS A086254) is the positive root of the above polynomial. The corresponding constants for a run of k>1 heads are alpha_k, the smallest positive root of

 1-x+(1/2x)^(k+1)=0,
(10)

and

 beta_k=(2-alpha_k)/(k+1-kalpha_k).
(11)

For an unfair coin with P(H)=p and P(T)=q=1-p, let alpha_k^' be the unique positive root of the reduced polynomial

 Q_k(x)=1-qsum_(j=0)^(k-1)p^jx^(j+1)=0,
(12)

and set

 beta_k^'={(1-palpha_k^')/((k+1-kalpha_k^')q)   if p!=k/(k+1); 2   if p=k/(k+1).
(13)

Then [1-R_p(k,n)](alpha_k^')^(n+1)->beta_k^' as n->infty (Feller 1968, pp. 322-325; Finch 2003, p. 339). The unreduced polynomial 1-x+qp^kx^(k+1)=(1-px)Q_k(x) always has a root at 1/p. This root is removable from the avoidance generating function, so choosing the smallest positive root of the unreduced polynomial fails to identify the decay rate when p>k/(k+1).

Let N_R be the expectation value of the number of maximal head runs of length at least R in n independent Bernoulli trials, with P(H)=p, q=1-p, and R a positive integer. Counting possible starting positions gives

 N_R={p^R[1+(n-R)q]   if n>=R; 0   if n<R.
(14)

For fixed R and p as n->infty, this is approximately nqp^R. The expectation value of the longest head run L_n has leading logarithmic growth

 <L_n>=log_(1/p)(nq)+O(1),
(15)

where O(1) is big-O notation and 0<p<1 is fixed as n->infty (Gordon et al. 1986, pp. 283-284; Schilling 1990, pp. 201-202).

For positive integers m and n, choose uniformly from the arrangements of m 0s and n 1s. The number of such arrangements with u runs is

 f_u={2(m-1; k-1)(n-1; k-1)   u=2k; (m-1; k)(n-1; k-1)+(m-1; k-1)(n-1; k)   u=2k+1
(16)

for k a positive integer, where (a; b) is a binomial coefficient, taken to be zero for b<0 or b>a (Johnson and Kotz 1968, p. 268). Then

 P(u<=u^')=sum_(u=2)^(u^')(f_u)/((m+n; m)).
(17)

Now consider drawing all N=m+k objects without replacement in uniformly random order from a collection containing m indistinguishable objects of one type and k indistinguishable objects of another, where m and k are nonnegative integers. Let N(r;m,k) denote the number of permutations of these objects in which no run of length at least r occurs, where r is a positive integer. For example, there are 6 permutations of two objects of type A and two of type B. Of these, AABB, ABBA, BAAB, and BBAA contain runs of length two, so N(2;2,2)=2. In general, the probability that an r-run does occur is given by

 P(r;m,k)=1-(N(r;m,k))/((m+k; k)),
(18)

where (a; b) is a binomial coefficient. Bloom (1996) gives the following recurrence sequence for N(r;m,k),

 N(r;m,k)=e(r;m,k)+sum_(i=0)^(r-1)N(r;m-1,k-i)-sum_(i=1)^(r-1)N(r;m-r,k-i),
(19)

where N(r;m,k)=0 for m or k negative and

 e(r;m,k)={1   if m=0 and 0<=k<r; -1   if m=r and 0<=k<r; 0   otherwise.
(20)

Another recurrence which has only a fixed number of terms is given by

 N(r;m,k)=N(r;m-1,k)+N(r;m,k-1)-N(r;m-r,k-1)-N(r;m-1,k-r)+N(r;m-r,k-r)+e_r^*(m,k),
(21)

where

 e_r^*(m,k)={1   if (m,k)=(0,0) or (r,r); -1   if (m,k)=(0,r) or (r,0); 0   otherwise.
(22)

(Goulden and Jackson 1983, Bloom 1996).

These formulas can be used to calculate the probability of obtaining a run of at least r cards of the same color in a deck of 52 cards. For r=1, 2, ..., this yields the sequence 1, 247959266474051/247959266474052, ... (OEIS A086439 and A086440). Normalizing by multiplying by (52; 26) gives 495918532948104, 495918532948102, 495891608417946, 483007233529142, ... (OEIS A086438). The result

 P(6;26,26)=(2740784175881)/(5903792058906)=0.46424...
(23)

disproves the assertion of Gardner (1982) that "there will almost always be a clump of six or seven cards of the same color" in a normal deck of cards.

Bloom (1996) gives the expected number of noncontiguous r-runs (i.e., split the sequence into maximal clumps of the same value and count the number of such clumps of length >=r) in a uniformly chosen sequence of m 0s and n 1s, for nonnegative integers m and n with m+n>=1 and 1<=r<=m+n, as

 E(n,m,r)=((m+1)(n)_r+(n+1)(m)_r)/((m+n)_r),
(24)

where (a)_n is the falling factorial. For positive integers m and n, the number of runs u has exact mean and variance

mu_u=1+(2mn)/(m+n)
(25)
sigma_u^2=(2mn(2mn-m-n))/((m+n)^2(m+n-1)).
(26)

As m and n tend to infinity with m/(m+n) fixed strictly between 0 and 1, (u-mu_u)/sigma_u approaches a normal distribution with mean 0 and variance 1 (Mood 1940, pp. 378-382).


See also

Cards, Coin Tossing, Eulerian Number, Hypergeometric Distribution, Permutation, Permutation Run, s-Run

Explore with Wolfram|Alpha

References

Bloom, D. M. "Probabilities of Clumps in a Binary Sequence (and How to Evaluate Them without Knowing a Lot)." Math. Mag. 69, 366-372, 1996. https://doi.org/10.1080/0025570X.1996.11996476.Feller, W. An Introduction to Probability Theory and Its Applications, Vol. 1, 3rd ed. New York: Wiley, 1968.Finch, S. R. "Feller's Coin Tossing Constants." §5.11 in Mathematical Constants. Cambridge, England: Cambridge University Press, pp. 339-342, 2003.Gardner, M. Aha! Gotcha: Paradoxes to Puzzle and Delight. New York: W. H. Freeman, p. 124, 1982.Godbole, A. P. "On Hypergeometric and Related Distributions of Order k." Commun. Stat.: Th. and Meth. 19, 1291-1301, 1990. https://doi.org/10.1080/03610929008830262.Godbole, A. P. and Papastavridis, G. (Eds.). Runs and Patterns in Probability: Selected Papers. New York: Kluwer, 1994.Gordon, L.; Schilling, M. F.; and Waterman, M. S. "An Extreme Value Theory for Long Head Runs." Prob. Th. and Related Fields 72, 279-287, 1986. https://doi.org/10.1007/BF00699107.Goulden, I. P. and Jackson, D. M. Combinatorial Enumeration. New York: Wiley, 1983.Johnson, N. and Kotz, S. Discrete Distributions. New York: Wiley, 1968.Mood, A. M. "The Distribution Theory of Runs." Ann. Math. Statistics 11, 367-392, 1940. https://doi.org/10.1214/aoms/1177731825.Numberphile. "Consecutive Coin Flips." Jun. 8, 2016. https://www.youtube.com/watch?v=SDw2Pu0-H4g.Philippou, A. N. and Makri, F. S. "Successes, Runs, and Longest Runs." Stat. Prob. Let. 4, 211-215, 1986. https://doi.org/10.1016/0167-7152(86)90069-6.Schilling, M. F. "The Longest Run of Heads." Coll. Math. J. 21, 196-207, 1990. https://doi.org/10.1080/07468342.1990.11973306.Schuster, E. F. In Runs and Patterns in Probability: Selected Papers (Ed. A. P. Godbole and S. Papastavridis). Boston, MA: Kluwer, pp. 91-111, 1994.Sloane, N. J. A. Sequences A000225/M2655, A008466, A050227, A050231, A050232, A050233, A086253, A086254, A086438, A086439, and A086440 in "The On-Line Encyclopedia of Integer Sequences."

Referenced on Wolfram|Alpha

Run

Cite this as:

Weisstein, Eric W. "Run." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/Run.html

Subject classifications