Shuffling Cards. D.J.W. Telkamp. Utrecht University Mathematics Bachelor s Thesis. Supervised by Dr. K. Dajani

Similar documents
Permutation Enumeration

Shuffling. Shahrzad Haddadan. March 7, 2013

Roberto s Notes on Infinite Series Chapter 1: Series Section 2. Infinite series

Combinatorics. Chapter Permutations. Reading questions. Counting Problems. Counting Technique: The Product Rule

8. Combinatorial Structures

Logarithms APPENDIX IV. 265 Appendix

arxiv: v2 [math.co] 15 Oct 2018

lecture notes September 2, Sequential Choice

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 12

Ch 9 Sequences, Series, and Probability

7. Counting Measure. Definitions and Basic Properties

x y z HD(x, y) + HD(y, z) HD(x, z)

}, how many different strings of length n 1 exist? }, how many different strings of length n 2 exist that contain at least one a 1

We often find the probability of an event by counting the number of elements in a simple sample space.

THE LUCAS TRIANGLE RECOUNTED. Arthur T. Benjamin Dept. of Mathematics, Harvey Mudd College, Claremont, CA Introduction

1. How many possible ways are there to form five-letter words using only the letters A H? How many such words consist of five distinct letters?

13 Legislative Bargaining

CS3203 #5. 6/9/04 Janak J Parekh

Unit 5: Estimating with Confidence

Summary of Random Variable Concepts April 19, 2000

Mathematical Explorations of Card Tricks

arxiv:math/ v2 [math.pr] 14 Mar 2006

Counting on r-fibonacci Numbers

PERMUTATIONS AND COMBINATIONS

A generalization of Eulerian numbers via rook placements

H2 Mathematics Pure Mathematics Section A Comprehensive Checklist of Concepts and Skills by Mr Wee Wen Shih. Visit: wenshih.wordpress.

X-Bar and S-Squared Charts

x 1 + x x n n = x 1 x 2 + x x n n = x 2 x 3 + x x n n = x 3 x 5 + x x n = x n

On the Number of Permutations on n Objects with. greatest cycle length

PERMUTATION AND COMBINATION

5 Quick Steps to Social Media Marketing

COLLEGE ALGEBRA LECTURES Copyrights and Author: Kevin Pinegar

CHAPTER 5 A NEAR-LOSSLESS RUN-LENGTH CODER

Grade 6 Math Review Unit 3(Chapter 1) Answer Key

COMBINATORICS 2. Recall, in the previous lesson, we looked at Taxicabs machines, which always took the shortest path home

PERMUTATIONS AND COMBINATIONS

APPLICATION NOTE UNDERSTANDING EFFECTIVE BITS

AMC AMS AMR ACS ACR ASR MSR MCR MCS CRS

AMC AMS AMR ACS ACR ASR MSR MCR MCS CRS

A New Space-Repetition Code Based on One Bit Feedback Compared to Alamouti Space-Time Code

On Parity based Divide and Conquer Recursive Functions

sible number of wavelengths. The wave~~ngt~ ~ ~ ~ c ~ n b~dwidth is set low eno~gh to interfax One of the most im

General Model :Algorithms in the Real World. Applications. Block Codes

Intermediate Information Structures

Application of Improved Genetic Algorithm to Two-side Assembly Line Balancing

15 min/ Fall in New England

Counting III. Today we ll briefly review some facts you dervied in recitation on Friday and then turn to some applications of counting.

Chapter (6) Discrete Probability Distributions Examples

PROJECT #2 GENERIC ROBOT SIMULATOR

Final exam PS 30 December 2009

PRACTICAL FILTER DESIGN & IMPLEMENTATION LAB

POWERS OF 3RD ORDER MAGIC SQUARES

Combinatorics and probability

Table Of Contents Blues Turnarounds

BOTTLENECK BRANCH MARKING FOR NOISE CONSOLIDATION

A RULE OF THUMB FOR RIFFLE SHUFFLING

COS 126 Atomic Theory of Matter

Name Class. Date Section. Test Form A Chapter Chapter 9 Infinite Series. 1 n 1 2 n 3n 1, n 1, 2, 3, Find the fourth term of the sequence

AS Exercise A: The multiplication principle. Probability using permutations and combinations. Multiplication principle. Example.

Using Color Histograms to Recognize People in Real Time Visual Surveillance

The Institute of Chartered Accountants of Sri Lanka

3. Error Correcting Codes

AC : USING ELLIPTIC INTEGRALS AND FUNCTIONS TO STUDY LARGE-AMPLITUDE OSCILLATIONS OF A PENDULUM

Procedia - Social and Behavioral Sciences 128 ( 2014 ) EPC-TKS 2013

CS 201: Adversary arguments. This handout presents two lower bounds for selection problems using adversary arguments ëknu73,

Single Bit DACs in a Nutshell. Part I DAC Basics

Math 140 Introductory Statistics

Data Mining the Online Encyclopedia of Integer Sequences for New Identities Hieu Nguyen

VIII. Shell-Voicings

Efficient Feedback-Based Scheduling Policies for Chunked Network Codes over Networks with Loss and Delay

A SELECTIVE POINTER FORWARDING STRATEGY FOR LOCATION TRACKING IN PERSONAL COMMUNICATION SYSTEMS

2. There are n letter and n addressed envelopes. The probability that all the letters are not kept in the right envelope, is. (c)

A New Design of Log-Periodic Dipole Array (LPDA) Antenna

Technical Explanation for Counters

Dividing Connected Chores Fairly

Lecture 4: Frequency Reuse Concepts

EMCdownload. Acknowledgements. Fair use

CHAPTER 8 JOINT PAPR REDUCTION AND ICI CANCELLATION IN OFDM SYSTEMS

Design of FPGA- Based SPWM Single Phase Full-Bridge Inverter

A study on the efficient compression algorithm of the voice/data integrated multiplexer

Circular waveguides. Introduction. Table of Contents

Fingerprint Classification Based on Directional Image Constructed Using Wavelet Transform Domains

Objectives. Some Basic Terms. Analog and Digital Signals. Analog-to-digital conversion. Parameters of ADC process: Related terms

Zonerich AB-T88. MINI Thermal Printer COMMAND SPECIFICATION. Zonerich Computer Equipments Co.,Ltd MANUAL REVISION EN 1.

BOUNDS FOR OUT DEGREE EQUITABLE DOMINATION NUMBERS IN GRAPHS

Estimation of non Distortion Audio Signal Compression

SIDELOBE SUPPRESSION IN OFDM SYSTEMS

Laboratory Exercise 3: Dynamic System Response Laboratory Handout AME 250: Fundamentals of Measurements and Data Analysis

HOW BAD RECEIVER COORDINATES CAN AFFECT GPS TIMING

A study on traffic accident measures in municipal roads by using GIS

The Detection of Abrupt Changes in Fatigue Data by Using Cumulative Sum (CUSUM) Method

Compression Programs. Compression Outline. Multimedia. Lossless vs. Lossy. Encoding/Decoding. Analysis of Algorithms

4. INTERSYMBOL INTERFERENCE

CCD Image Processing: Issues & Solutions

Modeling and solution for the ship stowage planning problem of coils in the steel industry

4.3 COLLEGE ALGEBRA. Logarithms. Logarithms. Logarithms 11/5/2015. Logarithmic Functions

ON THE FUNDAMENTAL RELATIONSHIP BETWEEN THE ACHIEVABLE CAPACITY AND DELAY IN MOBILE WIRELESS NETWORKS

