_{1}

The question of how many shuffles are required to randomize an initially ordered deck of cards is a problem that has fascinated mathematicians, scientists, and the general public. The two principal theoretical approaches to the problem, which differed in how each defined randomness, has led to statistically different threshold numbers of shuffles. This paper reports a comprehensive experimental analysis of the card randomization problem for the purposes of determining 1) which of the two theoretical approaches made the more accurate prediction, 2) whether different statistical tests yield different threshold numbers of randomizing shuffles, and 3) whether manual or mechanical shuffling randomizes a deck more effectively for a given number of shuffles. Permutations of 52-card decks, each subjected to sets of 19 successive riffle shuffles executed manually and by an auto-shuffling device were recorded sequentially and analyzed in respect to 1) the theory of runs, 2) rank ordering, 3) serial correlation, 4) theory of rising sequences, and 5) entropy and information theory. Among the outcomes, it was found that: 1) different statistical tests were sensitive to different patterns indicative of residual order; 2) as a consequence, the threshold number of randomizing shuffles could vary widely among tests; 3) in general, manual shuffling randomized a deck better than mechanical shuffling for a given number of shuffles; and 4) the mean number of rising sequences as a function of number of manual shuffles matched very closely the theoretical predictions based on the Gilbert-Shannon-Reed (GSR) model of riffle shuffles, whereas mechanical shuffling resulted in significantly fewer rising sequences than predicted.

