HOW MANY TIMES SHOULD YOU SHUFFLE A DECK OF CARDS? 1


 Hubert Caldwell
 1 years ago
 Views:
Transcription
1 1 HOW MANY TIMES SHOULD YOU SHUFFLE A DECK OF CARDS? 1 Brad Ma Departmet of Mathematics Harvard Uiversity ABSTRACT I this paper a mathematical model of card shufflig is costructed, ad used to determie how much shufflig is ecessary to radomize a deck of cards. The crucial aspect of this model is risig sequeces of permutatios, or equivaletly descets i their iverses. The probability of a arragemet of cards occurig uder shufflig is a fuctio oly of the umber of risig sequeces i the permutatio. This fact makes computatio of variatio distace, a measure of radomess, feasible; for i a card deck there are at most risig sequeces but! possible arragemets. This computatio is doe exactly for = 52, ad other approximatio methods are cosidered. 1 INTRODUCTION How may times do you have to shuffle a deck of cards i order to mix them reasoably well? The aswer is about seve for a deck of fiftytwo cards, or so claims Persi Diacois. This somewhat surprisig result made the New York Times [5] a few years ago. It ca be see by a itriguig ad yet uderstadable aalysis of the process of shufflig. This paper is a expositio of such a aalysis i Bayer ad Diacois [2], though may people have doe work o shufflig. These have icluded E. Gilbert ad Claude Shao at Bell Labs i the 50 s, ad more recetly Jim Reeds ad David Aldous. 1 This article was writte for the Chace Project at Dartmouth College supported by the Natioal Sciece Foudatio ad The New Eglad Cosortium for Udergraduate Educatio.
2 2 2 WHAT IS A SHUFFLE, REALLY? 2.1 Permutatios Let us suppose we have a deck of cards, labeled by the itegers from 1to. We will write the deck with the order of the cards goig from left to right, so that a virgi ushuffled deck would be writte 123. Hereafter we will call this the atural order. The deck after complete reversal would look like 321. A cocise mathematical way to thik about chagig orderigs of the deck is give by permutatios. A permutatio of thigs is just a oetooe map from the set of itegers, betwee 1 ad iclusive, to itself. Let S stad for the set of all such permutatios. We will write the permutatios i S by lower case Greek letters, such as π, ad ca associate with each permutatio a way of rearragig the deck. This will be doe so that the card i positio i after the deck is rearraged was i positio π(i) before the deck was rearraged. For istace, cosider the rearragemet of a 5 card deck by movig the first card to the ed of the deck ad every other card up oe positio. The correspodig permutatio π 1 would be writte i π 1 (i) Or cosider the socalled perfect shuffle rearragemet of a 8 card deck, which is accomplished by cuttig the deck exactly i half ad the alteratig cards from each half, such that the top card comes from the top half ad the bottom card from the bottom half. The correspodig permutatio π 2 is i π 2 (i) Now we do t always wat to give a small table to specify permutatios. So we may codese otatio ad just write the secod lie of the table, assumig the first lie was the positios 1 through i order. We will use brackets whe we do this to idicate that we are talkig about permutatios ad ot orders of the deck. So i the above examples we ca write π 1 = [23451] ad π 2 = [ ]. It is importat to remember the distictio betwee orderigs of the deck ad permutatios. A orderig is the specific order i which the cards lie i the deck. A permutatio, o the other had, does ot say aythig about the specific order of a deck. It oly specifies some
3 3 rearragemet, i.e. how oe orderig chages to aother, regardless of what the first orderig is. For example, the permutatio π 1 = [23451] chages the orderig to 23451, as well as rearragig to 13254, ad to (What will be true, however, is that the umbers we write dow for a permutatio will always be the same as the umbers for the orderig that results whe the rearragemet correspodig to this permutatio is doe to the aturally ordered deck.) Mathematicias say this covetio gives a actio of the group of permutatios S o the set of orderigs of the deck. (I fact, the actio is a simply trasitive oe, which just meas there is always a uique permutatio that rearrages the deck from ay give order to ay other give order.) Now we wat to cosider what happes whe we perform a rearragemet correspodig to some permutatio π, ad the follow it by a rearragemet correspodig to some other permutatio τ. This will be importat later whe we wish to codese several rearragemets ito oe, as i shufflig a deck of cards repeatedly. The card i positio i after both rearragemets are doe was i positio τ(i) whe the first but ot the secod rearragemet was doe. But the card i positio j after the first but ot the secod rearragemet was i positio π(j) before ay rearragemets. So set j = τ(i) ad get that the card i positio i after both rearragemets was i positio π(τ(i)) before ay rearragemets. For this reaso we defie the compositio π τ of π ad τ to be the map which takes i to π(τ(i)), ad we see that doig the rearragemet correspodig to π ad the the oe correspodig to τ is equivalet to a sigle rearragemet give by π τ. (Note that we have π τ ad ot τ π whe π is doe first ad τ secod. I short, the order matters greatly whe composig permutatios, ad mathematicias say that S is ocommutative.) For example, we see the complete reversal of a 5 card deck is give by π 3 = [54321], ad we ca compute the compositio π 1 π Shuffles i π 3 (i) π 1 π 3 (i) Now we must defie what a shuffle, or method of shufflig, is. It s just a probability desity o S, cosiderig each permutatio as a way of rearragig the deck. This meas that each permutatio is give a certai fixed probability of occurig, ad that all such probabilities
4 4 add up to oe. A wellkow example is the topi shuffle. This is accomplished by takig the top card off the deck ad reisertig it i ay of the positios betwee the 1 cards i the remaider of the deck, doig so radomly accordig to a uiform choice. This meas the desity o S is give by 1/ for each of the cyclic permutatios [234 (k 1)k1(k + 1)(k +2) ( 1)] for 1 k, ad 0 for all other permutatios. This is give for a deck of size = 3 i the followig example: permutatio [123] [213] [231] [132] [321] [312] probability uder topi 1/3 1/3 1/ What this defiitio of shuffle leads to, whe the deck is repeatedly shuffled, is a radom walk o the group of permutatios S. Suppose you are give a method of shufflig Q, meaig each permutatio π is give a certai probability Q(π) of occurig. Start at the idetity of S, i.e. the trivial rearragemet of the deck which does ot chage its order at all. Now take a step i the radom walk, which meas choose a permutatio π 1 radomly, accordig to the probabilities specified by the desity Q. (So π 1 is really a radom variable.) Rearrage the deck as directed by π 1, so that the card ow i positio i was i positio π 1 (i) before the rearragemet. The probability of each of these various rearragigs of the deck is obviously just the desity of π 1, give by Q. Now repeat the procedure for a secod step i the radom walk, choosig aother permutatio π 2, agai radomly accordig to the desity Q (i.e. π 2 is a secod, idepedet radom variable with the same desity as π 1 ). Rearrage the deck accordig to π 2. We saw i the last sectio o permutatios that the effective rearragemet of the deck icludig both permutatios is give by π 1 π 2. What is the probabiltiy of ay particular permutatio ow, i.e what is the desity for π 1 π 2? Call this desity Q (2). To compute it, ote the probability of π 1 beig chose, ad the π 2, is give by Q(π 1 ) Q(π 2 ), sice the choices are idepedet of each other. So for ay particular permutatio π, Q (2) (π) is give by the sum of Q(π 1 ) Q(π 2 ) for all pairs π 1,π 2 such that π = π 1 π 2, sice i geeral there may be may differet ways of choosig π 1 ad the π 2 to get the same π = π 1 π 2. (For istace, completely reversig the deck ad the switchig the first two cards gives the same overall rearragemet as first switchig the last two cards ad the reversig the deck.) This way of combiig Q
5 5 with itself is called a covolutio ad writte Q Q: Q (2) (π) =Q Q(π) = Q(π 1 )Q(π 2 )= Q(π 1 )Q(π1 1 π). π 1 π 2 =π π 1 Here π1 1 deotes the iverse of π 1, which is the permutatio that udoes π 1, i the sese that π 1 π1 1 ad π1 1 π 1 are both equal to the idetity permutatio which leaves the deck uchaged. For istace, the iverse of [253641] is [613524]. So we ow have a shorthad way of expressig the overall probability desity o S after two steps of the radom walk, each step determied by the same desity Q. More geerally, we may let each step be specified by a differet desity, say Q 1 ad the Q 2. The the resultig desity is give by the covolutio Q 1 Q 2 (π) = π 1 π2=π Q 1 (π 1 )Q 2 (π 2 )= π 1 Q 1 (π 1 )Q 2 (π 1 1 π). Further, we may ru the radom walk for a arbitrary umber, say k, of steps, the desity o S beig give at each step i by some Q i. The the resultig desity o S after these k steps will be give by Q 1 Q 2 Q k. Equivaletly, doig the shuffle specified by Q 1, ad the the shuffle specified by Q 2, ad so o, up through the shuffle give by Q k, is the same as doig the sigle shuffle specified by Q 1 Q 2 Q k. I short, repeated shufflig correspods to covolutig desities. This method of covolutios is complicated, however, ad we will see later that for a realistic type of shuffle, there is a much easier way to compute the probability of ay particular permutatio after ay particular umber of shuffles. 3 THE RIFFLE SHUFFLE We would ow like to choose a realistic model of how actual cards are physically shuffled by people. A particular oe with ice mathematical properties is give by the riffle shuffle. (Sometimes called the GSR shuffle, it was developed by Gilbert ad Shao, ad idepedetly by Reeds.) It goes as follows. First cut the deck ito two packets, the first cotaiig k cards, ad the other the remaiig k cards. Choose k, the umber of cards cut, accordig to the biomial desity, meaig ( the probability ) of the cut occurig exactly after k cards is give by /2 k.
6 6 Oce the deck has bee cut ito two packets, iterleave the cards from each packet i ay possible way, such that the cards of each packet maitai their ow relative order. This meas that the cards origially i positios 1, 2, 3,...k must still be i the same order i the deck after it is shuffled, eve if there are other cards ibetwee; the same goes for the cards origially i positios k + 1, k+ 2,... This requiremet is quite atural whe you thik of how a perso shuffles two packets of cards, oe i each had. The cards i the left had must still be i the same relative order i the shuffled deck, o matter how they are iterleaved with the cards from the other packet, because the cards i the left had are dropped i order whe shufflig; the same goes for the cards i the right had. Choose amog all such iterleavigs ( ) uiformly, meaig each is e qually likely. Sice there are possible iterleavigs (as we oly k eed choose k spots amog places for the first packet, the spots for the cards of the other packet the beig( determied), ) this meas ay particular iterleavig has probability 1/ of occurig. Hece the k probability of ay particular ( cut) followed( by a) particular iterleavig, with k the size of the cut, is /2 k 1/ =1/2 k. Note that this probability 1/2 cotais o iformatio about the cut or the iterleavig! I other words, the desity of cuts ad iterleavigs is uiform every pair of a cut ad a possible resultig iterleavig has the same probability. This uiform desity o the set of cuts ad iterleavigs ow iduces i a atural way a desity o the set of permutatios, i.e. a shuffle, accordig to our defiitio. We will call this the riffle shuffle ad deote it by R. It is defied for π i S by R(π) = the sum of the probabilities of each cut ad iterleavig that gives the rearragemet of the deck correspodig to π, which is 1/2 times the umber of ways of cuttig ad iterleavig that give the rearragemet of the deck correspodig to π. I short, the chace of ay arragemet of cards occurig uder riffle shufflig is simply the proportio of ways of rifflig which give that arragemet. Here is a particular example of the riffle shuffle i the case =3, with the deck startig i atural order 123.
7 7 k = cut positio cut deck probability of this cut possible iterleavigs / /8 123,213, /8 123,132, /8 123 Note that 0 or all 3 cards may be cut, i which case oe packet is empty ad the other is the whole deck. Now let us compute the probability of each particular orderig occurrig i the above example. First, look for 213. It occurs oly i the cut k=1, which has probability 3/8. There it is oe of three possibilities, ad hece has the coditioal probability 1/3, give k = 1. So the overall probability for 213 is 1 3 = 1, where of course 1 = 1 is the probability of ay particular cut ad iterleavig pair. Similar aalyses hold for 312, 132, ad 231, sice they all occur oly through a sigle cut ad iterleavig. For 123, it is differet; there are four cuts ad iterleavigs which give rise to it. It occurs for k =0, 1,2, ad 3, these situatios havig probabilities 1/8, 3/8, 3/8, ad 1/8, respectively. I these cases, the coditioal probability of 123, give the cut, is 1, 1/3, 1/3, ad 1. So the overall probability of the orderig is = 1, which also equals 4 1, the umber of ways of cuttig ad iterleavig that 2 3 give rise to the orderig times the probability of ay particular cut ad iterleavig. We may write dow the etire desity, ow droppig the assumptio that the deck started i the atural order, which meas we must use permutatios istead of orderigs. permutatio π [123] [213] [231] [132] [312] [321] probability R(π) uder riffle 1/2 1/8 1/8 1/8 1/8 0 It is worth makig obvious a poit which should be apparet. The iformatio specified by a cut ad a iterleavig is richer tha the iformatio specified by the resultig permutatio. I other words, there may be several differet ways of cuttig ad iterleavig that give rise to the same permutatio, but differet permutatios ecessarily arise from distict cut/iterleavig pairs. (A exercise for the reader is to show that for the riffle shuffle, this distictio is otrivial oly whe the permutatio is the idetity, i.e. the oly time distict cut/iterleavig pairs give rise to the same permutatio is whe the permutatio is the idetity.)
8 8 There is a secod, equivalet way of describig the riffle shuffle. Start the same way, by cuttig the deck accordig to the biomial desity ito two packets of size k ad k. Now we are goig to drop a card from the bottom of oe of the two packets oto a table, face dow. Choose betwee the packets with probability proportioal to packet size, meaig if the two packets are of size p 1 ad p 2, the the p probability of the card droppig from the first is 1 p 1 +p 2, ad p 2 p 1 +p 2 from the secod. So this first time, the probabilities would be k k ad. Now repeat the process, with the umbers p 1 ad p 2 beig updated to reflect the actual packet sizes by subtractig oe from the size of whichever packet had the card dropped last time. For istace, if the first card was dropped from the first packet, the the probabilities for the ext drop would be k 1 k ad. Keep goig util all cards are 1 1 dropped. This method is equivalet to the first descriptio ( of) the riffle i that this process also assigs uiform probability 1/ to each k possible resultig iterleavig of the cards. To see this, let us figure out the probability for some particular way of droppig the cards, say, for the sake of defiiteess, from the first packet ad the from the first, secod, secod, secod, first, ad so o. The probability of the drops occurig this way is k k 1 1 k 2 k 1 k 2 k , where we have multiplied probabilities sice each drop decisio is idepedet of the others oce the packet sizes have bee readjusted. Now the product of the deomiators of these fractios is!, sice it is just the product of the total umber of cards left i both packets before each drop, ad this umber decreases by oe each time. What is the product of the umerators? Well, we get oe factor every time a card is dropped from oe of the packets, this factor beig the size of the packet at that time. But the we get all the umbers k, k 1,..., 1 ad k, k 1,..., 1 as factors i some order, sice each packet passes through all of the sizes i its respective list as the cards are dropped from the two packets. So the umerator ( is ) k!( k)!, which makes the overall probability k!( k)!/! =1/, which is obviously valid for k ay particular sequece of drops, ad ot just the above example. So we have ow show the two descriptios of the riffle shuffle are equivalet, as they have the same uiform probability of iterleavig after a biomial cut.
9 9 Now let R (k) stad for covolutig R with itself k times. This correspods to the desity after k riffle shuffles. For which k does R (k) produce a radomized deck? The ext sectio begis to aswer this questio. 4 HOW FAR AWAY FROM RANDOM NESS? Before we cosider the questio of how may times we eed to shuffle, we must decide what we wat to achieve by shufflig. The aswer should be radomess of some sort. What does radomess mea? Simply put, ay arragemet of cards is equaly likely; o oe orderig should be favored over aother. This meas the uiform desity U o S, each permutatio havig probability U(π) =1/ S =1/!. Now it turs out that for ay fixed umber of shuffles, o matter how large, riffle shufflig does ot produce complete radomess i this sese. (We will, i fact, give a explicit formula which shows that after ay umber of riffle shuffles, the idetity permutatio is always more likely tha ay other to occur.) So whe we ask how may times we eed to shuffle, we are ot askig how far to go i order to achieve radomess, but rather to get close to radomess. So we must defie what we mea by close, or far, i.e. we eed a distace betwee desities. The cocept we will use is called variatio distace (which is essetially the L 1 metric o the space of desities). Suppose we are give two probability desities, Q 1 ad Q 2,oS. The the variatio distace betwee Q 1 ad Q 2 is defied to be Q 1 Q 2 = 1 Q 1 (π) Q 2 (π). 2 π S The 1 ormalizes the result to always be betwee 0 ad 1. 2 Here is a example. Let Q 1 = R be the desity calculated above for the three card riffle shuffle. Let Q 2 be the complete reversal the desity that gives probability 1 for [321], i.e. certaity, ad 0 for all other permutatios, i.e. ooccurece.
10 10 π Q 1 (π) Q 2 (π) Q 1 (π) Q 2 (π) [123] 1/2 0 1/2 [213] 1/8 0 1/8 [312] 1/8 0 1/8 [132] 1/8 0 1/8 [231] 1/8 0 1/8 [321] Total 2 So here Q 1 Q 2 =2/2 = 1, ad the desities are as far apart as possible. Now the questio we really wat to ask is: how big must we take k to make the variatio distace R (k) U betwee the riffle ad uiform small? This ca be best aswered by a graph of R (k) U versus k. The followig theory is directed towards costructig this graph. 5 RISING SEQUENCES To begi to determie what the desity R (k) is, we eed to cosider a fudametal cocept, that of a risig sequece. A risig sequece of a permutatio is a maximal cosecutively icreasig subsequece. What does this really mea for cards? Well, perform the rearragemet correspodig to the permutatio o a aturally ordered deck. Pick ay card, labeled x say, ad look after it i the deck for the card labeled x + 1. If you fid it, repeat the procedure, ow lookig after the x +1 card for the x + 2 card. Keep goig i this maer util you have to stop because you ca t fid the ext card after a give card. Now go back to your origial card x ad reverse the procedure, lookig before the origial card for the x 1 card, ad so o. Whe you are doe, you have a risig sequece. It turs out that a deck breaks dow as a disjoit uio of its risig sequeces, sice the uio of ay two cosecutively icreasig subsequeces cotaiig a give elemet is also a cosecutively icreasig subsequece that cotais that elemet. Let s look at a example. Suppose we kow that the order of a eight card deck after shufflig the atural order is Start with ay card, say 3. We look for the ext card i value after it, 4, ad do ot fid it. So we stop lookig after ad look before the 3. We fid 2, ad the we look for 1 before 2 ad fid it. So oe of the risig sequeces is give by 123. Now start agai with 6. We fid 7 ad the
11 11 8 after it, ad 5 ad the 4 before it. So aother risig sequece is We have accouted for all the cards, ad are therefore doe. Thus this deck has oly two risig sequeces. This is immediately clear if we write the order of the deck this way, , offsettig the two risig sequeces. It is clear that a traied eye may pick out risig sequeces immediately, ad this forms the basis for some card tricks. Suppose a brad ew deck of cards is riffle shuffled three times by a spectator, who the takes the top card, looks at it without showig it to a magicia, ad places it back i the deck at radom. The magicia the tries to idetify the reiserted card. He is ofte able to do so because the reiserted card will ofte form a sigleto risig sequece, cosistig of just itself. Most likely, all the other cards will fall ito 2 3 = 8 risig sequeces of legth 6 to 7, sice repeated riffle shufflig, at least the first few times, roughly teds to double the umber of the risig sequeces ad halve the legth of each oe each time. Diacois, himself a magicia, ad Bayer [2] describe variats of this trick that magicias have actually used. It is iterestig to ote that the order of the deck i our example, , is a possible result of a riffle shuffle with a cut after 3 cards. I fact, ay orderig with just two risig sequeces is a possible result of a riffle shuffle. Here the cut must divide the deck ito two packets such that the legth of each is the same as the legth of the correspodig risig sequece. So if we started i the atural order ad cut the deck ito 123 ad 45678, we would iterleave by takig 4, the 5, the 1, the 6, the 2, the 3, the 7, the 8, thus obtaiig the give order through rifflig. The coverse of this result is that the riffle shuffle always gives decks with either oe or two risig sequeces. 6 BIGGER AND BETTER: ashuffles The result that a permutatio has ozero probability uder the riffle shuffle if ad oly if it has exactly oe or two risig sequeces is true, but it oly holds for a sigle riffle shuffle. We would like similar results o what happes after multiple riffle suffles. This ca igeiously be accomplished by cosiderig ashuffles, a geeralizatio of the riffle shuffle. A ashuffle is aother probability desity o S, achieved as follows. Let a stad for ay positive iteger. Cut the deck ito a packets, of oegative sizes p 1,p 2,...,p a, with the probability
12 12 ( of this particular ) packet structure give by the multiomial desity: /a p 1,p 2,...,p. Note we must have p p a =, but some a of the p i may be zero. Now iterleave the cards from each packet i ay way, so log as the cards from each packet maitai their relative order amog themselves. With a fixed packet structure, cosider all iterleavigs equally likely. Let us cout the umber of such iterleavigs. We simply wat the umber of differet ways of choosig, amog positios i the deck, p 1 places for thigs of oe type, p 2 places for ( thigs of aother ) type, etc. This is give by the multiomial coefficiet. Hece the probability of a particular rearragemet, p 1,p 2,...,p a i.e. a cut of the deck ad a iterleavig, is ( ) ( ) /a = 1 p 1,p 2,...,p a p 1,p 2,...,p a a. So it turs out that each combiatio of a particular cut ito a packets ad a particular iterleavig is equally likely, just as i the riffle shuffle. The iduced desity o the permutatios correspodig to the cuts ad iterleavigs is the called the ashuffle. We will deote it by R a.itis apparet that the riffle is just the 2shuffle, so R = R 2. A equivalet descriptio of the ashuffle begis the same way, by cuttig the deck ito packets multiomially. But the drop cards from the bottom of the packets, oe at a time, such that the probability of choosig a particular packet to drop from is proportioal to the relative size of that packet compared to the umber of cards left i all the packets. The proof that this descriptio is ideed equivalet is exactly aalogous to the a = 2 case. A third equivalet descriptio is give by cuttig multiomially ito p 1,p 2,...,p a ad rifflig p 1 ad p 2 together (meaig choose uiformly amog all iterleavigs which maitai the relative order of each packet), the rifflig the resultig pile with p 3, the rifflig that resultig pile with p 4, ad so o. There is a useful code that we ca costruct to specify how a particular ashuffle is doe. (Note that we are abusig termiology slightly ad usig shuffle here to idicate a particular way of rearragig the deck, ad ot the desity o all such rearragemets.) This is doe through digit base a umbers. Let A be ay oe of these digit umbers. Cout the umber of 0 s i A. This will be the size of the first packet i the ashuffle, p 1. The p 2 is the umber of 1 s i A, ad so o, up through p a = the umber of (a 1) s. This cuts the deck cut ito a packets. Now take the begiig packet of cards, of size p 1.
13 13 Evisio placig these cards o top of all the 0 digits of A, maitaiig their relative order as a risig sequece. Do the same for the ext packet, p 2, except placig them o the 1 s. Agai, cotiue up through the (a 1) s. This particular way of rearragig the cards will the be the particular cut ad iterleavig correspodig to A. Here is a example, with the deck startig i atural order. Let A = be the code for a particular 5shuffle of the 8 card deck. There are three 0 s, oe 1, oe 2, two 3 s, ad oe 4. Thus p 1 =3,p 2 = 1, p 3 =1,p 4 =2, ad p 5 = 1. So the deck is cut ito So we place 123 where the 0 s are i A, 4 where the 1 is, 5 where the 2 is, 67 where the 3 s are, ad 8 where the 4 is. We the get a shuffled deck of whe A is applied to the atural order. Reflectio shows that this code gives a bijective correspodece betwee digit base a umbers ad the set of all ways of cuttig ad iterleavig a card deck accordig to the ashuffle. I fact, if we put the uiform desity o the set of digit base a umbers, this trasfers to the correct uiform probability for cuttig ad iterleavig i a ashuffle, which meas the correct desity is iduced o S, i.e. we get the right probabilities for a ashuffle. This code will prove useful later o. 7 VIRTUES OF THE ashuffle 7.1 Relatio to risig sequeces There is a great advatage to cosiderig ashuffles. It turs out that whe you perform a sigle ashuffle, the probability of achievig a particular permutatio π does ot deped upo all the iformatio cotaied i π, but oly o the umber of risig sequece that π has. I other words, we immediately kow that the permutatios [12534], [34512], [51234], ad [23451] all have the same probability uder ay ashuffle, sice they all have exactly two risig sequeces. Here is the exact result: The probablity of( achievig a) permutatio π whe doig a + a r ashuffle is give by /a, where r is the umber of risig sequeces i π. Proof: First ote that if we establish ad fix where the a 1 cuts occur i a ashuffle, the whatever permutatios ca actually be
14 14 achieved by iterleavig the cards from this cut/packet structure are achieved i exactly oe way; amely, just drop the cards i exactly the order of the permutatio. Thus the probability of achievig a particular permutatio is the umber of possible ways of makig cuts that could actually give rise to that permutatio, divided by the total umber of ways of makig cuts ad iterleavig for a ashuffle. So let us cout the ways of makig cuts i the aturally ordered deck that could give the orderig that results whe π is applied. If we have r risig sequeces i π, we kow exactly where r 1 of the cuts have to have bee; they must have occurred betwee pairs of cosecutive cards i the aturally ordered deck such that the first card eds oe risig sequece of π ad the secod begis aother risig sequece of π. This meas we have a 1 (r 1) = a r uspecified, or free, cuts. These are free i the sese that they ca i fact go aywhere. So we must cout the umber of ways of puttig a r cuts amog cards. This ca easily be doe by cosiderig a sequece of (a r)+ blak spots which must be filled by (a r) thigs ( of oe type ) (cuts) ad thigs (a r)+ of aother type (cards). There are ways to do this, i.e. choosig places amog (a r)+. This is the umerator for our probability expressed as a fractio; the deomiator is the umber of possible ways to cut ad iterleave for a ashuffle. By cosiderig the ecodig of shuffles we see there are a ways to do this, as there are this may digit base a umbers. Hece our result is true. This allows us to evisio the probability desity associated with a ashufle i a ice way. Order all the permutatio i S i ay way such that the umber of risig sequeces is odecreasig. If we label these permutatios as poits o a horizotal axis, we may take the vertical axis to be the umbers betwee 0 ad 1, ad at each permutatio place a poit whose vertical coordiate is the probability of the permutatio. Obviously, the above result meas we will have sets of poits of the same height. Here is a example for a 7shuffle of the five card deck (solid lie), alog with the uiform desity U 1/5! = 1/120 (dashed lie). ( ) + a r Notice the probability /a is a mootoe decreasig fuctio of r. This meas if 1 r 1 <r 2, the a particular permutatios with r 1 risig sequeces is always more likely tha a permutatio
15 15 with r 2 risig sequeces uder ay ashuffle. Hece the graph of the desity for a ashuffle, if the permutatios are ordered as above, will always be oicreasig. I particular, the probability starts above uiform for the idetity, ( the oly permutatio ) with r = 1. (I our example R 7 (idetity) = /7 5 5 =.0275.) It the decreases for icreasig r, at some poit crossig below uiform (from r =2 to 3 i the example). The greatest r value such that the probability is above uiform is called the crossover poit. Evetually at r =, which occurs oly for the permutatio correspodig to complete reversal of the ) deck, the probability is at its lowest value. (I the example ( /7 5 5 =.0012.) All this explais the earlier statemet that after a ashuffle, the idetity is always more likely tha it would be uder a truly radom desity, ad is always more likely tha ay other particular permutatio after the same ashuffle. For a fixed deck size, it is iterestig to ote the behavior of the crossover poit as a icreases. By aalyzig the iequality ( ) + a r /a 1!, the reader may prove that the crossover poit ever moves to the left, i.e. it is a odecreasig fuctio of a, ad that it evetually moves to the right, up to /2 for eve ad ( 1)/2 for odd, but ever beyod. Furthermore, it will reach this halfway poit for a approximately the size of 2 /12. Combiig with the results of the ext sectio, this meas roughly 2 log 2 riffle shuffles are eeded to brig the crossover poit to halfway. 7.2 The multiplicatio theorem Why bother with a ashuffle? I spite of the ice formula for a desity depedet oly o the umber of risig sequeces, ashuffles seem of little practical use to ay creature that is ot ahaded. This turs out to be false. After we establish aother major result that addresses this questio, we will be i busiess to costruct our variatio distace graph. This result cocers multiple shuffles. Suppose you do a riffle shuffle twice. Is there ay simple way to describe what happes, all i oe step, other tha the covolutio of desities described i sectio 2.2?
16 16 Or more geerally, if you do a ashuffle ad the do a bshuffle, how ca you describe the result? The aswer is the followig: A ashuffle followed by a bshuffle is equivalet to a sigle abshuffle, i the sese that both processes give exactly the same resultig probability desity o the set of permutatios. Proof: Let us use the previously described code for shuffles. Suppose that A is a digit base a umber, ad B is a digit base b umber. The first doig the cut ad iterleavig ecoded by A ad the doig the cut ad iterleavig ecoded by B gives the same permutatio as the oe resultig from the cut ad iterleavig ecoded by the digit base ab umber give by A B &B, as Joh Fi figured out. (The proof for this formula will be deferred util sectio 9.4, where the iverse shuffle is discussed.) This formula eeds some explaatio. A B is defied to be the code that has the same base a digits as A, but rearraged accordig to the permutatio specified by B. The symbol & i A B &B stads for digitwise cocateatio of two umbers, meaig treat the base a digit A B i i the ith place of A B together with the base b digit B i i the ith place of B as the base ab digit give by A B i b+b i.i other words, treat the combiatio A B i &B i as a two digit umber, the rightmost place havig value 1, ad the leftmost place havig value b, ad the treat the result as a oe digit base ab umber. Why this formula holds is better show by a example tha by geeral formulas. Suppose A = is the code for a particular 3 shuffle, ad B = is the code for a particular 4shuffle. (Agai we are abusig termiology slightly.) Let π A ad π B be the respective permutatios. The i the tables below ote that π A π B, the result of a particular 3shuffle followed by a particular 4shuffle, ad π A B &B, the result of a particular 12shuffle, are the same permutatio. i π A (i) π B (i) π A π B (i) A B A B B A B &B i π A B &B(i)
17 17 We ow have a formula A B &B that is really a oetooe correspodece betwee the set of pairs, cosistig of oe digit base a umber ad oe digit base b umber, ad the set of digit base ab umbers; further this formula has the property that the cut ad iterleavig specified by A, followed by the cut ad iterleavig specified by B, result i the same permutatio of the deck as that resultig from the cut ad iterleavig specified by A B &B. Sice the probability desities for a, b, ad abshuffles are iduced by the uiform desities o the sets of digit base a, b, or ab codes, respectively, the properties of the oetooe correspodece imply the iduced desities o S of a ashuffle followed by a bshuffle ad a abshuffle are the same. Hece our result is true. 7.3 Expected happeigs after a ashuffle It is of theoretical iterest to measure the expected value of various quatities after a ashuffle of the deck. For istace, we may ask what is the expected umber of risig sequeces after a ashuffle? I ve foud a approach to this questio which has too much computatio to be preseted here, but gives the aswer as a +1 a 1 r. a As a, this expressio teds to +1, which is the expected umber 2 of risig sequeces for a radom permutatio. Whe, the expressio goes to a. This makes sese, sice whe the umber of packets is much less tha the size of the deck, the expected umber of risig sequeces is the same as the umber of packets. The expected umber of fixed poits of a permutatio after a a shuffle is give by 1 i=0 a i, as metioed i [2]. As, this 1 expressio teds to = a, which is betwee 1 ad 2. As a, 1 1/a a 1 the expected umber of fixed poits goes to 1, which is the expected umber of fixed poits for a radom permutatio. 8 PUTTING IT ALL TOGETHER r=0 Let us ow combie our two major results of the last sectio to get a formula for R (k), the probability desity for the riffle shuffle doe k times. This is just k 2shuffles, oe after aother. So by the multiplicatio theorem, this is equivalet to a sigle =2 k shuffle.
18 ( 2 Hece i the R (k) desity, there is a k ) + r /2 k chace of a permutatio with r risig sequeces occurrig, by our risig sequece formula. This ow allows us to work o the variatio distace R k U. For a permutatio π with r risig sequeces, we see that ( R k 2 (π) U(π) = k ) + r /2 k 1!. 18 We must ow add up all the terms like this, oe for each permutatio. We ca group terms i our sum accordig to the umber of risig sequeces. If we let A,r stad for the umber of permutatios of cards that have r risig sequeces, each of which have the same probabilities, the the variatio distace is give by R k U = 1 2 r=1 A,r ( 2 k + r ) /2 k 1!. The oly thig uexplaied is how to calculate the A,r. These are called the Euleria umbers, ad various formulas are give for them (e.g. see [8]). Oe recursive oe is A,1 = 1 ad A,r = r ( r 1 + r j j=1 (It is iterestig to ote that the Euleria umbers are symmetric i the sese that A,r = A, r+1. So there are just as may permutatios with r risig sequeces as there are with r + 1 risig sequeces, which the reader is ivited to prove directly.) Now the expressio for variatio distace may seem formidable, ad it is. But it is easy ad quick for a computer program to calculate ad graph R k U versus k for ay specific, moderately sized. Eve o the computer, however, this computatio is tractable because we oly have terms, correspodig to each possible umber of risig sequeces. If we did ot have the result o the ivariace of the probability whe the umber of risig sequeces is costat, we would have S =! terms i the sum. For = 52, this is approximately 10 68, which is much larger tha ay computer could hadle. Here is the graphical result of a short Mathematica program that does the calculatios for = 52. The horizotal axis is the umber of riffle shuffles, ad the vertical axis is the variatio distace to uiform. ) A,j. The aswer is fially at had. It is clear that the graph makes a sharp cutoff at k = 5, ad gets reasoably close to 0 by k = 11. A good middle poit for the cutoff seems to k = 7, ad this is why seve shuffles are said to be eough for the usual deck of 52 cards.
19 19 Additioally, asymptotic aalysis i [2] shows that whe, the umber of cards, is large, approximately k = 3 log shuffles suffice to get the 2 variatio distace through the cutoff ad close to 0. We have ow achieved our goal of costructig the variatio distace graph, which explais why seve shuffles are eough. I the remaiig sectios we preset some other aspects to shufflig, as well as some other ways of approachig the questio of how may shuffles should be doe to deck. 9 THE INVERSE SHUFFLE There is a ushufflig procedure which is i some sese the reverse of the riffle shuffle. It is actually simpler to describe, ad some of the theorems are more evidet i the reverse directio. Take a facedow deck, ad deal cards from the bottom of the deck oe at a time, placig the cards facedow ito oe of two piles. Make all the choices of which pile idepedetly ad uiformly, i.e. go 50/50 each way each time. The simply put oe pile o top of the other. This may be called the riffle ushuffle, ad the iduced desity o S may be labeled ˆR. A equivalet process is geerated by labelig the backs of all the cards with 0 s ad 1 s idepedetly ad uiformly, ad the pullig all the 0 s to the frot of the deck, maitaiig their relative order, ad pullig all the 1 s the back of the deck, maitaiig their relative order. This may quickly be geeralized to a aushuffle, which is described by labelig the back of each card idepedetly with a base a digit chose uiformly. Now place all the cards labeled 0 at the frot of the deck, maitaiig their relative order, the all the 1 s, ad so o, up through the (a 1) s. This is the aushuffle, deoted by ˆR a. We really have a reverse or iverse operatio i the sese that ˆR a (π) =R a (π 1 ) holds. This is see most easily by lookig at digit base a umbers. We have already see i sectio 6 that each such digit base a umber may be treated as a code for a particular cut ad iterleavig i a ashuffle; the above paragraph i effect gives a way of also treatig each digit base a umbers as code for a particular way of achievig a aushuffle. The two iduced permutatios we get whe lookig at a give digit base a umber i these two ways are iverse to oe aother, ad this proves ˆR a (π) =R a (π 1 ) sice the u iform desity o digit base a umbers iduces the right desity o S.
20 20 We give a particular example which makes the geeral case clear. Take the 9 digit base 3 code ad apply it i the forward directio, i.e. treat it as directios for a particular 3shuffle of the deck i atural order. We get the cut structure ad hece the shuffled deck Now apply the code to this deck order, but backwards, i.e. treat it as directios for a 3ushuffle of We get the cards where the 0 s are, 123, pulled forward; the the 1 s, 456; ad the the 2 s, 789, to get back to the aturally ordered deck It is clear from this example that, i geeral, the aushuffle directios for a give digit base a umber pull back the cards i a way exactly opposite to the way the ashuffle directios from that code distributed them. This may be checked by applyig the code both forwards ad backwards to the ushuffled deck ad gettig ( ) ( which ispectio shows are ideed iverse to oe aother. The advatage to usig ushuffles is that they motivate the A B &B formula i the proof of the multiplicatio theorem for a ashuffle followedbyabshuffle. Suppose you do a 2ushuffle by labelig the cards with 0 s ad 1 s i the upper right corer accordig to a uiform ad idepedet radom choice each time, ad the sortig the 0 s before the 1 s. The do a secod 2ushuffle by labelig the cards agai with 0 s ad 1 s, placed just to the left of the digit already o each card, ad sortig these leftmost 0 s before the leftmost 1 s. Reflectio shows that doig these two processes is equivalet to doig a sigle process: label each card with a 00, 01, 10, or 11 accordig to uiform ad idepedet choices, sort all cards labeled 00 ad 10 before all those labeled 01 ad 11, ad the sort all cards labeled 00 ad 01 before all those labeled 10 ad 11. I other words, sort accordig to the rightmost digit, ad the accordig to the leftmost digit. But this is the same as sortig the 00 s before the 01 s, the 01 s before the 10 s, ad the 10 s before the 11 s all at oce. So this sigle process is equivalet to the followig: label each card with a 0, 1, 2, or 3 accordig to uiform ad idepedet choices, ad sort the 0 s before the 1 s before the 2 s before the 3 s. But this is exactly a 4ushuffle! So two 2ushuffles are equivalet to a 2 2 = 4ushuffle, ad geeralizig i the obvious way, a bushuffle followed by a aushuffle is equivalet to a abushuffle. (I the case of ushuffles we have orders reversed ad write a bushuffle followed by a aushuffle, rather ),
SOME GEOMETRY IN HIGHDIMENSIONAL SPACES
SOME GEOMETRY IN HIGHDIMENSIONAL SPACES MATH 57A. Itroductio Our geometric ituitio is derived from threedimesioal space. Three coordiates suffice. May objects of iterest i aalysis, however, require far
More informationConsistency of Random Forests and Other Averaging Classifiers
Joural of Machie Learig Research 9 (2008) 20152033 Submitted 1/08; Revised 5/08; Published 9/08 Cosistecy of Radom Forests ad Other Averagig Classifiers Gérard Biau LSTA & LPMA Uiversité Pierre et Marie
More informationCrowds: Anonymity for Web Transactions
Crowds: Aoymity for Web Trasactios Michael K. Reiter ad Aviel D. Rubi AT&T Labs Research I this paper we itroduce a system called Crowds for protectig users aoymity o the worldwideweb. Crowds, amed for
More informationType Less, Find More: Fast Autocompletion Search with a Succinct Index
Type Less, Fid More: Fast Autocompletio Search with a Succict Idex Holger Bast MaxPlackIstitut für Iformatik Saarbrücke, Germay bast@mpiif.mpg.de Igmar Weber MaxPlackIstitut für Iformatik Saarbrücke,
More informationBOUNDED GAPS BETWEEN PRIMES
BOUNDED GAPS BETWEEN PRIMES ANDREW GRANVILLE Abstract. Recetly, Yitag Zhag proved the existece of a fiite boud B such that there are ifiitely may pairs p, p of cosecutive primes for which p p B. This ca
More information4. Trees. 4.1 Basics. Definition: A graph having no cycles is said to be acyclic. A forest is an acyclic graph.
4. Trees Oe of the importat classes of graphs is the trees. The importace of trees is evidet from their applicatios i various areas, especially theoretical computer sciece ad molecular evolutio. 4.1 Basics
More informationEverything You Always Wanted to Know about Copula Modeling but Were Afraid to Ask
Everythig You Always Wated to Kow about Copula Modelig but Were Afraid to Ask Christia Geest ad AeCatherie Favre 2 Abstract: This paper presets a itroductio to iferece for copula models, based o rak methods.
More informationStéphane Boucheron 1, Olivier Bousquet 2 and Gábor Lugosi 3
ESAIM: Probability ad Statistics URL: http://wwwemathfr/ps/ Will be set by the publisher THEORY OF CLASSIFICATION: A SURVEY OF SOME RECENT ADVANCES Stéphae Bouchero 1, Olivier Bousquet 2 ad Gábor Lugosi
More informationHow Has the Literature on Gini s Index Evolved in the Past 80 Years?
How Has the Literature o Gii s Idex Evolved i the Past 80 Years? Kua Xu Departmet of Ecoomics Dalhousie Uiversity Halifax, Nova Scotia Caada B3H 3J5 Jauary 2004 The author started this survey paper whe
More informationTeaching Bayesian Reasoning in Less Than Two Hours
Joural of Experimetal Psychology: Geeral 21, Vol., No. 3, 4 Copyright 21 by the America Psychological Associatio, Ic. 963445/1/S5. DOI: 1.7//963445..3. Teachig Bayesia Reasoig i Less Tha Two Hours Peter
More informationSystemic Risk and Stability in Financial Networks
America Ecoomic Review 2015, 105(2): 564 608 http://dx.doi.org/10.1257/aer.20130456 Systemic Risk ad Stability i Fiacial Networks By Daro Acemoglu, Asuma Ozdaglar, ad Alireza TahbazSalehi * This paper
More informationJ. J. Kennedy, 1 N. A. Rayner, 1 R. O. Smith, 2 D. E. Parker, 1 and M. Saunby 1. 1. Introduction
Reassessig biases ad other ucertaities i seasurface temperature observatios measured i situ sice 85, part : measuremet ad samplig ucertaities J. J. Keedy, N. A. Rayer, R. O. Smith, D. E. Parker, ad M.
More informationON THE EVOLUTION OF RANDOM GRAPHS by P. ERDŐS and A. RÉNYI. Introduction
ON THE EVOLUTION OF RANDOM GRAPHS by P. ERDŐS ad A. RÉNYI Itroductio Dedicated to Professor P. Turá at his 50th birthday. Our aim is to study the probable structure of a radom graph r N which has give
More informationDryad: Distributed DataParallel Programs from Sequential Building Blocks
Dryad: Distributed DataParallel Programs from Sequetial uildig locks Michael Isard Microsoft esearch, Silico Valley drew irrell Microsoft esearch, Silico Valley Mihai udiu Microsoft esearch, Silico Valley
More informationAdverse Health Care Events Reporting System: What have we learned?
Adverse Health Care Evets Reportig System: What have we leared? 5year REVIEW Jauary 2009 For More Iformatio: Miesota Departmet of Health Divisio of Health Policy P.O. Box 64882 85 East Seveth Place, Suite
More informationSpinout Companies. A Researcher s Guide
Spiout Compaies A Researcher s Guide Cotets Itroductio 2 Sectio 1 Why create a spiout compay? 4 Sectio 2 Itellectual Property 10 Sectio 3 Compay Structure 15 Sectio 4 Shareholders ad Directors 19 Sectio
More informationNo One Benefits. How teacher pension systems are failing BOTH teachers and taxpayers
No Oe Beefits How teacher pesio systems are failig BOTH teachers ad taxpayers Authors Kathry M. Doherty, Sadi Jacobs ad Trisha M. Madde Pricipal Fudig The Bill ad Melida Gates Foudatio ad the Joyce Foudatio.
More informationThe Arithmetic of Investment Expenses
Fiacial Aalysts Joural Volume 69 Number 2 2013 CFA Istitute The Arithmetic of Ivestmet Expeses William F. Sharpe Recet regulatory chages have brought a reewed focus o the impact of ivestmet expeses o ivestors
More informationare new doctors safe to practise?
Be prepared: are ew doctors safe to practise? Cotets What we foud 02 Why we ve writte this report 04 What is preparedess ad how ca it be measured? 06 How well prepared are medical graduates? 08 How has
More informationThe Unicorn, The Normal Curve, and Other Improbable Creatures
Psychological Bulleti 1989, Vol. 105. No.1, 156166 The Uicor, The Normal Curve, ad Other Improbable Creatures Theodore Micceri 1 Departmet of Educatioal Leadership Uiversity of South Florida A ivestigatio
More informationHOMEBUYING STEP BY STEP. A Consumer Guide and Workbook
HOMEBUYING STEP BY STEP A Cosumer Guide ad Workbook CMHC HOME TO CANADIANS Caada Mortgage ad Housig Corporatio (CMHC) has bee Caada s atioal housig agecy for more tha 65 years. Together with other housig
More informationTesting for Welfare Comparisons when Populations Differ in Size
Cahier de recherche/workig Paper 039 Testig for Welfare Comparisos whe Populatios Differ i Size JeaYves Duclos Agès Zabsoré Septembre/September 200 Duclos: Départemet d écoomique, PEP ad CIRPÉE, Uiversité
More informationWhich Extreme Values Are Really Extreme?
Which Extreme Values Are Really Extreme? JESÚS GONZALO Uiversidad Carlos III de Madrid JOSÉ OLMO Uiversidad Carlos III de Madrid abstract We defie the extreme values of ay radom sample of size from a distributio
More informationSignal Reconstruction from Noisy Random Projections
Sigal Recostructio from Noisy Radom Projectios Jarvis Haut ad Robert Nowak Deartmet of Electrical ad Comuter Egieerig Uiversity of WiscosiMadiso March, 005; Revised February, 006 Abstract Recet results
More informationCatalogue no. 62557XPB Your Guide to the Consumer Price Index
Catalogue o. 62557XPB Your Guide to the Cosumer Price Idex (Texte fraçais au verso) Statistics Caada Statistique Caada Data i may forms Statistics Caada dissemiates data i a variety of forms. I additio
More informationChild. Is Missing: When Your. A Family Survival Guide
U.S. Departmet of Justice Office of Justice Programs Office of Juveile Justice ad Deliquecy Prevetio you are ot aloe; families ca ad do survive there is o right or wrog way to respod; there is o right
More informationController Area Network (CAN) Schedulability Analysis with FIFO queues
Cotroller Area Network (CAN) Schedulability Aalysis with FIFO queues Robert I. Davis RealTie Systes Research Group, Departet of Coputer Sciece, Uiversity of York, YO10 5DD, York, UK rob.davis@cs.york.ac.uk
More informationSupporting medical students with mental health conditions
Supportig medical studets with metal health coditios Supportig medical studets with metal health coditios Cotets 02 Geeral Medical Coucil Supportig medical studets with metal health coditios Published
More informationNo Eigenvalues Outside the Support of the Limiting Spectral Distribution of Large Dimensional Sample Covariance Matrices
No igevalues Outside the Support of the Limitig Spectral Distributio of Large Dimesioal Sample Covariace Matrices By Z.D. Bai ad Jack W. Silverstei 2 Natioal Uiversity of Sigapore ad North Carolia State
More informationTurning Brownfields into Greenspaces: Examining Incentives and Barriers to Revitalization
Turig Browfields ito Greespaces: Examiig Icetives ad Barriers to Revitalizatio Juha Siikamäki Resources for the Future Kris Werstedt Virgiia Tech Uiversity Abstract This study employs iterviews, documet
More information