Computational Algorithm for Higher Order Legendre Polynomial and Gaussian Quadrature Method

Problem of calculating time delay between pulse arrivals

You Think You ve Got Problems? Marc Brodie Associate Professor of Mathematics, WJU

Transcription:

Shufflig Cards Utrecht Uiversity Mathematics Bachelor s Thesis D.J.W. Telkamp Supervised by Dr. K. Dajai Jue 3, 207

Cotets Itroductio 2 2 Prerequisites 2 2. Problems with the variatio distace................ 5 2.2 Multiple successive shuffles..................... 5 3 Motivatio: let s perform a card trick! 6 3. The setup............................... 6 3.2 The card trick............................. 2 4 Riffle shuffle 3 4. The a-shuffle............................. 5 4.. Risig sequeces ad their use............... 7 4..2 Applyig corollary..................... 20 4.2 Riffle shuffle aalysis usig stoppig time............. 20 4.2. Stoppig time for the Riffle shuffle............. 22 5 Top-i shuffle 26 6 Overhad shuffle 30 6. Direct calculatio of variatio distace for multiple shuffles... 32 6.2 Boud for Overhad shuffle..................... 34 7 Fisher-Yates shuffle 35 8 Coclusio 36 9 Ackowledgemets 37

Itroductio Most people have played a decet amout of card games i their lives. May shufflig methods have bee show to those occassioal card players at some poit (or the reader ay have bee depeded o other people to shuffle the cards). Certai shuffles of a deck of cards might have always seemed better tha others. Is this truly the case? Ad what makes a shuffle better tha aother shuffle? What is the fastest way to mix up a deck of cards while preparig a card game? These seem to be atural questios, which most people do ot worry about. However, It might make a game of cards (very) ufair. To aswer all these questios, I will dive ito the world of card decks, shuffles ad radomess. For this, a profoud aalysis of the mathematics behid these metoied aspects is eeded. This will all be preseted by brighteig examples, sometimes with umerical help. 2 Prerequisites I order to establish sufficiet shufflig techiques, we eed to look ito the mathematical tools eeded for shufflig cards. A ormal deck of cards cotais 52 cards: 3 cards i 4 differet kids. But for a aalysis of shufflig, we ca also work with a deck of cards. From ow o, label the cards i order to, accordig to the order i which you fid them. With [23], I mea the order of the cards i which oe fids them (from left to right or from top to bottom). If > 0, umbers will be separated like this: [()(2)(3)(4)...]. Example. Suppose we have all the cards of hearts from a regular deck, that is (i order): A, 2, 3, 4, 5, 6, 7, 8, 9, 0, J, Q, K. We will umber the umbered cards as they are ad further: J, Q 2 K 3 ad A. So the origial deck is: [()(2)(3)(4)(5)(6)(7)(8)(9)(0)()(2)(3)]. Suppose we mix up the cards ad get the ew order: 5, 9, 2, A, J, 3, 7, Q, 4, 6, 8, K, 0. This correspods to the deck orderig: [(5)(9)(2)()()(3)(7)(2)(4)(6)(8)(3)(0)]. We ca also show this as a permutatio (from the origial deck): ( ) 2 3 4 5 6 7 8 9 0 2 3 5 9 2 3 7 2 4 6 8 3 0 Here, the permutatio idicates that the card o place was o place 5 before the reorderig of the cards. I the example, I spoke of mix up the cards. I will ow make more precise what I mea by this, through the otio of a shuffle. 2

Defiitio. Suppose we have a deck of cards. A shuffle is a probability desity o S. Without usig a aspect of radomess, shufflig cards would of course ot be so fair (read: iterestig). shuffles will be represeted by permutatios. With the permutatio e, I mea the idetity. The permutatio (234) meas sedig to 2, 2 to 3, 3 to 4 ad 4 to. So: ( ) 2 3 4 = (234) 2 3 4 I give a example of a shuffle. Example 2. Suppose we have a deck of 4 cards. We umber the cards accordigly, i order: [234]. Defie Q : S 4 [0, ] as: 2 if π = (234) Q(π) 2 if π = e 0 else So i this example, there are two optios. The first optio is gettig the origial deck back. The secod optio is gettig the deck [234]. Both optios appear with probability 2. What do we wat of a shufflig techique? Well preferably to be radom or at least as radom as possible. That meas we wat it to be as close as possible to the uiform desity U o S. Where U(π) =! for all permutatios π. To determie what we mea by closeess, we eed to defie a metric o the probability space (of shuffles). There are may optios, but i this thesis oe will be used. Defiitio 2. Suppose we have two probability desities Q ad Q 2 o S. The variatio distace, deoted. is defied as follows: Q Q 2 = 2 π S Q (π) Q 2 (π) Here the factor 2 is to scale the variatio distace betwee 0 ad. A equivalet defiitio is., which ca be calculated accordigly: Q Q 2 = max S S Q (π) Q 2 (π) π S π S 3

We see that the variatio distace betwee two probability desities varies from 0 to. To see this, defie A = {π S Q (π) Q 2 (π)}. The: 2 Q Q 2 = π A Q (π) Q 2 (π)+ π A Q 2 (π) Q (π) π A Q (π)+ π A Q 2 (π) 2 If Q Q 2 = 0, the the probability desities are the same. If Q Q 2 =, the they are othig alike. Notice that ot shufflig at all (permutatio e with probability ) has the followig variatio distace from U o S : 2(! + (! )! 0 ) =! We see that ot doig aythig quickly becomes less radom, if is big. Furthermore, the two variatio distaces are i fact the same, as we will ow see. The proof of this lemma is ispired by []. Lemma. The variatio distaces. ad. are ideed the same. Proof. Suppose that Q, R are probability desities o S. We eed to verify that Q R = Q R. First, set A = {π Q(π) R(π)}. Take S S, the defie: Q(S) = π S Q(π). So: Q(S) R(S) = Q(S A) R(S A)+Q(S A) R(S A) Q(S A) R(S A) The iequality is achieved sice the if π S A, the Q(π) R(π) 0, sice π A. Moreover, if π S A, the π A. So Q(π ) R(π ) 0. Together with the previous iequality, this results i: Q(S) R(S) Q(S A) R(S A) Q(A) R(A) I a similar way we also achieve R(S) Q(S) R(A) Q(A): R(S) Q(S) = R(S A) Q(S A)+R(S A) Q(S A) R(S A) Q(S A) Hece: R(S) Q(S) R(S A) Q(S A) R(A) Q(A) Note ow that Q(A) R(A) = R(A) Q(A), sice: 0 = Q(S ) R(S ) = Q(A) R(A) R(A) + Q(A) Because S was arbitrary, we ca coclude: Q R = max S S Q(S) R(S) Q(A) R(A) Ad so: Q R 2 ( ) Q(A) R(A) + R(A) Q(A) = Q R 4

