## Some Cards Stuff

I’m not good at shuffling cards. I can eventually scramble up a deck tolerably well, given time, but I can’t do a good riffle shuffle. Nor can I do any of the moves that show competence at card-shuffling. That thing where people make a little semicircular arch of cards in their hands? I can’t even understand how that works, never mind do it myself.

That said, I do know how many shuffles it takes to randomize a deck of cards. I mean a standard deck of 52. It’s seven. I learned that ages ago, but never saw it proved. Best I could work out was that each shuffling would, if done perfectly, mix the upper and lower halves of the old deck. So I want what had been (say) the first and second card to be mixed up arbitrarily far from one another. One shuffle might get one or two cards between the old first and second. Two shuffles might double that; three shuffles that again, and so on. By six shuffles there could be anywhere up to 64 cards between the first and second, and that’s … surely enough, right? Then one more for good luck? It’s not rigorous but you can see where that satisfies.

The Probability Fact of the Day tweet above gives a real explanation. It links to the paper Trailing the Dovetail Shuffle to its Lair, by Dr Dave Bayer and Dr Persi Diaconis. It first appeared in the Annals of Applied Probability, 1992, Vol 2, Number 2, 294 – 313. It gives an actual proof of why seven shuffles are what’s needed.

I’m sad to admit the paper isn’t one you can jump into without mathematical training. Even the symbols may seem bizarre: it uses π not for that thing to do with circles. Instead it’s used as a variable name, the way we might use ‘x’ in ordinary algebra. In this context it stands for ‘permutation’. That’s a standard thing to do in this field of mathematics. It just looks funny if you’re coming in cold.

A permutation, here, means how you change the order of things. For example, suppose we start out with five things, which I’ll label with the letters of the alphabet. Suppose they start out in the order A B C D E. (We could use other labels, but letters are convenient.) I can apply a permutation π to this ordered list of letters. Suppose that afterwards they end up in the order C A B E D. Then the permutation π did this: it moved the first thing to the second spot. It moved the second thing to the third spot. It moved the third thing to the first spot. It moved the fourth thing to the fifth spot. It moved the fifth thing to the fourth spot. There are several ways to describe this efficiently. I could say, for example, that the permutation π is (2 3 1 5 4). (If you don’t see why that works, think about it a while.) There’s other ways to write this. We don’t need them just now.

You can chain permutations together. If we did the same swapping of order on C A B E D, we would get the list B C A D E. That’s the same list we would have gotten if we had started with A B C D E and done a *different* permutation once. It’s what we would get if we had done (3 1 2 4 5). We can think of this as what you get if we “multiply” π by π. Permutations, these directions of how to shuffle a list of things, can work a lot like numbers.

There’s more interesting things in here, even if you don’t follow the argument. I admit I get lost somewhere in section 3. I’m hoping someone asks me about the baker’s transformation. But it does describe some impressive-sounding magic tricks to be done with a slightly shuffled deck. And it gives this great puzzle, as well as answering it.

Suppose someone has a well-shuffled deck of cards. She deals them one at a time. You try to guess what card is coming up next. And you never make the foolish mistake of predicting a card that’s already come up. Most of the time you’ll be wrong. But at least you’ll end on a success. After 51 cards have been dealt you will call the final one right.

How many cards would you expect, on average, to call correctly, out of these 52?

## scifihammy 3:52 pm

onSaturday, 20 February, 2016 Permalink |Interesting about the card shuffling :)

And I’m going to guess you predict 5 correctly on average.

LikeLike

## Joseph Nebus 4:00 am

onTuesday, 23 February, 2016 Permalink |Great guess. You’re almost dead on.

LikeLiked by 1 person

## Chiaroscuro 4:11 pm

onSaturday, 20 February, 2016 Permalink |So, lessee. Odds of the first card: 1/52. Odds of the second: 1/51. Etc, to the last card, which is 1+1. Now, we add that up. There’s likely nice shortcuts here involving factorials, but I’ve got Windows Calculator here, and it goes so much faster now that I realize the number pad on my keyboard puts numbers into the calculator. (2012 is a perfectly reasonable year to figure this out so shut up.)

I get 4.538 cards out of 52, including the sure thing of card #52.

LikeLike

## Joseph Nebus 4:02 am

onTuesday, 23 February, 2016 Permalink |Run exactly right, well done.

I didn’t know that about Windows Calculator, but I keep an Octave window open all the time to do my calculations. In that the computation would just be sum(1./(1:52)). (That works for Matlab too.)

LikeLike

## How February 2016 Treated My Mathematics Blog | nebusresearch 9:18 pm

onTuesday, 1 March, 2016 Permalink |[…] Some Cards Stuff (pointing to a proof about how much shuffling a deck of cards needs) […]

LikeLike