Proposed solutions to the problem of determining the number of shuffles required to randomize a deck of cards have drawn upon concepts from probability theory, statistics, combinatorial analysis, group theory, and communication theory [

Probability as a coherent mathematical theory is said to have been “born in the gaming rooms of the seventeenth century” in attempts to solve one or another betting problem [

The standard way to mix a deck of cards randomly is to shuffle it, for which purpose the riffle shuffle is perhaps the most widely studied form. To execute a riffle shuffle, one separates (“cuts”) the deck into two piles, then interleaves the cards by dropping them alternately from each pile to reform a single deck. The process can be performed either by hand or mechanically by an auto shuffler, like the device shown in

where shuffles are not perfect, the order of the cards from each pile is degraded with each successive riffle shuffle.

The central question comprising the card randomization problem is this: How many riffle shuffles are required to randomize a deck of cards? More accurately stated: After how many shuffles can one detect no evidence of non-randomness? Various researchers have studied this question theoretically and arrived at statistically different answers, depending on the adopted measure of randomness. In the analysis of Bayer and Diaconis [

m VD ( n ) ≈ 3 2 log 2 ( n ) (1)

shuffles should adequately randomize a deck of n cards. Thus m VD ( 52 ) is about 8 - 9. According to [

‖ Q n , m − U n ‖ = 1 − 2 2π ∫ − ∞ − 1 / 4 3 e − t 2 2 d t ≈ 0.115 (2)

for large n with m given by Equation (1). For complete randomness, the VD would equal 0.

In a numerical analysis by Trefethen and Trefethen [^{th} permutation of S n , then the Shannon entropy of the deck is given by

H = − ∑ j = 1 n ! p j log 2 p j (3)

where, by completeness,

∑ j = 1 n ! p j = 1 , (4)

and the information associated with the set of probabilities { p j } was defined as

I n = log 2 ( n ! ) − H . (5)

According to [

m IT ( n ) ≈ log 2 ( n ) (6)

shuffles should adequately randomize a deck of n cards. Thus m IT ( 52 ) is about 5 - 6, in contrast to m VD ( 52 ) . The numerically obtained results of [

The structure of relation (5) provides a mathematical definition of the word “information” consistent with its general vernacular use. If there is no uncertainty in the communication of any n-symbol message based on card sequence, then p j = 1 for each permutation j. In that case H = 0 and the information I n = log 2 n ! is maximum. If, however, every message received is completely uncertain as to card order, then p j = 1 / n ! for each permutation j, and therefore, by use of Equation (4), the information I n = 0 . Alternatively [

Although the two analyses [

C k n ≡ n ! k ! ( n − k ) ! (7)

is the binomial combinatorial coefficient. The two halves are then riffled together such that the probability of a card being dropped from a pile is proportional to the number of cards in the pile.

The research literature on the randomization of cards by shuffling is vast. An extensive list of references that survey the development of the problem, of which virtually all papers are theoretical analyses or numerical modeling by computer simulation, can be found in [

This paper reports on an extensive set of tests by which was measured the progression toward randomness of card sequences produced in multiple riffle shuffles manually and, for comparison, by a mechanical auto shuffler.

The basic theory and experimental outcomes of the following measures of randomness are discussed in Section 2: 1) runs with respect to the mean, 2) runs up/down, 3) rank ordering, 4) serial correlation (lag 1), and 5) theory of rising sequences.

Analysis of the data by information theory is discussed in Section 3.

Conclusions are presented in Section 4.

Experiments were undertaken to examine the permutations of card order in a deck of n = 52 cards as a function of shuffle number m for m = 0 , 1 , ⋯ , M implemented N times. For the experiments reported here, the number of shuffles per set is M = 19 and the number of sets is N = 12. In addition to manual shuffles, the experiments were also carried out with the mechanical auto shuffler of

The experiment began with an ordered deck (column m = 0, highlighted in red), with card values increasing from 1 (top card) to 52 (bottom card). Permutations of card order for each shuffle m = 1 , 2 , ⋯ , M are recorded sequentially in columns from left to right. A cursory examination of the table immediately reveals patterns of ascending sequences (highlighted in yellow) and descending sequences (highlighted in green) that extend across all the columns. Each of the N sets of card shuffles was subject to a variety of statistical tests to quantify the non-randomness of the permuted orderings indicated by these and other patterns.

A run is defined as a succession of similar events preceded and succeeded by a different event. For example, the sequence of 12 symbols

b b a a a b b b a b a b

contains:

2runsof a oflength1 2runsof b oflength1 1runof b oflength2 1runof a oflength3 1runof b oflength3 (8)

or a total of 7 runs. If a sequence is random, then all permutations of symbol order should have the same probability of occurrence. From this invariance principle, as applied to a sequence containing n a symbols of type a, n b symbols of type b, and n = n a + n b symbols in all, it can be deduced that [

・ the mean number of runs of a of length precisely k (where k ≥ 1 ) is

r ¯ k a = n a ! n b ( n b + 1 ) ( n − k − 1 ) ! ( n a − k ) ! n ! (9)

・ the mean number of runs of a of length k or greater (i.e. inclusive runs) is

R ¯ k a = n a ! ( n b + 1 ) ( n − k ) ! ( n a − k ) ! n ! (10)

・ the mean number of total runs of both kinds is

R ¯ = R ¯ 1 a + R ¯ 1 b = n + 2 n a n b n . (11)

Expressions for r ¯ k b , R ¯ k b follow, mutatis mutandis, from Equation (9) and Equation (10). Proofs of these expressions are given in [

Two methods were employed in this paper to generate runs of binary symbols from the experimentally recorded sequences of digital card values.

The card value x i ( i = 1 , ⋯ , n ) at location i in the sequence resulting from a particular shuffle is compared with a target value X, here taken to be the mean

X = 1 n ∑ i = 1 n x i → 26.5 (12)

which reduces as shown for the case n = 52 with set of card values { x = 1 , 2 , ⋯ , 52 } . If x i < X , the symbol 0 is assigned to location i; if x i > X , the symbol 1 is assigned to location i. Because the set { x i } is comprised of integers, the event x i = X cannot occur. Moreover, the set is equally partitioned:

n 1 = n 0 = 1 2 n ,

and the mean number of total runs, Equation (11), reduces to

R ¯ mean = n + 2 2 → 27 (13)

where the numerical value again applies to the case of n = 52 .

The associated variance (with corresponding standard deviation) is given by [

σ mean 2 ≈ n 4 ( 1 − 1 n − 1 ) ≈ n − 1 4 σ mean → 3.57 (14)

with numerical evaluation for n = 52 . It can also be shown that the test statistic

z mean = R − R ¯ mean σ mean → N ( 0 , 1 ) (15)

for the observed total number of runs is approximately Gaussian for sufficiently large n. The symbol N ( 0 , 1 ) designates the standard normal distribution of mean 0 and variance 1.

As an example, consider the 10-card decimal sequence generated by a uniform random number generator (RNG) over the integer range (1 ... 52):

x = { 294745326344436385 } (16)

The resulting binary series with target taken to be the mean (12) is then

y mean = { 1111011110 } (17)

which comprises the following set of target runs

2runsof0oflength1 2runsof1oflength4 (18)

for a total of 4 runs with respect to the mean.

For a long equipartitioned sequence ( n 1 = n 0 ≫ 1 ), the contribution of runs at the start or end of a sequence becomes negligible compared with the number of runs within the sequence, and Equation (9) and Equation (10) may be approximated as follows [

r ¯ k a ≈ n 2 k + 2 (19)

R ¯ k a ≈ n 2 k + 1 . (20)

Equation (19) and Equation (20) are illustrative of the general exact relation

r ¯ k a = R ¯ k a − R ¯ ( k + 1 ) a (21)

that follows from the definitions of r ¯ k a and R ¯ k a .

An alternative method of generating sequences of binary symbols that provides an independent test for non-random symbol patterns is to calculate sequential differences of the card values as follows

y j = x j + 1 − x j ( j = 1 , ⋯ , n − 1 ) (22)

and assign 1 to a positive difference ( y j > 0 ) and 0 to a negative difference ( y j < 0 ) . Since there is no repeating integer in the set { x i } , the value y j = 0 cannot occur. Thus, a sequence of 52 card values is transformed into a sequence of 51 binary difference values.

For example, consider again the 10-card decimal sequence (16):

x = { 294745326344436385 } . (23)

The resulting binary difference series is then

y diff = { 100011010 } (24)

which comprises the following set of up/down runs

2runsof1oflength1 2runsof0oflength1 1runof1oflength2 1runof0oflength3 (25)

for a total of 6 up/down runs.

Comparison of binary sequences (24), (17) and corresponding runs tabulations (25), (18) illustrates how the same decimal sequence (16) can lead to completely different outcomes of up/down and target runs tests. Thus, the two kinds of runs procedures independently test the same decimal sequence for different symbol patterns.

A major difference between the target runs and the up/down runs is that variates in the former (e.g. series (17)) are realizations of Bernoulli random variables (i.e. the probability of occurrence is the same irrespective of location within the series), whereas the variates in the latter (e.g. series (24)) are not. For up/down runs, the greater the length of a run, the less probable is the occurrence of yet another symbol of the same kind. The expectation values of up/down runs, therefore, differ from those of target runs. Instead, the expressions corresponding to (9)-(11) are [

・ the mean number of up and down runs of length precisely k (where k ≤ n − 2 ) is

r ¯ k = 2 ( k + 3 ) ! [ n ( k 2 + 3 k + 1 ) − ( k 3 + 3 k 2 − k − 4 ) ] (26)

・ the mean number of up and down runs of length k or greater (where k ≤ n − 1 ) is

R ¯ k = 2 ( k + 2 ) ! [ n ( k + 1 ) − ( k 2 + k − 1 ) ] (27)

・ the mean total number of up and down runs is

R ¯ u/d = 1 3 ( 2 n − 1 ) → 34.33 (28)

with associated variance and standard deviation

σ u/d 2 = 1 90 ( 16 n − 29 ) σ u/d → 2.99 (29)

Evaluations in Equation (28) and Equation (29) pertain to n = 52 . The statistic

z u/d = R − R ¯ u/d σ u/d → N ( 0 , 1 ) (30)

is again approximately normally distributed.

The total numbers of target runs and up/down runs were calculated as a function of shuffle number for each of the N sets of M shuffles, such as exemplified by

statistic | z | ≤ 1 . Also, for shuffle numbers below threshold, decks shuffled by hand (blue curves) manifested greater disorder than decks mixed by the auto shuffler (red curves).

The Spearman rank correlation coefficient r S is a nonparametric measure of the association between two random variables X and Y as defined by their rank order in a sequence of n pairs [

r S = 1 − 6 ∑ i = 1 n D i 2 n ( n 2 − 1 ) (31)

in which

D i = r ( x i ) − r ( y i ) (32)

is the difference between the ranks assigned to samples x i and y i (When a distinction is necessary, lower case letters (e.g. x) represent realizations of the abstract random variable which is usually expressed by an upper case letter (e.g. X)).

Values of r S range from −1 to +1, respectively signifying perfect anti-correlation (i.e. reverse rankings) and perfect correlation. It is r S 2 , however, rather than r S , that has a statistical interpretation; r S 2 is a measure of the variability of the data attributable to the correlation between variables X and Y [

For independent variables (and therefore uncorrelated ranks), the expectation value and variance are respectively

〈 r S 〉 = 0 (33)

σ r S 2 = 1 n − 1 , (34)

and the test statistic

z rank = r S − 〈 r S 〉 σ r S = r S n − 1 → N ( 0 , 1 ) (35)

follows a standard normal distribution to good approximation [

Applied to the shuffling of cards, the variable Y signifies the initial card sequence { y i } m = 0 = { 1 , 2 , ⋯ , 52 } and variable X signifies the card sequence { x i } m = { x 1 , ⋯ , x n } of the m^{th} shuffle. Since the face values of the cards range from 1 to 52, the rank of a card is equal to its face value. Therefore an equivalent, but simpler, way to perform the rank correlation test is to calculate the cross correlation of ranks

C rank ≡ ∑ j = 1 n r ( x j ) r ( y j ) = ∑ j = 1 n j r ( x j ) (36)

where the second equality in (36) pertains specifically to the sequence of cards in a deck of n cards. The expectation value and variance of C rank are respectively

〈 C rank 〉 = 1 4 n ( n + 1 ) 2 → 36517 (37)

σ rank 2 = 1 444 ( n − 1 ) n 2 ( n + 1 ) 2 σ rank → 1640.15 (38)

with numerical evaluations for n = 52 . The test statistic

z rank = C rank − 〈 C rank 〉 σ rank (39)

can be shown to be identical to that of Equation (35) [

^{th} shuffle and the initial card sequence (m = 0) is interpreted as statistically 0 (i.e. for | z rank | ≤ 1 ) starting at about m = 6 or 7.

Serial correlation refers to the relationship between elements of the same series separated by a fixed interval. Given a sequence of elements { x j } for j = 1 , 2 , ⋯ , n , the serial correlation coefficient lag-k is defined by [

ρ k = ∑ j = 1 n x j x j + k − 1 n ( ∑ j = 1 n x j ) 2 ∑ j = 1 n x j 2 − 1 n ( ∑ j = 1 n x j ) 2 (40)

where x j + k is to be replaced by x j + k − n for all values of j such that j + k > n .

For the purpose of testing correlations in card order following shuffling, the most useful serial coefficient is ρ 1 , which measures the correlations between pairs of consecutive cards. It can be shown, however, that a test based upon the simpler statistic [

c 1 = ∑ j = 1 n x j x j + 1 (41)

is equivalent to a test based on ρ 1 . The mean and variance of c 1 are given by the following expressions [

〈 c 1 〉 = S 1 2 − S 2 n − 1 (42)

σ c 1 2 = S 2 2 − S 4 n − 1 + S 1 4 − 4 S 1 2 S 2 + 4 S 1 S 3 + S 2 2 − 2 S 4 ( n − 1 ) ( n − 2 ) (43)

where

S k = ∑ j = 1 n x j k . (44)

For large n, the statistic

z serial = c 1 − 〈 c 1 〉 σ c 1 (45)

follows a standard normal distribution to good approximation.

^{th} shuffle and the initial card sequence (m = 0) is interpreted as statistically 0 (i.e. for | z serial | ≤ 1 ) starting at about m = 8 (manual) and m = 16 (auto).

A rising sequence, as defined in [

{ x i } = { 1 2 3 4 5 6 7 8 } (46)

one sees that the hand consists of two rising sequences (1,2,3,4,5) and (6,7,8) interleaved together. Successive riffle shuffles tend to double the number of rising sequences up to a maximum number of 1 2 ( n + 1 ) in the limit of an infinite number of shuffles. Note that a rising sequence is different from an ascending sequence (i.e. a run up): 1) The elements of a run up merely ascend, but do not have to increment successively; 2) The elements of a rising sequence do not have to be contiguous (as in a run), but can be separated by other elements.

It is shown in [

riffle shuffle depends only on the deck size n and the number r of rising sequences in the permutation. Specifically, the probability that the m^{th} riffle shuffle of an ordered deck has r rising sequences is

Q n , m ( r ) = 1 2 m n C n 2 + n − r . (47)

The mean number of rising sequences in the permutation following m shuffles is then given by

〈 r n , m 〉 = ∑ r = 1 n r E n ( r ) Q n , m ( r ) (48)

where the Eulerian number [

E n ( r ) = ∑ n = 1 r + 1 ( − 1 ) r − j j n C r − j n + 1 (49)

is the number of permutations containing r rising sequences. Substitution of Equation (49) into Equation (48) leads to the simpler expression [

〈 r n , m 〉 = 2 m − n + 1 2 m n ∑ r = 1 2 m − 1 r n . (50)

The sum of powers of an uninterrupted sequence of positive integers, such as contained in expression (50), is given by Faulhaber’s formula [

∑ r = 1 R r n = R n + 1 n + 1 + 1 2 R n + ∑ k = 2 n B k k ! n ! ( n − k + 1 ) ! R n − k + 1 (51)

in which B_{k} is a Bernoulli number, defined by the generating function [

t e t − 1 = t 2 ( coth ( t / 2 ) − 1 ) = ∑ k = 0 ∞ B k t k k ! (52)

and given explicitly by

B 0 = 1 B 1 = − 1 2 B k = { 0 k = 3 , 5 , 7 , ⋯ − ( − 1 ) k / 2 ( 2 π ) − k 2 k ! ζ ( k ) k = 2 , 4 , 6 , ⋯ (53)

where the Riemann zeta function is defined by (Ref. [

ζ ( p ) = ∑ k = 1 ∞ k − p . (54)

In the limit R → ∞ , the sum in the right side of Equation (51) becomes negligible, and therefore

lim R → ∞ ∑ r = 1 R r n → R n + 1 n + 1 − 1 2 R n . (55)

Substitution of relation (55) into (50) with R = 2 m leads to the asymptotic number of rising sequences after an infinite number of riffle shuffles

lim m → ∞ 〈 r n , m 〉 = r n , ∞ = 1 2 ( n + 1 ) → 26.5 (56)

as stated without proof at the start of this section. The numerical evaluation pertains to a deck with n = 52.

The mean-square number of rising sequences for m shuffles can be calculated numerically from Equation (47) and Equation (49)

〈 r n , m 2 〉 = ∑ r = 1 n r 2 E n ( r ) Q n , m ( r ) (57)

from which follows, also numerically, the theoretical (i.e. population) variance

σ n , m 2 = 〈 r n , m 2 〉 − 〈 r n , m 〉 2 . (58)

The author was unable to determine an analytical closed-form expression for (57) or (58).

Shuffle Number m | Mean 〈 r 52 , m 〉 | Mean Square 〈 r 52 , m 2 〉 | Standard Deviation σ 52 , m |
---|---|---|---|

0 | 1 | 1 | 0 |

1 | 2 | 4 | 0 |

2 | 4 | 15.9999 | 0.0041 |

3 | 7.9489 | 63.2337 | 0.2224 |

4 | 14.0994 | 199.9632 | 1.0814 |

5 | 19.6053 | 387.4865 | 1.7657 |

6 | 22.9482 | 530.6637 | 2.0110 |

7 | 24.7104 | 614.9224 | 2.0785 |

8 | 25.6034 | 659.9288 | 2.0958 |

9 | 26.0515 | 683.0915 | 2.1001 |

10 | 26.2757 | 694.8289 | 2.1012 |

11 | 26.3879 | 700.7354 | 2.1015 |

12 | 26.4439 | 703.6980 | 2.1016 |

13 | 26.4720 | 705.1815 | 2.1016 |

14 | 26.4860 | 705.9239 | 2.1016 |

15 | 26.4930 | 706.2952 | 2.1016 |

16 | 26.4965 | 706.4809 | 2.1016 |

17 | 26.4982 | 706.5738 | 2.1016 |

18 | 26.4991 | 706.6202 | 2.1016 |

19 | 26.4996 | 706.6435 | 2.1016 |

20 | 26.4998 | 706.6550 | 2.1016 |

〈 r n , m 〉 is compared with the observed numbers obtained by manually and auto shuffled cards averaged over the N data sets. Several features are to be noted:

・ In contrast to the statistical behavior graphically displayed in preceding figures which showed gradual randomization with increasing shuffle number m, the mean number of rising sequences underwent a relatively abrupt transition from a non-random state to the asymptotically random state at a threshold shuffle number m = 7 or 8 for manual shuffles and m = 11 or 12 for auto shuffles.

・ For m < 4 , the three curves (theory, manual shuffle, auto shuffle) yielded virtually identical results.

For m ≥ 5 , the rising sequences due to manual shuffling were statistically coincident with theoretical predictions, whereas shuffling by machine yielded too few rising sequences at each shuffle number up to the asymptotic number m A ≈ 13 . This feature suggests one can randomize a deck better by shuffling it manually than by use of a mechanical auto shuffling device like that in

As discussed briefly in Section 1.1, the Shannon entropy of a set of n symbols is given by

H = − ∑ j = 1 n ! p j log 2 p j (59)

where p j ( j = 1 , ⋯ , n ! ) is the probability of the j^{th} permutation of the n ! total number of ways to permute the symbols. By completeness, the set of probabilities { p j } satisfies Equation (4). Multiplied by a universal physical constant (Boltzmann’s constant k B ), the Shannon entropy, usually expressed in terms of natural logarithms, provides the basis for deriving the partition function―and therefore all the thermodynamic potentials―of equilibrium statistical mechanics [

Although Equation (59) yields the entropy of a sequence of n distinct uncorrelated symbols, it does not predict the entropy correctly when the permutations are constrained by rules that create correlations among the symbols. To chart the increasing disorder in a system of n cards as a function of the number m of riffle shuffles one can calculate the entropy of all configurations of a fixed number r of rising sequences and then sum that entropy over the total number of rising sequences produced in the shuffle. In this case, the relevant probability function is

p n , m ( r ) = E n ( r ) Q n , m ( r ) (60)

with expressions for E n ( r ) and Q n , m ( r ) given respectively by Equation (49) and Equation (47). This procedure leads to a much lower maximum entropy than Equation (59) because it respects the constraints imposed on possible orderings by the physical mechanism of the riffle shuffle. It has been shown that the possible outcomes to m riffle shuffles of an ordered deck are equivalent to the outcomes of cutting a deck into 2 m packets and interleaving the cards from different packets in such a way that the cards from each packet maintain their relative order among themselves [

starts at about m = 10 (blue curve), the distribution over r is a nearly perfect Gaussian function, shown by the dashed red curve in

The entropy of a deck of n cards as a function of shuffle number m, calculated from the probability distribution (60), takes the form

H n , m = − ∑ r = 0 n p n , m ( r ) log 2 p n , m ( r ) (61)

and is plotted in ^{th} shuffle.

Equation (61) yields the total entropy of a card deck subject to m riffle shuffles. However, it does not provide information on the randomization of specific card associations, which is the kind of information that serious players might rely on for advantage in competition or gambling. For this purpose, the conditional entropy of pairs of ordered sequences was determined experimentally.

Let X and Y be two discrete random variables spanning the same range of n sequential integers ( i = 1 , 2 , ⋯ , n ) with joint probability function p X Y ( x , y ) and marginal probability functions

p X ( x ) = ∑ y = 1 n p X Y ( x , y ) p Y ( y ) = ∑ x = 1 n p X Y ( x , y ) (62)

each satisfying the completeness relation. The entropy (mean uncertainty) in receipt of n transmitted symbols { x i } or { y i } is

H ( X ) = − ∑ x = 1 n p X ( x ) log 2 p X ( x ) H ( Y ) = − ∑ y = 1 n p Y ( y ) log 2 p Y ( y ) (63)

The conditional entropy of the sequence { x i } , given that the sequence { y i } is known, is defined by [

H ( X | Y ) = − ∑ x = 1 n p X | Y ( x | y ) log 2 p X | Y ( x | y ) p Y ( y ) , (64)

where the condition probability p X | Y ( x | y ) is

p X | Y ( x | y ) = p X Y ( x , y ) / p Y ( y ) . (65)

(See also Ref. [

H ( X , Y ) = H ( X ) + H ( Y | X ) = H ( Y ) + H ( X | Y ) . (66)

Equation (66) states that the entropy of a joint event, e.g. X and Y, is the entropy of the former plus the conditional entropy of the latter when the former is known. One may also define the quantity

H [ X Y ] ≡ H ( X ) − H ( X | Y ) (67)

which is the decrease in entropy of the events X when it is known that events Y have occurred. Given the preceding interpretation, the function expressed by Equation (67) is taken to represent the information provided by knowledge of the events Y [

In the analysis of permuted card sequences in the following two sections, the information function H [ X Y ] is one of the important quantities to be deduced experimentally. Substitution into Equation (67) of the conditional probability H ( X | Y ) from Equation (66) leads to the symmetric relation

H [ X Y ] = H ( X ) + H ( Y ) − H ( X Y ) (68)

which is particularly useful for calculation.

To apply the preceding concepts to riffle shuffles, the experimental sequences of digital card values are transformed into two sets of binary values by the following procedure, schematically shown in

・ Given a decimal sequence of card values { x i } for i = 1 , 2 , ⋯ , n , create the binary sequence { b j } for j = 1 , 2 , ⋯ , n − 1 defined by

b j = { 1 if x j + 1 − x j = 1 0 otherwise (69)

・ Transform the set { b j } into the set { c k } k = 1 , 2 , ⋯ , n − 2 , where

c k = b k + 1 − 1 2 b k . (70)

Transformation (69) generates a binary sequence of 1’s and 0’s, in which the symbol 1 signifies a pair of cards in numerical order (e.g. 4,5). Transformation

(70) converts the binary sequence into a sequence of four values 1, 0, and ± 1 2 .

Panel A: c = + 1 2 signifies that a 1 follows a 1.

Panel B: c = − 1 2 signifies that a 0 follows a 1.

Panel C: c = 1 signifies that a 1 follows a 0.

Panel D: c = 0 signifies that a 0 follows a 0.

Given the set { c k } , the following four pair-association statistics

n ( 0 , 0 ) = ∑ k = 1 n − 2 I 0 ( c k ) (71)

n ( 0 , 1 ) = ∑ k = 1 n − 2 I 1 ( c k ) (72)

n ( 1 , 0 ) = ∑ k = 1 n − 2 I − 1 2 ( c k ) (73)

n ( 1 , 1 ) = ∑ k = 1 n − 2 I 1 2 ( c k ) , (74)

in which

I α ( c k ) = { 1 c k = α 0 c k ≠ α (75)

count the number of events of the kinds represented respectively by panels A, B, C, D. To summarize, the statistic n ( α , β ) is the number of events of symbol α followed by symbol β , where both symbols can take on values of 0 or 1. The statistics n ( α , β ) satisfy the sum rule

∑ α = 0 , 1 β = 0 , 1 n ( α , β ) = n − 2 → 50 (76)

evaluated numerically above for a deck of n = 52 cards.

In this information theoretic analysis, it is useful to think of the α symbols as the realizations of a “message” variable A that represents a received signal of 1’s and 0’s, whereas the β symbols are the realizations of a following “prediction” variable B that represents a predicted signal of 1’s and 0’s. For each successive shuffle of the deck, the set of conditional probabilities p ( β | α ) determines the conditional entropy H ( B | A ) , which is the uncertainty in predicting B given knowledge of A.

It is straightforward to show that the conditional probabilities p ( β | α ) can be estimated from the pair association statistics (71)-(74) as follows

p ( 0 | 0 ) = n ( 0 , 0 ) n ( 0 , 0 ) + n ( 0 , 1 ) (77)

p ( 1 | 0 ) = n ( 0 , 1 ) n ( 0 , 0 ) + n ( 0 , 1 ) (78)

p ( 0 | 1 ) = n ( 1 , 0 ) n ( 1 , 0 ) + n ( 1 , 1 ) (79)

p ( 1 | 1 ) = n ( 1 , 1 ) n ( 1 , 0 ) + n ( 1 , 1 ) (80)

in the limit of a sufficiently large number of sets of shuffles. Note that the order of symbols in the argument of p ( β | α ) signifies that event α precedes event β , which is the reverse of the order of symbols in the argument of n ( α , β ) . Regrettably, this potential for confusion is the price required to maintain conventional statistical notation.

The a priori probabilities p A ( α ) of a received symbol α are given by

p A ( α ) = 1 n − 2 ∑ β = 0 , 1 n ( α , β ) , (81)

or explicitly

p A ( 0 ) = n ( 0 , 0 ) + n ( 0 , 1 ) n − 2 , p A ( 1 ) = n ( 1 , 0 ) + n ( 1 , 1 ) n − 2 . (82)

Similarly, the a priori probabilities p B ( β ) of a predicted symbol β are

p B ( β ) = 1 n − 2 ∑ α = 0 , 1 n ( α , β ) , (83)

or explicitly

p B ( 0 ) = n ( 0 , 0 ) + n ( 1 , 0 ) n − 2 , p B ( 1 ) = n ( 0 , 1 ) + n ( 1 , 1 ) n − 2 . (84)

The joint probability p A B ( α , β ) of a received symbol α and predicted symbol β is given by

p A B ( α , β ) = p A ( α ) p ( β | α ) = n ( α , β ) n − 2 (85)

where the second equality follows from combining relations (82) and (77)-(80).

Given the probability functions constructed above, the a priori entropies of the received (A) and predicted (B) signals are

H ( A ) = − ∑ α = 0 , 1 p A ( α ) log 2 p A ( α ) (86)

H ( B ) = − ∑ β = 0 , 1 p B ( β ) log 2 p B ( β ) (87)

and the total entropy of A and B is

H ( A B ) = − ∑ α = 1 , 0 β = 1 , 0 p A B ( α , β ) log 2 p A B ( α , β ) . (88)

The information, or decrease in uncertainty of values of B as a result of knowing values of A, is then given by Equation (68)

H [ B A ] = H ( B ) − H ( B | A ) = H ( A ) + H ( B ) − H ( A B ) . (89)

The entropy and information are in units of bits (“binary digits”). In statistical physics, where natural logarithms are usually used rather than logarithms to base 2, entropy and information are in units of nats.

An experiment was performed in which an initially ordered deck of n = 52 cards was subject to N = 11 sets of M = 19 riffle shuffles per set implemented by the auto shuffler in

For a completely ordered deck prior to shuffling (m = 0), there are n − 2 = 50 occurrences of α = 1 followed by β = 1 , as shown by the plot of n ( 1 , 1 ) (red curve) in

Shuffle Number m | n ( 0 , 0 ) | n ( 0 , 1 ) | n ( 1 , 0 ) | n ( 1 , 1 ) |
---|---|---|---|---|

0 | 0.00 | 0.00 | 0.00 | 50.00 |

1 | 5.82 | 12.00 | 12.27 | 19.91 |

2 | 14.27 | 11.91 | 12.36 | 11.45 |

3 | 20.91 | 10.64 | 11.09 | 7.36 |

4 | 26.64 | 10.27 | 10.27 | 2.82 |

5 | 30.27 | 8.91 | 8.91 | 1.91 |

6 | 34.00 | 7.55 | 7.27 | 1.18 |

7 | 38.36 | 5.36 | 5.36 | 0.91 |

8 | 39.18 | 5.18 | 5.27 | 0.36 |

9 | 41.00 | 4.45 | 4.36 | 0.18 |

10 | 42.91 | 3.45 | 3.45 | 0.18 |

11 | 43.55 | 3.00 | 3.09 | 0.36 |

12 | 43.64 | 3.00 | 3.00 | 0.36 |

13 | 43.82 | 3.00 | 3.00 | 0.18 |

14 | 44.00 | 2.91 | 2.91 | 0.18 |

15 | 46.00 | 2.00 | 2.00 | 0.00 |

16 | 46.91 | 1.55 | 1.55 | 0.00 |

17 | 46.55 | 1.73 | 1.73 | 0.00 |

18 | 47.64 | 1.18 | 1.18 | 0.00 |

19 | 46.73 | 1.64 | 1.64 | 0.00 |

followed by β = 0 rises rapidly with increasing m, approaching ≈48, as shown by the plot of n ( 0 , 0 ) (blue curve). The plots of n ( 0 , 1 ) (green curve) and n ( 1 , 0 ) (orange curve), which start at 0 and then fall off gradually from a maximum of about 12 at m = 1, are virtually indistinguishable.

The conditional probabilities p ( β | α ) , deduced from the pair-association statistics by means of Equations (77)-(80), are plotted as a function of m in

∑ β = 0 , 1 p ( β | α ) = 1 (90)

for α = 0 , 1 .

The plots in panel A, which show the conditional probabilities of prediction variable β given received variable α = 0 , begin at m = 1 because there is no event 0 in a completely ordered deck (m = 0). As the shuffle number m increases, the number of ordered pairs decreases, and p ( 0 | 0 ) approaches 1 while p ( 1 | 0 ) approaches 0. In panel B, the probabilities are conditioned on a received variable 1. As the number of 0 events increase with m, it follows again that p ( 0 | 1 ) approaches 1 and p ( 1 | 1 ) approaches 0. For a gambler or competitive player, the probability p ( 1 | 1 ) is particularly useful, since it quantifies the chance of a third card in order (e.g. 1,2,3), given prior receipt of two cards in order (e.g. 1,2). Empirically, this conditional probability is seen to be about 20% at the 5^{th} shuffle.

The entropy H ( B ) of the prediction variable and information H ( B ) − H ( B | A ) are summarized in

Since the randomness of a deck of cards is ordinarily expected to increase with the number of shuffles, as shown explicitly in

Shuffle Number m | Entropy H(B) | Conditional Entropy H(B|A) | Information H(B) − H(B|A) | Information Std Dev |
---|---|---|---|---|

1 | 0.9386 | 0.9382 | 0.0004 | 0.0494 |

2 | 0.9892 | 0.9883 | 0.0010 | 0.0180 |

3 | 0.9353 | 0.9333 | 0.0021 | 0.0611 |

4 | 0.8242 | 0.8269 | −0.0027 | 0.0767 |

5 | 0.7463 | 0.7451 | 0.0013 | 0.1158 |

6 | 0.6521 | 0.6458 | 0.0063 | 0.1920 |

7 | 0.5323 | 0.5326 | −0.0003 | 0.1770 |

8 | 0.4953 | 0.4977 | −0.0024 | 0.1381 |

9 | 0.4370 | 0.4340 | 0.0029 | 0.1516 |

10 | 0.3695 | 0.3733 | −0.0038 | 0.1293 |

11 | 0.3474 | 0.3569 | −0.0096 | 0.1421 |

12 | 0.3474 | 0.3569 | −0.0096 | 0.1421 |

13 | 0.3334 | 0.3417 | −0.0083 | 0.1386 |

14 | 0.3290 | 0.3292 | −0.0001 | 0.1165 |

15 | 0.1385 | 0.1290 | 0.0094 | 0.1905 |

16 | 0.1201 | 0.1182 | 0.0019 | 0.1781 |

17 | 0.2119 | 0.2092 | 0.0028 | 0.1002 |

18 | 0.0623 | 0.0551 | 0.0072 | 0.1701 |

19 | 0.0702 | 0.0545 | 0.0156 | 0.2276 |

pair not occurring). Consequently, pair association variables B and A are so defined that their outcomes become more certain and their entropies (i.e. uncertainties) decrease as the deck becomes increasingly randomized.

To put into perspective the empirical results of this information theoretical analysis, it is to be recalled that 1 bit of information, as initially construed by Shannon who largely created the subject of information or communication theory [

1) Information, as ordinarily defined by scientists, is associated with uncertainty, i.e. entropy H. Thus, the decrease in entropy H ( B ) for about the first 10 shuffles, as seen in

2) Information can also be construed as a measure of the reduction in uncertainty in one variable (e.g. B) as a result of knowledge of another variable (e.g. A). From this perspective,

In this paper the sequential permutations of an initially ordered deck of cards mixed by riffle shuffles executed manually or mechanically were tested for different statistical measures of random patterns, including 1) runs, 2) rank ordering, 3) pair correlations, 4) rising sequences, and 5) entropy and information loss. The various statistical measures probed different aspects of the symbol patterns within each permuted sequence. Consequently, different measures could result in different threshold shuffle numbers at which the deck could be said to have been randomized for the purposes of competitive card playing or gambling.

As seen in

Statistical Test | Hand Shuffles | Auto Shuffles |
---|---|---|

Runs (relative to mean) | 10 | 10 |

Runs (up/down) | 8 | 8 |

Rank Ordering | 6 | 6 |

Serial Correlation (lag 1) | 8 | 16 |

Rising Sequences | 8 | 12 |

Conditional Probability p(1|1) | - | 9 |

Conditional Probability p(1|0) | - | 11 |

Entropy (Information) H(B) | - | 17 |

about the 6^{th} shuffle, whereas the runs test statistic z is close to 0 at about the 8^{th} shuffle. For the statistical variable of rising sequences, the manually shuffled cards met the criterion of complete mixing at about the 8^{th} shuffle, as predicted in [^{th} shuffle for mechanically shuffled cards. Large differences in threshold values obtained from different test variables arose because the tests examined different aspects of the residual patterns embedded in the permutations of card order.

However, so as not to misinterpret (or over-interpret) these results, the reader should bear in mind that the statistical tests in themselves do not indicate that any residual pattern would actually be useful to a card player. For example, ^{th} shuffle, at which point such patterns are almost assuredly uninformative. On the other hand, the residual order remaining at the 7^{th} shuffle, indicated by the conditional probability functions plotted in

Of the various statistical measures applied to the experimentally generated card sequences, the author is aware of only one measure―mean number of rising sequences―for which a theoretical distribution function pertaining to a particular shuffle model is known. The probability function of this distribution, Equation (60), is based on the GSR model of riffle shuffling. Although there are many references in the statistical literature and on the internet to the theory of riffle shuffling (such as those cited in the References to this paper), the author knows of no previously published experimental test with actual cards, rather than simulations by computer. In this regard, the nearly exact match of the theoretically predicted and experimentally measured mean number of rising sequences shown in

J. Becker, J. Boreyko, C. Davis, J. Halverson, N. Harrison, A. Lampert, A. Mathis, O. Sanford, C. Sherman, W. Strange, and F. Sullivan participated in data collection at an early phase of this project. The author also thanks Trinity College for partial support through the research fund associated with the George A. Jarvis Chair of Physics.

The author declares no conflicts of interest regarding the publication of this paper.

Silverman, M.P. (2019) Progressive Randomization of a Deck of Playing Cards: Experimental Tests and Statistical Analysis of the Riffle Shuffle. Open Journal of Statistics, 9, 268-298. https://doi.org/10.4236/ojs.2019.92020