On spiral shuffles

card-gamesprobability

I'm writting a program that shuffles the cards using a Mexican spiral shuffle. In my case the number of unique cards is arbitrarily large but let's assume for the sake of simplicity that there are only 52 unique cards. The experiment is the following:

  1. Given a deck of 52 cards shuffle them (Collections.shuffle(cards)) – this a Java shuffling library and it has nothing to do with the Mexican spiral shuffle, I just used this one so that my results can be more randomized. Let's assume that this randomized order of cards is the original order
  2. After having a randomized list of cards start applying the Mexican spiral shuffle.
  3. Keep applying the Mexican spiral shuffle until we reach the original order again. Once the hand deck is empty, take the table deck and repeat the shuffle. This designates one iteration of the shuffle.

I am making the following observation and I cannot really explain it. For a given number of cards the number of rounds required to reach the original order is fixed. For example, for a 52 card deck we need 510 rounds of a Mexical spiral shuffle to reach the original order. Irrespective of the order of cards in the original state. No matter how many times I run the simulation the results are the same.

To my understanding there are 52! permutations of the deck's state after the shuffle and I'm quite sure that we cannot reach all of them with the same probability. If this is the case how can the number of rounds for reaching the original order is always the same for a given number of cards?

Best Answer

The Mexican Spiral shuffle is a permutation of $52$ (or $n$) items. You can find the order of the permutation, the number of repetitions that make it do nothing, by taking the lowest common multiple of its cycle lengths.

The shuffle is somewhat complex, so I don't think there is a simple formula based on the number of cards $n$. But you can just do the shuffle once on an ordered deck of n cards, examine the result to find its cycles, and then calculate the order from that.

Here is an example. I'll use $9$ cards.

The cards start off as ABCDEFGHI, where A is the top card. A single mexican spiral shuffle affects the cards like this:

ABCDEFGHI
DFHB IGECA
FB HDIGECA
BFHDIGECA

So the end results is that card A went to the location of I, and card I went to the location of E, and so on. We get the following cycles:

A$\rightarrow$I$\rightarrow$E$\rightarrow$G$\rightarrow$F$\rightarrow$B$\rightarrow$A
C$\rightarrow$H$\rightarrow$C
D$\rightarrow$D

These cycles have lengths $6$, $2$, and $1$. The lowest common multiple of these lengths is $6$, so it takes $6$ shuffles for the cards to return to their original order.

If you do this with $52$ cards you'll find that the top card is part of a cycle of length $34$, the second card is in a cycle of length $10$, the fifth card is in a cycle of length $6$, and finally the 12th and 35th cards don't move (i.e. cycles of length $1$). The LCM of $34,10,6,1,1$ is $510$.

Related Question