The Math of Card Shuffling

advertisement
Zhang 1
Sharon Zhang
Zachary Hamaker
Math 20
26 November 2011
The Math of Card Shuffling
I give you a brand new deck of cards and ask you to cut and shuffle the deck three
times. Now you are going to pick up the top card, memorize it, and insert it back anywhere
in the deck. Then you are you going to cut, shuffle, and cut the deck one more time. I will
fan out the deck and pick out your card. Ta-da! The outcome of this trick, and more broadly,
any card shuffle, depends on the way in which the cards are shuffled and the number of
times they are shuffled. Once the order of the cards in the deck become “random,” all bets
are off.
One of the most common shuffles is the riffle shuffle, in which a deck of n cards is cut
into 2 stacks and then interleaved together. The probability that the cut occurs after the kth
card is the binomial probability b(n, ½, k). All possible interleavings of the two stacks of (k)
1
and (n-k) cards are equally likely, so the probability of each interleaving is (𝑛) (Snell 120).
π‘˜
After s shuffles, there will be 2s rising sequences. For instance, the ordering (2, 4, 1, 3, 5, 7,
6, 8, 9) has 4 rising sequences: (1), (2, 3), (4, 5, 6), and (7, 8, 9). This is the result of 2s = 4 or
2 riffle shuffles.
Another way to view shuffling is called the a-shuffle, in which a deck is cut into a
stacks and then all stacks are riffled together. Some of the stacks are allowed to have 0
cards. A 2-shuffle is an ordinary riffle shuffle. “If an ordering of length n has r rising
sequences, then the number of cut-interleaving pairs under an a–shuffle of the identity
Zhang 2
ordering which lead to the ordering is (
𝑛+π‘Ž−π‘Ÿ
𝑛
) " (Snell 126). One way to visualize the a-
shuffle is thinking about its inverse, the a-unshuffle. One by one, the top card is taken from
a stack of n cards and placed with equal probability on the bottom of any of a stacks. After
all the cards are distributed, we recombine the stacks by placing stack i on top of stack i+1,
for 0 ≤ 𝑖 ≤ π‘Ž − 1. After the a-unshuffle is performed, we arrive back at with the identity
ordering (Snell 122).
Now back to our card guessing magic trick. We can now use our card shuffling
analysis tools to figure out how I was able to “guess” what your card was. The first three
riffle shuffles created 23 = 8 rising sequences. The expected number of cards in each rising
sequence is 6.5. When you took the top card of the deck and placed it back in the middle of
the deck, you created a 9th rising sequence of 1 card. The cuts made the trick a little more
complicated. If we imagine the deck of 1 to n cards as a loop, the each cut rotates the loop. A
riffle shuffle doubles the loop onto itself, creating winding sequences. A deck starts with a
winding number, or number of laps required to cycle through the deck by successive face
values, of 1, and doubles every time the deck is shuffled (Bayer and Diaconis 297). This
makes it harder to guess the correct card as the winding sequences breaks up into multiple
rising sequences. This particular trick, called “Premo” by Jordan, was found to have an 84%
success rate with 3 shuffles (Bayer and Diaconis 298). As the number of shuffles allowed
rises, the successive rate drops significantly. After 5 shuffles, the success rate is only 9%.
The problem of inaccuracy that “Premo” encounters as the number of shuffles
increases has to do with randomness. A process that produces an object from a set of
objects is considered random if each object in the set is produced with the same probability
Zhang 3
by the process (Snell 128). If each card in a deck were labeled with a 0 or 1 before each 2unshuffle for 2s-unshuffles, then the deck is considered random after all the labels become
distinct. Let T be the number of unshuffles before randomness is reached. For a deck of n
𝑠
𝑛!
cards, 𝑃(𝑇 > 𝑠) = 1 − (2𝑛 ) 2𝑠𝑛. For a deck of 52 cards, the average value of T is 11.7,
meaning 12 riffle shuffles are needed for the process to be random (Snell 126).
Variation distance is how far away a given shuffle is from being a random process.
Let X be any process that produces an ordering {1, 2, … , 𝑛} and let ٠𝑛 be the set of all
orderings {1, 2, … , 𝑛} . 𝐿𝑒𝑑 𝑓𝑋 (πœ‹) be the probability that X produces the ordering πœ‹ and
𝑒(πœ‹) = 1/|٠𝑛 |. |𝑓𝑋 (πœ‹) − 𝑒(πœ‹)| is the difference between the actual and desired
probabilities that X produces πœ‹. The variation distance between the two processes is
1
‖𝑓𝑋 − 𝑒‖ = ∑πœ‹πœ–Ω𝑛|𝑓𝑋 (πœ‹) − 𝑒(πœ‹)|
2
1
= 2 ∑π‘›π‘Ÿ=1 𝐴(𝑛, π‘Ÿ) |
𝑠
(2 +𝑛−π‘Ÿ
)
𝑛
2𝑛𝑠
1
− 𝑛!| (Snell 128). For n=52, the
variation distance of 1, 2, and 3 riffle shuffles are each calculated to be 1. For 5 shuffles it is
.9237 and for 6 shuffles, it drops to .6135. This is why the “Premo” trick stops working well
after 5 shuffles. The process is getting too close to a random process, and we can no longer
easily pick out our card from a larger number of rising sequences.
For a low number of shuffles, we can use this simple analysis of shuffling to our
advantage in card games and tricks. As the number of riffle shuffles increase, the variation
distance between the given shuffling process and a random process diminishes
significantly and becomes too close 0, giving us a deck of cards in “random” order.
Zhang 4
Bibliography
Bayer, Dave and Diaconis, Persi. “Trailing the Dovetail Shuffle to its Lair.” Annals of Applied
Probability 2.2 (1992): 294-313.
Grinstead, Charles and Laurie Snell. Introduction to Probability. Providence: American
Mathematical Society, 1997.
Download