What is the optimum number of shuffles to randomize any size deck of cards?
For a standard deck of 52 cards, the famous answer, of course, is seven. Wikipedia discusses this answer and presents an alternative.
I assume larger decks would require more shuffles. Is there a formula or a rule of thumb that correlates the size of the deck with the number of shuffles required for good randomization?
Perfectly consistent shuffles will bring the deck back to its initial position eventually. For example, a perfect alternating shuffle in which the top and bottom cards remain in position will bring the deck back to its exact initial position after exactly 8 shuffles. (I’ve heard that some magicians can do this! To be clear, the shuffle just described changes the deck 1-2-3-4-5-… to 1-27-2-28-3-…) The other way to do a perfectly alternating shuffle (change deck to 27-1-28-2-29-…) will restore the deck after, I think, 52 shuffles.
More than once I’ve heard the claim that seven imperfect shuffles is “optimal” (in the sense that an 8th shuffle would leave the deck less random). I don’t know if there’s any basis to it; perhaps the idea is derived by simulating imperfect shuffles, but of course some human shufflers are more imperfect than others.
The idea that an eighth shuffle is bad might derive from the fact that a magician can restore the deck with 8 perfect shuffles, but of course after seven such perfect shuffles, the deck won’t be random at all. (It will be 1-3-5-7-9-…)
When you shuffle, a card needs to have had a chance to have moved to any other position in the deck. When you halve and merge, the card could only have moved halfway. Halve again and the card could have moved 75% of the way. After six shuffles, it could have moved 98.4375%. Multiplied by 52 cards, that’s only 51.1875, you need one more shuffle to get a number that rounds up to 52 (51.59375).
Your formula, assuming I’m right, would be:
(1 - 0.5^n) * x >= x - 0.5
Where n is the number of shuffles and x is the number of cards. Solve for n.
I presume that we’re talking about imperfect shuffles. Perfect shuffles are simply a bad idea for randomization, no matter how many of them are used. I don’t believe the claim that seven imperfect shuffles is optimal. Do you have a citation for that?
I’ve done it once (doing all the shuffles tediously by hand to make sure they were perfect).
And if the cards are in such a state that an additional shuffle will make them apparently less random, then they weren’t ever random to begin with. Without looking at the cards and making decisions about them, you can never get them any less random.
In the links from the wikipedia page, the shuffles they use are the Gilbert-Shannon-Reeds (GSR) riffle shuffle. A deck is divided into two piles (by the binomial distribution), of sizes A and B, and when combined the probability that the next card to to drop from the A or B pack is A/(A+B) or B/(A+B) respectively (so you don’t have a deterministic shuffle).
This PDF link (from the wiki article) shows that 7 GSR shuffles are not enough in all cases to be equivalent to a uniformly shuffled 52 card deck. They don’t seem to say how many shuffles are needed.
(I wrote “I think” out of (false?) humility. Where did you come up with your over-confident 14? )
And, athough we need not digress into Kolmogorov Complexity theory, the simple answer to your 2nd question is that “random” is, at best, ambiguous in this context.
As to a citation for the claim that an 8th shuffle may reduce “randomness,” I don’t have one. I heard the claim from a PhD student in information theory describing a paper he’d just read, and I’ve heard the claim elsewhere as well. But I’m quite prepared to believe these claimants (incl. the PhD student) are misinformed. Note however that it isn’t completely implausible: after all, the deck may look quite random after 4 of the magician’s shuffle, even though 4 more restore it.
A perfect shuffle is not a randomization device. It changes the ordering in a very specific and ordered manner. Not surprisingly then, it turns out that there is a cycle within the group of all the transpositions of the cards so that the 52nd power of a perfect shuffle is the identity transposition. An inperfect shuffle doesn’t have any simple structure though. Note that there are a vast number of possible imperfect shuffles. I can’t see any way that eight imperfect shuffles would be less random on average than seven of them.
Let me repeat my position. The claim is one of I’ve heard, not made. Nevertheless:
If one models an “imperfect shuffle” as a “noisy” perfect shuffle, then the model might produce a result similar to that in the peculiar claim. My guess is that the noise (deviation from “perfection”) would have to be rather small to see the effect: certainly smaller than the noise in my own imperfect shuffles.
To save a round of pointless surrejoinders, let me point out the the claim almost certainly holds if the modeled imperfect shuffle is the “magician’s shuffle” (defined upthread) with a sufficently tiny level of noise.
So you’re defining something like an almost perfect shuffle which is a perfect shuffle with one (or whatever) change and you’re claiming that it might satisfy this condition of having more order after eight shuffles than after seven shuffles. That’s possible, I suppose, but I doubt it, based on my knowledge of randomization. I’m trying to answer the question in the OP, not some odd variation of it. The OP is presumably talking about imperfect shuffles, not perfect ones or almost perfect ones (assuming that such things actually exist). For imperfect shuffles, eight shuffles will be more random than seven shuffles.
If you ignore suits, there are only 13 unique cards. An imperfect shuffle could get you farthest from having the cards ordered by number near 6 or 7 (roughly 13/2 shuffles). Going to 8 shuffles then takes you closer to 13, where the cards are ordered again (although the ordering is different than what you started with when you include suits).
The best way to randomize a deck of cards (or anything else) is to not do the same thing over and over. Here’s a technique that will quickly randomize them. Admittedly, most regular card players are going to be irritated by you doing this, but it will be the surest way to randomize them. In the following, when I say shuffle the cards together, assume that I always mean imperfect shuffles except when I mention otherwise:
Shuffle the cards once. Splilt the deck into a half dozen (or so) smaller piles. Grab random pairs of the piles and, for each pair, shuffle the two piles together. Shuffle all the remaining piles together. Shuffle the cards again. Do this half a dozen times. Feel free to intersperse with other ways of randomization. For instance, grab a few cards from the top and push them into the middle. Grab a few cards from the bottom and push them into the middle. Or lay out a dozen or so piles from the deck and randomly stack them together again.
The reason that most card players like ordinary imperfect shuffles is that it’s a single, fast way that in most cases is good enough. They don’t like strange techniques that they haven’t seen before. They expect (possibly incorrectly) that the people that they play with aren’t dexterous enough to do a perfect shuffle. They expect (possibly incorrectly) that a single imperfect shuffle will be good enough.
Once when I was bored, I took a deck of cards in order, counted out exactly 26, and then played out cards one at a time, alternately from each side of the deck, in such a way as to exactly simulate a perfect shuffle. I repeated this process exactly 14 times, and ended up with the deck back in order.
Or at least, that’s what I thought happened, though I’m having trouble reconciling that with your convincing demonstration there. It’s possible that, first of all, I miscounted the number of shuffles I made, and second of all, that I got the cards into a different state than the original, but one which was equally-ordered.
Out of curiosity I tried to reconstruct what your 14th shuffle produced. I may as well report the results.
(I don’t know what SD policy is on long boring posts, but at least mine is more factual than the typical collection of political or global-warming half-truths over in the GD forum. To make this message look less tedious, I’ll place the details inside a “Spoiler”.)
As mentioned earlier, there are two flavors of alternating shuffle, one with 52-cycle, one with 8-cycle. Perhaps you accidentally mixed the two flavors. Color me lazy if you wish, but I did not simulate all such mixtures to look for one with a 14-cycle.
By the way, I also did the experiment I suggested about slightly noisy shuffles. To observe significant non-randomness after 8 shuffles, I had to set the noise so low that the 7th shuffle also produced significant non-randomness. (I was using a very crude randomness measure.) Checking a link posted in this thread I see mention of a 1992 paper, which would have been just the right timeframe for the excited PhD student I remember. I now suspect he either misinterpreted the paper, or I misinterpreted his comment.
And from looking at that output, it looks like the only other time in the cycle when it looks “ordered” is after 26 shuffles, when the deck is reversed. There’s also the possibility that I started with the deck ordered 1C 1D 1H 1S 2C 2D 2H 2S etc., but we can consider that possibility just by looking at shuffles 2-54 in your list, instead of 0-52, which leads to the same cycle, just with a different starting point in it.
And I don’t expect any more effort from you on this (you’ve already put forth a heroic showing), but now I’m really wondering what the heck it was that I did that got me that 14.
Far be it from me to suggest that you’re not playing with a full deck… but decks of 42, 43, and 44 cards have period 14 for at least one of the flavors of perfect shuffle. (As do decks of 128, 129, and 130 cards.)
I find no patterns of 14 mixed-flavor shuffles that return a 52-card deck to its original state.
Which should be obvious after a moment’s thought, given that it’s the equivalent to setting the top and bottom cards aside and doing an out-shuffle on the rest.