So we proved that Q R Q R. For the other way aroud, otice that (sice A S ): Q R = 2 ( ) Q(A) R(A) + R(A) Q(A) = Q(A) R(A) = Q(A) R(A) max S S Q(S) R(S) = Q R So Q R Q R ad we coclude: Q R = Q R. 2. Problems with the variatio distace The variatio distace seems fie, but as Ma i [3] already poits out: it has a slight problem. Suppose we have a deck of cards, which is radomly shuffled. So, we apply the aforemetioed probability fuctio U. Suppose ow that the top card accidetally falls off ad is show to you. You place the card back, but i the top half of the deck. By doig this, you get a ew distributio V. The variatio distace betwee U ad V is 2, sice half of the permutatios have probability 2! ad the other half 0. This is because you put the card i the top half, so every permutatio where the top card is i the bottom half of the deck, is ot possible. For the other permutatios, it is obvious that they have equal probability of appearig. It was a uiform shuffle ad the card is uiformly put i the top half of the deck. So for every permutatio π, we establish that U(π) differs 2(!) from V (π). Hece U V = 2. If is very large, kowig just oe card does ot really matter for radomess, but the spread betwee U ad V is still 2. O the other had, simulatios tur out that the variatio distace fuctio (which is also the maximal variatio distace possible) ca be too forgivig i certai games. Doyle created such game which is as ufair as possible for the Riffle shuffle, as explaied i [3]. However, the variatio distace appears to be the most useful method of establishig whether probability desities are close together. Ad, more importatly, it is a great tool to come to a coclusio whether or ot a shuffle is radom eough. 2.2 Multiple successive shuffles It is of course practically ot possible to perform a uiform shuffle U to mix up the deck (or is it? See sectio 7). It is therefore that we explore practically useful shuffles ad try to miimize the variatio distace. For shuffles, we eed to dive ito multiple shuffles followig each other. We will deote this by Q (k) = Q Q Q (k-times). This is easily exteded from what we already kow: Q (k) (π) = Q(π ) Q(π k ) π π k =π 5

It is apparet that we sum over all combiatios (π,..., π k ) such that: π π k = π. I give a example, usig the example used earlier (example 2). Example 3. Suppose we seek Q (3). For this, let us first determie Q (2) : 4 if π = (3)(24) Q (2) 2 if π = (234) (π) 4 if π = e 0 else From this we ca derive Q (3) : 8 if π = (432) 3 8 if π = (234) Q (3) (π) 3 8 if π = (3)(24) 8 if π = e 0 else Note that, for example, to get the permutatio x = (234), we have the followig possibilities: x e e, e x e ad e e x, all with probability 8. These calculatios seem a bit gruesome ad ideed they tur out to be. Luckily there are other optios for some atural shuffles, as we will fid out later (see for example sectio 4). 3 Motivatio: let s perform a card trick! Before cotiuig with a aalysis of certai shufflig methods, let me first stop for a momet to appreciate what we are doig. Why is it so importat to ispect shufflig methods used i practice? Well, some shuffles are easy to spot as bad. Every shuffle without a elemet of ucertaity is obviously ot good i games whe cards of oppoets should remai hidde. However, some shuffles which o the eye seem to be good, are ot so good after all. Certai shuffles are ice for magicias to use i card tricks, for example because they appear to be more radom tha they are. I will dedicate this sectio to the aalysis of the Gilbreath shuffle. This shuffle has a lot of possible permutatios of the deck i his arseal, but is ot as radom as it seems. 3. The setup First of all, we eed to defie the Gilbreath shuffle. 6

Defiitio 3. Say we have a deck of cards as usual: [()(2)... ]. Pick ay umber j {0,,..., }. It does ot really matter for the aalysis i this sectio, but let s say that: ( k) P(j = k) = 2 This seems as a fair choice (biomial distributio), but as said: it does ot really matter for this sectio. Now distribute the first j cards oe-by-oe ito a ew pile. This reverses the order i this ew pile. We ow have two piles (i order): [(j + )(j + 2)... ()] ad [(j)(j )... ()]. After this, riffle the cards together. Now: form a ew deck usig the two piles, where the relative order of the cards iside the piles should ot be chaged. Choose uiformly betwee the ways of rifflig the piles together. There are ( j) ways to do this. The ow obtaied deck has bee Gilbreath shuffled. This shuffle has a lot of commo with the Riffle shuffle (see sectio 4). It has some ice properties, but let me give a example first. Example 4. Suppose = 4. I will hadle all optios for the Gilbreath shuffle. j pile pile 2 possible decks permutatio 0 [234] [234] e [234] [] [234],[234],[234],[234] e,(2),(32),(432) 2 [34] [2] [234],[234],[234], [342],[324],[324] (2),(32),(432), (423),(43),(3) 3 [4] [32] [324],[324],[342],[432] (3),(43),(423),(4)(23) 4 [432] [432] (4)(23) Notice that there is o optio i which we ca get the top 2 or bottom 2 cards such that the umbers have the same parity. What is so iterestig about this Gilbreath shuffle? Well, as we saw i the example above, there is o optio to get the top or bottom pair of the ew deck with two cards of the same parity. This results holds i geeral, as we ow witess i the form of a theorem. Theorem. Say we have a deck of cards: [()... ()]. Let π be a permutatio of the deck. The followig properties are equivalet: ) π is obtaied through a Gilbreath shuffle 7

2) For every j N, the top j cards after applyig the permutatio are distict modulo j 3) For every j N ad k N with jk, the cards o the places: {(k )j +, (k )j + 2,..., kj} after the permutatio π, are distict modulo j. This is also kow as the Ultimate Gilbreath priciple, but I left oe equivalet property out, sice it is irrelevat for the card trick (for the iterested reader, see [7]). If we take = 4, j = 2 ad k = or k = 2, the property (3) of theorem shows that modulo 2, the first ad last two card umbers after a Gilbreath shuffle should be distict. Hece they should have differet parity, which we ideed saw i example 4. For the proof of theorem, we eed some otatio which will be familiar. With π(i), the card o place i after the permutatio π is applied to the deck, is meat. So, i example 4, if k = 4, the: π() = 4, π(2) = 3, π(3) = 2 ad π(4) =. This is because the ew deck is i order: [432]. To prove theorem, we eed a lemma. To prove this lemma, a equivalet explaatio of the Gilbreath shuffle is eeded. As we saw i example 4, every possible deck/permutatio appears twice. These doubles appear exactly at cosecutive j ad j 2. More importatly, we ca calculate the umber of distict possible decks: ( ) = 2 2 k 2 = 2 k=0 Usig the argumet of Diacois i [7], we ca make exactly 2 distict Gilbreath permutatios (i.e. a permutatio obtaied by a Gilbreath shuffle). Of course, this implies a equivalet explaatio of the Gilbreath shuffle, sice there are oly 2 distict Gilbreath permutatios. For every j {,... }, pick all S = {s,..., s j } {2,..., } with S = j. Here the s i are labeled such that: s < s 2 < < s j. There are exactly ( j ) such subsets for every j, sice {2,..., } =. The place j o positio ad place j i o positio s i. The positios that are still ot filled, should be filled i icreasig order. That is, startig from j + up util. First of all, this ideed creates distict decks. Secodly, the umber of decks are: ( ) ( ) = = 2 j j j= j=0 Thirdly, every permutatio created this way is ideed a Gilbreath permutatio. This is because for certai j ad S = {s,..., s j }, this is the same as splittig the deck i the piles: [(j + )(j + 2)... ()] ad [(j)(j )... ()]. Ad after this, rifflig the packs exactly together as eeded (which is obviously possible). 8

Cocludig, because we ca ideed form 2 distict Gilbreath permutatios, we ideed have a equivalet way of defiig the Gilbreath permutatios o a deck. To illustrate this, let s go back to example 4 ad fid all distict permutatios. Example 5. Take = 4, as i example 4. We the fid: j S {2,3,4} such that S = j correspodig ew decks [234] 2 {2},{3},{4} [234],[234,[234] 3 {2,3},{3,4},{2,4} [324],[342],[324] 4 {2,3,4} [432] A little explaatio as to how to get to this table: take for example j = 3 ad S = {2, 3}. Firstly, j = 3 should be o positio i the ew deck. The j = 2 should be o positio 2 ad j 2 = should be o positio 3. Now, we ca fill i the remaiig umbered card 4 o the first empty positio, which is positio 4. This gives ideed [324]. If we look at all ewly formed decks, we see that these are exactly the 2 = 2 3 = 8 distict decks foud i example 4. After this example, it is time to prove a importat lemma to prove theorem. Lemma 2. The first j cards of a deck after a Gilbreath shuffle cosist of j cosecutive umbered cards. They eed ot be cosecutive i the deck after the shuffle, but for every j you should be able to rearrage the first j umbered cards π(),..., π(j) such that they are cosecutive. That is, there exist a j = mi i j π(i), such that: j {π(i)} = {a j, a j +,..., a j + (j )} i= Alteratively, if after a permutatio of the deck for every j {,..., } there exists such a j, the the permutatio is a Gilbreath permutatio. Proof. Suppose we have a deck of cards ad label it i its origial order, to keep thigs simple. Suppose that the first card of the ew deck after a Gilbreath permutatio is: π() = j. Because of the explaatio of the equivalet way of defiig the Gilbreath permutatios o a deck, we kow that after j, there should a cosecutive icreasig sequece. If this sequece termiates, we must 9

have j. After that, this process cotiues. However, we ca ideed always rearrage, because of the equivalet explaatio of defiig all the Gilbreath permutatios. To prove the coverse, suppose that after a permutatio π, for every j {, }, there exists a j = mi i j π(i), such that: j {π(i)} = {a j, a j +,..., a j + (j )} i= Deote the place where card i is after the permutatio as π i. Take the first card of the deck after applyig the permutatio: π(). Assume that π() = j. Create a set S {2,..., } as follows: S = {π j,..., π }. If S is ordered (π j < π j 2 < < π ), the we are doe. This is, because the rest of the cards (j +,..., ) must be filled i icreasig order, otherwise the assumptio would be violated. Suppose it is o Gilbreath permutatio. The, there exists a smallest m >, such that π(m) π(m ) + ad π(j) a m. This ecessarily meas that (m was the smallest such that it did ot hold!): {π(i)} {π(m)} = {a m, a m +,..., a m + (m )} {π(m)} m i= However, this certaily does ot fulfill our assumptio, hece completes a cotradictio. Hece, all that remais is to show that: π j < π j 2 < < π. For this: suppose ot. So, suppose there exists a biggest i, l {,..., j 2}, such that: π i < π l (of course: l > i). Firstly, if there is o smallest k > i, such that π m < π i for all m k, the the first π i cards are [j(j + )... (π i j + )] = [j(j + )... (π i j)], sice otherwise our assumptio of cosecutive π(k) s would ot hold. Obviously, if we add card i j 2 to these first cards, we get a cotradictio. Sice i j 2 < j ad we would eed to exted these first cards with a card with a value greater or equal tha j. O the other had, suppose there exists a smallest k > i, such that π m < π i, for all m k. Sice these are the smallest respectively biggest such k ad i, we kow that the first π i cards form a set: {π(w)} = {k, k +..., k + π i 2} π i w= We ca see this because k is the smallest fulfillig k, so π j < π j 2 < < π k. However, sice the first π i cards must also have cosecutive values ad i < k, we fid that: k = i +. But, this results i: π m < π i, for all m i +. So, there is o l > i, such that: π i < π l. All together, we ca coclude that π j < π j 2 < < π ad our proof is complete. 0

We ca use this lemma to prove theorem (proof based o [7], thoroughly exteded). Proof. First of all: (3) (2), sice we ca take k =. O the other had, we ca show that (2) (3) by iductio. Suppose (2) is true. From ow o, take j fixed. Take ay k 2 (k = is just property (2)) ad suppose jk. Assume that for i k, the cards π((i )j + ),..., π(ij) are distict modulo j. We kow that the first jk are distict modulo jk, from property (2). This meas that of every equivalece class modulo jk, there is exactly oe card. However, there should also be k cards of every equivalece class modulo j. Sice we assumed by iductio hypothesis that for i k, the cards π((i )j + ),..., π(ij) are distict modulo j, we have exactly oe card i every equivalece class modulo j left. Hece we coclude that the cards: {π((k )j + ), π((k )j + 2),..., π(kj)} are distict modulo j. So by iductio: (2) (3) ad the properties (2) ad (3) are equivalet. Now suppose that () holds ad fix j. Usig lemma (2), we have a a j such that the first j cards are: {a j,..., a j + (j )}. These cards are obviously distict modulo j. Hece () (2). O the other had, suppose (2) holds. We eed to prove that for every j {,..., }, the cards o positio to j i the deck are cosecutive, up to order. Proceed by iductio. If j =, the obviously the results hold. Suppose it holds for j = k. So for some a = mi i k π(i) : k {π(i)} = {a, a +,..., a + (k 2)} i= We kow that the first k cards are distict modulo k. So π(k) = a +m(j+) = a + mk, with m Z. Also: m should of course be such that π(k). Now, we exclude the case m {0, }. If m 2, the mk > k, sice k 2 ad m 2. It follows that: k < π(k) a a <, because a. So the first π(k) a cards ca ot be differet modulo π(k) a, sice: π(k) a 0 (mod π(k) a) Notice that this ca oly be doe sice k < π(k) a <. This gives a cotradictio, sice we assumed property (2). Suppose ow that m. We kow that a + (k 2) π(k) <, sice a + (k 2) ad π(k). O the other had: a + (k 2) π(k) = (k ) mk = ( m)k > k, because ( m) 2 ad k 2. So the first a+(k 2) π(k) ca ot be differet modulo a+(k 2) π(k), i the same sese as the case m 2. This ca ow oly be doe because k < a+(k 2) π(k) <.

Cocludig: m = 0 or m =. This meas that π(k) = a or π(k) = a+(k ). This meas that the iductio step is complete ad that (2) () usig lemma (2). Lookig at the theorem, it is obvious that the shuffle does ot completely radomize the origial deck, sice a lot of permutatios are ot possible. I fact, we kow that oly 2 permutatios of a deck of cards are possible. If we take = 52, the oly a fractio of 25 52! 2.8 0 53 of the permutatios of the deck is possible. Also, the variatio distace betwee the uiform shuffle U ad the Gilbreath shuffle G o a deck of cards is easy to approximate: G U = 2 G(π) U(π)! 2 2! π S Here we used that o at least! 2 permutatios, the variatio distace betwee U ad G is!. This is because G gives a probability of 0 to this amout of permutatios. Eve for = 0, this gives: G U 0.4999. This is quite a rough estimatio of the variatio distace, but eve the we see that the variatio distace is ot goig to be better tha 0.5 for 0. 3.2 The card trick A lot of card tricks have bee performed, usig this Gilbreath priciple. Say you are a magicia ad you have a stadard deck of cards. That is: the umbers to 0 ad the cards J, Q, K ad A (a total of 52 cards). These cards appear exactly oce i the followig 4 kids: Spades (S), Hearts (H), Clubs (C) ad Diamods (D). Sort your deck usig a specific order of the type of cards, for example: SHCDSHCD.... Because of the distictio betwee cards withi a specific type, the deck might appear to be radom for the o-traied eye. So you ca briefly show the deck as radom to the audiece. Next, you perform the Gilbreath shuffle. Notice: every Spades card is umbered x (mod 4), every Hearts card is umbered x 2 (mod 4), every Clubs card is umbered x 3 (mod 4) ad every Diamods card is umbered x 0 (mod 4). Now ask the audiece for a umber j, such that you ca perform the Gilbreath shuffle as explaied. After this, every ew deck satisfies property (3) from theorem. To see how this helps i a card trick: take j = 4. The the cards of the first quartet o top of the deck are distict modulo 4, the cards of the secod quartet o top of the deck (cards o positio 5, 6, 7 ad 8) are distict modulo 4, et cetera. Hece you ca start showig quartet after quartet of cards. Obviously every quartet cotais exactly oe card of each type. This works, sice there are exactly 52 cards i a regular deck ad hece exactly 3 quartets. The audiece 2

will, if they have a feelig for probability, be quite amazed. Why would they be so amazed? Well, the probability of gettig 4 differet type of cards i the first quartet i a deck of 4m cards (m cards of every type) is: 4m 3m 2m m 4m 4m 4m 2 4m 3 = 24m 4 (4m)(4m )(4m 2)(4m 3) We ca see this, because the first card does ot matter. The secod card we take from the remaiig 4m cards. Here we ca ot get the type of the first card of which there are m left. Hece (4m ) (m ) = 3m. The third card we take from the remaiig 4m 2 cards. Here we ca ot get the type of the first card ad the secod card of which there are 2(m ) left. Hece (4m 2) 2(m ) = 2m. Similarly for the last card. Notice that m = gives a probability of. So the probability of gettig oly quartets i a deck of 52 cards is easy to calculate, sice we ca just take a product: 3 m= 24m 4 ( 3 (4m)(4m )(4m 2)(4m 3) = m= 24m 4) 52! < 0.000000000 So ay perso i the audiece with a little bit of feelig for probability would see the remarkability i this trick. The trick also works for the red ad black cards i a deck of cards, which might be eve more etertaiig. What ca we lear from this? Well, ever trust a shuffle which o the eye seems radom eough. This is a proper motivatio to examie the variatio distace betwee shuffles ad what we wat: the uiform shuffle U, sice it is ot that easy o the eye to spot bad shuffles. 4 Riffle shuffle A atural way to shuffle a deck of cards, which is mathematically also very ice, is the Riffle shuffle. This goes as follows: divide the deck ito two packs of size k ad k. So k {0,,..., }, packs may be empty. Choose k accordig to the biomial distributio, with probability: p = ( k) 2. The split the deck i two packs: {, 2,..., k} ad {k +, k + 2,..., }. Now form a ew deck, rifflig the two packs together. The relative order of the two packs must be maitaied, but cards i differet packs eed ot be i their relative order from the origial deck. There are ( k) possible ways to do this ad each must have the same probability, so choose uiformly betwee those iterleavigs. The probability to pick a certai cut, followed by a certai iterleavig is (because of uiformity): p ( ) = 2 k 3

Let s look at all the possible Riffle shuffles of a deck of size 4 through a example (ispired by [3]). Example 6. Suppose = 4. We have: k packs cut probability possible iterleavigs 0 234 6 [234] 234 4 [234], [234], [234], [234] 2 2 34 3 8 [234], [342], [324], [342], [342], [324] 3 23 4 4 [234], [243], [423], [423] 4 234 6 [234] This gives the followig shufflig distributio Q : S 4 [0, ]: 5 6 if π = e 6 if π = (2) 6 if π = (32) 6 if π = (432) 6 if π = (3)(24) 6 if π = (23) Q(π) 6 if π = (243) 6 if π = (243) 6 if π = (23) 6 if π = (34) 6 if π = (234) 6 if π = (234) 0 else The variatio distace betwee radomess ad this shuffle is easily determied: Q U = ( 5 2 6 24 + 6 24 + 2 ) 24 = 3 8 This is better tha the differece betwee doig othig ad uiform shufflig U, which is 4! = 23 24. But still, multiple shuffles are eeded, especially because for example, the order [423] is ot eve possible yet. 4

To determie Q (k) for large k is, eve with such small, ot very ice. Because of this, we wat to exted our defiitio a bit to esure a easier calculatio. 4. The a-shuffle Istead of the usual Riffle shuffle R, it is also possible to divide the deck of cards i a packs (the followig explaatio of the a-shuffle is ispired by [3]). These packs have size,..., a, where i 0. So a 3-shuffle ca have oe or two packs, because i = 0 is allowed. The probability of pickig a specific distributio of packs is: ( ) p =,..., a a Note: the omiator is a multiomial coefficiet, hece the packs are chose by the multiomial distributio. After splittig the deck i a packs of size larger or equal to zero, we put the deck back together. While doig this, the relative order of cards iside a pack must be maitaied as with the Riffle shuffle. A possible deck is chose usig the uiform distributio. The probability of a specific iterleavig beig chose is therefore: (,..., a ) The reaso for this is because the relative order must be maitaied. So we ca colour all of the cards i a pack the same colour. We do ot eed to make a distictio betwee these cards, because their order has already bee established i the deck after the cut. The we determie all possible ways to divide the cards back i the deck, this is just ( ),..., a. Cocludig, just as with the Riffle shuffle R, the probability of a specific cut ad a followig iterleavig is: p (,..., a ) = a Notice that if we choose a = 2, the we ed up with the Riffle shuffle. The otatio for the a-shuffle is: R a. This meas that: R 2 = R. Let me illustrate the a-shuffle by a small example. Example 7. Suppose = 4 ad a = 3. We cut the deck with = 3 = ad 2 = 2. This occurs with probability: ( ) 4,2, 3 = 4 4 27. We have the followig packs: {}, {2, 3} ad {4}. There should be ( 4,2,) = 2 possible ways to put a deck together. Ideed we have the possible decks: [234], [243], [423], [234], [243], [234], [234], [243], [243], [423], [423], [423] This is oe possible way to obtai certai shuffles. 5

Notice that i the example there is o way i gettig 3 as first card i the deck, due to the cut. Also, the probability of gettig the origial deck back after a a-shuffle, is bigger tha ay other permutatio as we will fid usig risig sequeces. What is exactly the use for a a-shuffle? Practically, most people ted to use oly the 2-shuffle, which is the practical Riffle shuffle. Well as it turs out, sequetial Riffle shuffles are liked to a a-shuffle for certai a. Theorem 2. Suppose we have a, b N. Performig a a-shuffle followed by a b-shuffle is equivalet to performig a ab-shuffle. This turs out to be a very ice ad useful property, which is ot true for most shuffles. To prove this theorem, firstly some backgroud is eeded. We wat to defie the iverse of a a-shuffle. Defiitio 4. Defie a a-ushuffle of a deck of cards as follows. Form a umbered decks of cards (ot ecessary o-empty). Do this by takig firstly the top card of the deck ad placig it with probability a o oe of the (ow all empty) bottom of the stacks. Repeat this util the deck of cards is empty. Now place pile i o top of pile i + for all i with i a. As there is oly oe way to cut the deck i a specific piles ad there is oly oe way to iterleave the cards to get the origial deck before the ushuffle, every a- ushuffle is the uique iverse of a certai a-shuffle. We ow have the ecessary tools to complete the proof of the theorem (the proof is largely devoted to [8]). Proof. Suppose we apply a ab-ushuffle to a deck. So we form ab stacks i the explaied way. Label these stacks (i order) ot, 2,..., ab, but with elemets (x, y) of Z 2. Here x {0,..., a } ad y {0,..., b }. Label each card accordigly, with the label of the pile it is i. Now we wat to fid a b-ushuffle ad a a-ushuffle, such that applyig the ushuffles after oe aother is the same as applyig the ab-ushuffle. To fid the eeded b-ushuffle, sort the deck ito b stacks. I pile i, there should be exactly all cards where y = i. Do exactly the same after this for the eeded a-ushuffle: i pile j should be exactly all cards with x = j. Now, after the b-ushuffle followed by the a-ushuffle, the cards lie i the followig order: (0, 0), (0, ),..., (0, b ), (, 0),..., (, b ),..., (a, 0),..., (a, b ). Coclude ow that this is exactly the same as the ab-ushuffle. This completes the result, because b a has a oe-to-oe correspodece with (ab). Hece a a-shuffle followed by a b-shuffle is the same as performig a ab-shuffle. This result might ot seem useful ow to the reader, but i that case I suggest readig o. 6

4.. Risig sequeces ad their use A ice way to look at a specific deck is to fid its risig sequeces. This turs out to be a useful tool i determiig certai probabilities of a-shuffles. Defiitio 5. Suppose we have a deck i specific orderig. Say [x... x ]. A risig sequece is a subsequece A = (x ik ) k of (x i ) i such that x ik+ = x ik + for all k. Additioally there should ot exist a sequece B such that A B ad A B ad B is also risig. Hece, it should be maximal. Example 8. Cosider the followig deck orderig: [58924673]. Startig at 5, we fid 6 ad after that 7. Hece (5, 6, 7) is a risig sequece. We could have obtaied the sequece also by startig at 6 ad coutig up (spottig 7). After that returig to 6 ad coutig dow. Moreover we fid (8, 9), (2, 3), () ad (4). It appears that risig sequeces partitio the elemets (cards) i a elegat way. Ideed this is the subject of the followig theorem. Theorem 3. Give a orderig of a deck: [x... x ]. Every umbered card x i is i exactly oe risig sequece. Proof. Suppose we have such orderig of a deck: [x... x ]. First of all, we ca costruct a risig sequece with a give x i. This is straightforward by first goig to the right i the deck ad coutig up (lookig for x j such that x j = x i + ). Cotiue, repeatig this process util we come at x. After that go back to x i ad start coutig dow (lookig for x k such that x k = x i ). Also cotiue ad repeat util we stop at x. This certaily gives a risig sequece (obviously maximal). Suppose A = (a,... a k, x i, a k+,..., a ) ad B = (b,... b m, x i, b m+,..., b 2 ) are risig sequeces. Now otice that a k+ = b m+, sice they are risig sequeces. Cotiuig this way gives: B = (b,... b m, x i, a k+,..., a ). The reaso that = 2 is that if > 2 (or vice versa), the x i is i the risig sequece B, but this ca ever be maximal. So it ca ot be a risig sequece. We ca also do this the other way aroud, hece B = (a,... a k, x i, a k+,..., a ) = A. The theorem establishes that a deck orderig ca be partitioed ito risig sequeces. We also fid that the umber of risig sequeces is limited to, where is the order of the deck. We ca achieve this by this orderig: [()( )... (2)()]. But what do risig sequeces cotribute to the a-shuffle R a? Well, as it turs out, it makes calculatios a lot easier. See the followig theorem ad its proof, which is a hybrid form of [3] ad [5]. 7

Theorem 4. Suppose we are give a deck [()(2)... ( )()] ad we wat to perform the a-shuffle R a. The probability of a certai permutatio π o this deck is: ( +a r ) a Here is the size of the deck ad r the umber of risig sequeces i the deck after applyig the permutatio π. Proof. Recall that all possible ways of cuttig the deck ad the iterleavig it have the same probability. So we eed to fid the umber of ways to cut the deck ito a packs, such that π is a possible permutatio. I a a-shuffle all cards stay i their relative order of the packs, so each risig sequece i the ew deck is a uio of the a packs. It is therefore, that we wat to fid the umber of ways of distributig r risig sequeces ito a packs. Because π has r risig sequeces, we kow where r cuts must have bee: betwee a card that eds a risig sequece of π ad aother card that begi a risig sequece of π. These pairs are of course cosecutive i the deck [()... ()]. But, we eed to make a cuts. Hece, we remai with (a ) (r ) = a r cuts i a deck of cards. So we eed to fill + (a r) = + a r positios with two types: cards ad (a r) cuts. This gives the biomial coefficiet. By prior explaatio, the deomiator a is trivial. Corollary. Suppose we have a deck [()(2)... ( )()] ad we Riffle shuffle k-times. The probability of edig up with a certai permutatio π o this give deck is: ( +2 ) k r 2 k Here is the size of the deck ad r the umber of risig sequeces of the deck after applyig the permutatio π. Proof. Combie theorem 2 ad theorem 4. Performig a Riffle shuffle (or 2- shuffle) k-times is equivalet to performig a 2 k -shuffle, accordig to theorem 2. Applyig theorem 4 yields the result. Iterestig is that we ca immediately see that the idetity permutatio (with oly oe risig sequece) is more likely to appear tha ay other permutatio. Also, suppose we have = r = 52 ad shuffle 5 times. The: ( +2 ) k r 2 k = ( 32 ) 52 2 52 = 0 So we eed to Riffle shuffle a ormal deck of cards more tha 5 times to eve possibly achieve the deck [(52)(5)... (2)()]. Kowig that the umber of risig sequeces determies the probability of a 8

certai shuffle, we might wat to kow how may differet permutatios yield a certai probability. For this, defie D(, r) as the umber of distict decks after a permutatio with r risig sequeces. If we look at the just proved theorem, we ow kow that: ( +a r ) D(, r) a = Which leads us to: r= ( ) + a r D(, r) = a r= Now defie the Euleria umbers A(, m) recursively: A(, m) = ( m)a(, m ) + (m + )A(, m) Also: A(, 0) = A(2, 0) = A(3, 0) = A(2, ) = A(3, ) = A(3, 2) = ad A(, m) is oly defied if: > m 0. Usig the Euleria umbers, we have the idetity of Worpitzky (for a proof see [6]): x = m=0 ( ) x + m A(, m) or x = ( ) x + m A(, m ) This formula holds for the Euleria umbers. Fillig i x = a ad m = r gives: ( ) + a r a = A(, r ) r=0 Usig the idetity A(, m) = A(, m ) ad makig a mior substitutio gives: ( ) + a r a = A(, r) or r=0 m= ( ) + a r A(, r ) We obtai: D(, r) = A(, r ). Fortuately, there is also a explicit formula for D(, r), usig the fact that they are the Euleria umbers A(, r ) (see []): D(, r) = A(, r ) = r= r ( ) + ( ) k (r k) () k k=0 Ideed, D(4, ) = A(4, 0) = ad D(4, 2) = A(4, ) = as we saw i example 6. At last, let me remark that sometimes A(, r) is defied as the umber of permutatios of S with r risig sequeces. I do ot adopt this otio, but rather stick to the defiitio o Wikipedia. Usig the closed form (or the kowledge of values of the Euleria umbers), we ca easily calculate the umber of permutatios i S which have r risig sequeces. 9

4..2 Applyig corollary As poited out, Riffle Shufflig a deck of 52 cards eeds to be doe more tha 5 times to have a otrivial probability for every permutatio. However, this might ot eve be a problem, because the differece betwee 52! (uiform shuffle U) ad 0 is ot that big. Therefore it is more iterestig to look at the variatio distace betwee R (k) ad U. Recall the variatio distace betwee two desities (Q ad Q 2 ) o the same deck of cards: Q Q 2 = 2 Applyig this to R (k) ad U gives: π S Q (π) Q 2 (π) R (k) U = R (k) (π) U(π) 2 r= π S Or, usig corollary ad (), we get: R (k) U = ( +2 ) k r D(, r) 2 2 k! = 2 r= m=0 r ( ) + ( ) m (r m) m 2 k! ( +2 ) k r Usig = 52, we ca plot the value of the variatio distace for k {0,,..., 4} (see Figure ). We see that the variatio distace takes a steep drop after 5 shuffles ad is early 0 after 2 shuffles. The umber 7 is ormally (I do ot completely agree) chose as the umber of shuffles it takes to radomize a deck (see for example [0]). 4.2 Riffle shuffle aalysis usig stoppig time Whe lookig at the Riffle shuffle, we could immediately calculate the probabilities through ice properties. However, there is a alterative approach which is more strict o the variatio distace betwee R (k) U. We will work this out ad fid out that it might ideed (as oticed before) be better to Riffle shuffle more tha 7 times. To work this out, some istrumets will be explaied. Firstly, (recall) the defiitio of a discrete-time Markov Chai. Defiitio 6. Suppose we have a sequece of radom variables X, X 2... ad X i ca take values i a coutable state space S. This sequece is called a discrete-time Markov Chai if it satisfies the Markov property, that is: the 20

Figure : The variatio distace betwee R ad U (y-axis) for certai successive Riffle shuffles (x-axis). Figure created usig Mathematica. probability of what happes i state m + is oly depedet o the state X m. More formally: P(X m+ X,... X m ) = P(X m+ X m ) It is a well-kow fact that if our Markov Chai has a irreducible aperiodic trasitio matrix o a fiite state space, that there exists a uique statioary distributio. I the Riffle shuffle case, we will take X m to be the orderig of the deck at time m. This is equivalet to some permutatio π S, which determies the ew positios of the umbered cards. Our iitial value X 0 is the orderig [()... ()]. This is obviously a Markov Chai, because the probability of a certai permutatio o this deck is oly depedet o the umber of risig sequece at time m. From earlier computatio, we kow that the statioary distributio is the uiform distributio: the Riffle shuffle coverges to the uiform distributio. Next, we defie a radom variable called the stoppig time. Also, a strog uiform time T will be defied (defiitio from [4]). Defiitio 7. Suppose we have a sequece of radom variables X, X 2,.... A stoppig time T is a radom variable with state space N. Moreover the probability that T = t is oly depedet o the values of X,..., X t. Defiitio 8. A strog uiform time T is a radomized stoppig time for a Markov Chai (X m : m 0) with statioary distributio π, state space S ad iitial state i 0 S, if: P(X k = i T = k) = π(i) for all k {0,,... } ad i S. Why do we eed the otio of stoppig time to fid a good amout of Riffle shuffles? Well, we ca use P(T > k) to estimate R (k) U! The proof of the followig lemma is largely based o [3]. 2

Lemma 3. Suppose we have a probability distributio Q o a fiite group G (= S ). Let T be a strog uiform time for Q. The, for all k 0: Q (k) U P(T > k) Proof. Suppose A G, the Q (k) (A) = P(X k A) = = k P(X k A, T = j) + P(X k A, T > k) j= k P(X k A T = j)p(t = j) + P(X k A T > k)p(t > k) j= But we kow that T is a strog uiform time, hece P(X k A T = j) = π(a) = U(A). This gives, with a little re-orderig: ( ) Q (k) (A) = U(A) + P(X k A T > k) U(A) P(T > k) Hece: Q (k) ( ) (A) U(A) = P(X k A T > k) U(A) P(T > k) P(T > k) Coclude the hypothesis, because A was arbitrarily. 4.2. Stoppig time for the Riffle shuffle So, if oe succeeds to fid a strog uiform time for the Riffle shuffle ad to obtai P(T > k), the it is possible to say somethig about R (k) U. Well, what stoppig time T should we use? Ma describes a good stoppig time T i [3]. Firstly, it is sufficiet to fid a stoppig time for the ushuffle, because the a- ushuffle ˆR a is exactly the iverse of the Riffle shuffle (that is ˆR a (π ) = R a (π)). Secodly, we eed a equivalet way of doig a a-ushuffle. This ca be doe by labellig all cards with a k {0,..., (a )} chose uiformly. Place all cards with a 0 o top of the ew deck, keepig their relative order. Repeat this for all umbers i ascedig order, always keepig the relative order of cards with the same umber k. O the other had, a equivalet way of describig the R a shuffle is by takig a digit base a umber ad puttig bars after the umber of zeros, the oes, et cetera. Here, the i-th digit of the chose umber is i the rage: {0,..., a }, chose uiformly. After this, place the umbers i their relative order o the spots they belog, that is the first card will be the card o the positio of the first 0 i the base a umber. Cotiue doig this for all zeros i the base 22

a umber. Repeat this process with all oes, et cetera. The equivalece is for example show i [3]. I will ow demostrate with a example how this is doe. Example 9. Take a = 3 ad = 8. Take the digit base 3 umber: 020222. That is, we have 2 zeros, 2 oes ad 4 twos. We wat to perform the 3-shuffle usig this code. Hece, the deck is split as: 2 34 5678. From the base umber, we get that the card should be o place 2 ad that the card 2 should be o place 4 (sice the zeros are o that spot). Cotiuig, we ed up with: [3524678], which is the permutatio π = (3542). Use the same base umber to perform the 3-ushuffle. So the cards o place 2 ad 4 should be i frot, i that order. These are ideed the cards ad 2. Cotiuig gives the origial deck [2345678]. This is the permutatio (2453). Ideed (2453) = π, as we expected. We ca do k cosecutive 2-ushuffles by gettig k biary umbers with digits (00... 0 is also a digit biary umber), ame them x,... x k. The, create biary umbers with k digits, ame these y,..., y. They are costructed as follows: the i-th digit of y j is equal to the j-th digit of x k+ i. After this, covert y,... y to regular umbers z,... z. We ca the sort the z i s i order of size (if z i = z j, the the z k with the smallest idex i or j is placest first). The order of the idices of the z i s gives the ew deck orderig. Why is this the same as performig k cosecutive 2-ushuffles? Well, there is a similar theorem for ushuffles, as theorem 2, but just the other way aroud: a b-ushuffle followed by a a-ushuffle is equivalet to a ab-ushuffle. As Ma poits out i [3], the orders are reversed: we write a b-ushuffle followed by a a-ushuffle. Ma gives the explaatio: for the same reaso that oe puts o socks ad the shoes, but takes of shoes ad the socks. I will ot dive ito details as with theorem 2, but assume the aforemetioed as true. A example seems more illustratig to me. Example 0. Suppose we wat to perform 4 cosecutive 2-ushuffles. So k = 4, = 5 ad we get the followig biary umbers with = 5 digits: x = 0, x 2 = 0, x 3 = 0000 ad x 4 = 000. These digit biary umbers are chose by uiformly selectig each digit. We get: 23

card 2-ushuffle (vertically: x 4 x 3 x 2 x ) ormal umbers y = 00 z = 3 2 y 2 = 0 z 2 = 3 y 3 = 00 z 3 = 3 4 y 4 = 00 z 4 = 9 5 y 5 = 00 z 5 = 6 Firstly, y is 00. This is because the first digits of x, x 2, x 3 ad x 4 are (respectively):,, 0 ad 0. Notice how we reverse the order. Secodly, the biary umbers are easily coverted to regular umbers. For example, 0 gives: 8 + 0 4 + 2 + =. Moreover, we get: (z, z 2, z 3, z 4, z 5 ) = (3,, 3, 9, 6). We order them (z comes before z 3, because < 3) ad get the order: (z, z 3, z 5, z 4, z 2 ). So, we ed up with the ushuffle of the origial deck ([2345]) of: [3542]. It is fially time to defie a stoppig time for 2-ushufflig, which gives us a stoppig time for 2-shufflig. The stoppig time T is defied as the umber of tries it takes to have distict base 2 T umbers. Lookig at the previous example: T > 4, sice the cards ad 3 have the same base umber. This does at first glace ot immediately seem like a radomized stoppig time ad strog uiform time, which we do eed. But as it turs out, it is quite easy to prove that it i fact is. Lemma 4. If T is defied as the umber of tries it takes to have distict base 2 T umbers for 2-ushufflig, it is a strog uiform time. Proof. First of all, it is ideed a radom variable with state space N. Ad the probability that T = t is oly depedet o the values of X,..., X t. Here X i is the permutatio of the deck at time i. This is a Markov Chai, sice oly the last permutatio matters for the curret orderig of the deck. The last thig we eed to verify is if: P(X k = i T = k) = π(i) for all k {0,,... } ad i S This ca be explaied easily, sice if T = k, the we have distict base 2 T umbers. But these umbers are chose radomly, hece for two cards i ad j it is equally alike that the umber of card i is larger tha the umber of card 24

Figure 2: The blue dots represet the real variatio distace. The yellow oes come from the upper boud. Figure obtaied usig Mathematica. j as the other way aroud. So the deck is uiformly distributed. Hece give k N ad i S: P(X k = i T = k) = S = π(i) Now all that remais is fidig P(T > k), the we ca apply lemma 3. This probability is exactly the probability that digit base 2 k umbers picked radomly are ot all distict. This is easily determied by its complemet. That is: we eed to fid the probability that o umber is equal. We have for the first umber 2 k optios. For the secod 2 k, all the way to the -th. That is: (2 k )(2 k )... (2 k +) = (2k )!. All with equal probability. Combiig (2 k )! 2 k gives: P(T > k) = (2k )! (2 k )! 2 k We fially have a upper boud, but I have to disappoit you: this is ot strict eough to come to the already calculated values of R (k) U. Take the usual case = 52 ad see figure 2 for the upper boud ad the variatio distace. Luckily, we have aother way of usig P(T > k). We kow that the shufflig is truly radom if T stops. Hece it is iterestig to determie E(T ). 25

Because P(T 0) =, we ca rewrite the stadard E(T ) ad behold: ( E(T ) = kp(t = k) = P(T > k) = (2k )! (2 k )! k=0 k=0 k=0 ) 2 k For = 52, we get aroud.7. So it takes about 2 Riffle shuffles to radomize. This is almost the same as usig the first value of k for which R (k) U is very close to 0. This is, oppositely to the upper boud, a direct way to see that aroud 2 Riffle shuffles should ideed be sufficiet. 5 Top-i shuffle Aother way to shuffle, which will tur out to be of less practical use, is the Top-i shuffle as i [3]. Defiitio 9. Defie the followig probability mass fuctio σ : S [0, ] by: if π = ( ()(k)(k + )(k + 2)... ( ) ) where k {, 2,..., } σ(π) = 0 else So if we apply this fuctio, we get a permutatio (with probability which seds the top card of the deck to place k ad all cards o place i k will be sed to i +. Now the Top-i shuffle (TS). Mark the bottom card of the deck (the card ). The proceed iteratively: Step : Fid a permutatio π usig σ. Step 2: If the card o place is ot equal to the marked card: apply π ad retur to step. Otherwise: apply π ad quit the iteratio. What does the Top-i shuffle do? It iserts the top card i the deck at a place chose uiformly. It cotiues to do so util the marked card comes o top. After that it places the marked card uiformly i the deck ad the shuffle is complete. Whe the marked card came up top, all cards beeath where radomized ad the last step radomly iserts the marked card. So this process ideed radomizes, that is: all decks are equally alike. However, as said, it is of less practical use: it is ot very efficiet ad takes a while to do. See a example below. Example. Take = 4. The followig k s have bee geerated by Mathematica (usig RadomIteger[{, 4}] ): {4,, 3, 4,, 2,, 4,, 2}. Notice that gettig at least oes is always eough, if the last oe is followed by aother 26

k. old deck k permutatio i this step π ew deck [234] 4 e [234] [234] (432) [423] [423] 3 (23) [432] [432] 4 e [432] [432] (423) [243] [243] 2 (43) [234] [234] (432) [234] So the deck is shuffled to itself. Now defie the radom variable T as the umber of times oe eeds to apply σ i total. Hece i the example above, T = 7. As we wated to fid out how may Riffle shuffles are eeded to radomize, ow we wat to fid out how soo the iteratios quit. So we eed to determie E(T ). For this, write T = T + + T 2 +. Here T j as the umber of times we eed to geerate a umber k such before the tagged card moves from positio j to positio j. The probability of pickig a umber such that the tagged card is moved from positio j to j i a certai iteratio is: p := j m= = j Usig the geometric series we get (p( p) i ): ( j j+ ) i if i N P(T j = i) = 0 else Which makes determiig E(T j ) easy, as this is just p = obtai E(T ): E(T ) = + E(T j ) = + j j=2 j= j. Usig this, we 27

Because the Harmoic umbers ca be approximated by log for large, we ca estimate E(T ) by log for large. Specifically for = 52, we get: 5 E(T ) = + 52 j j= 236 or E(T ) 52 log 52 205 This tured out to be a ice ad quiet simple approach. But, as we recall from sectio 4.2, that P(T > k) a upper boud is for the variatio distace. For this, the defiitio of T must ideed be so, that it is a strog uiform time. Lemma 5. If we defie T as the umber of permutatios we eed to geerate for the Top-i Shufflig process, the T is a strog uiform time. Proof. First of all, it is ideed a radom variable with state space N. Ad the probability that T = t is oly depedet o the values of X,..., X t. Here X i is the permutatio i step i. It is therefore obvious that T is a stoppig time for the Markov Chai (X i ) i. The statioary distributio π is the uiform distributio, because at a certai momet all distributios of the deck are equally alike. The last thig we eed to verify is if: P(X k = i T = k) = π(i) for all k {0,,... } ad i S This ca be explaied easily, sice if T = k, the every orderig is equally alike. This is exactly how the Top-i Shufflig process was defied. Hece give k N ad i S: P(X k = i T = k) = S = π(i) So from ow o, a method of estimatig P(T > k) will be preseted. For this, defie the coupo collecter distributio. Liag provides a extesive method to estimate P(T > k) i [2]. Suppose we have a coupo collector. We defie the radom variable C as the umber of coupos the collector has whe he collected all coupos. Here the probability of gettig a specific type of coupo is:. Lemma 6. Let C be a coupo collector radom variable. have: P(C > log + α ) e α Give α > 0, we Proof. Defie A i to be the evet that the i-th coupo type is ot preset i the first log + α draws. Because the probability of ot drawig coupo type i is (i.i.d.) =, we have: P(A i ) ( log +α ) 28