Last time we solved some probability puzzles involving coin flips. This time we’ll look at puzzles involving cards.

### Permutations

**Example 1.** How many ways are there to order 3 cards: a jack (J), a queen (Q), and a king (K)?

By **order** them I mean put one on top, then one in the middle, then one on the bottom. There are three choices for the first card: it can be A, Q, or K. That leaves two choices for what the second card can be, and just one for the third. So, there are

ways to order the cards.

**Example 2.** How many ways are there to order all 52 cards in an ordinary deck?

By the same reasoning, the answer is

This is a huge number. We call it 52 **factorial**, or 52! for short. I guess the exclamation mark emphasizes how huge this number is. In fact

This is smaller than the number of atoms in the observable universe, which is about But it’s much bigger than the number of galaxies in the observable universe, which is about , or even the number of stars in the observable universe, which is roughly It’s impressive that we can hold such a big number in our hand… in the form of possible ways to order a deck of cards!

### A well-shuffled deck

**Definition 1.** We say a deck is **well-shuffled** if each of the possible ways of ordering the cards in the deck has the same probability.

**Example 3.** If a deck of cards is well-shuffled, what’s the probability that it’s in this order?

Since all orders have the same probability, and there are of them, the probability that they’re in *any* particular order is

So, the answer is

### A hand from a well-shuffled deck

Suppose you take the top cards from a well-shuffled deck of cards. You’ll get a subset of cards—though card players call this a **hand** of cards instead of a subset. And, there are choose possible hands you could get! Remember from last time:

**Definition 2.** The **binomial coefficient**

called ** choose ** is the number of ways of choosing a subset of things from a set of things.

I guess card-players call a set a ‘deck’, and a subset a ‘hand’. But now we can write a cool new formula for choose Just multiply the top and bottom of that big fraction by

We get

I won’t do it here, but here’s something you can prove using stuff I’ve told you. Suppose you have a well-shuffled deck of cards and you draw a hand of cards. Then each of these hands is equally probable!

Using this we can solve lots of puzzles.

**Example 4.** If you draw a hand of 5 cards from a well-shuffled standard deck, what’s the probability that you get the 10, jack, queen, king and ace of spades?

Since I’m claiming that all hands are equally probable, we just need to count the number of hands, and take the reciprocal of that.

There are

5-card hands drawn from a 52-card deck. So, the probability of getting any particular hand is

We can simplify this a bit since 50 is 5 × 10 and 48 is twice 4 × 3 × 2 × 1. So, the probability is

### A royal flush

The hand we just saw:

is an example of a ‘royal flush’… the best kind of hand in poker!

**Definition 3.** A **straight** is a hand of five cards that can be arranged in a consecutive sequence, for example:

**Definition 4.** A **straight flush** is a straight whose cards are all of the same suit, for example:

**Definition 5.** A **royal flush** is a straight flush where the cards go from 10 to ace, for example:

**Example 5.** If you draw a 5-card hand from a standard deck, what is the probability that it is a royal flush?

We have seen that each 5-card hand has probability

There are just 4 royal flushes, one for each suit. So, the probability of getting a royal flush is

### Puzzles

Suppose you have a well-shuffled standard deck of 52 cards, and you draw a hand of 5 cards.

**Puzzle 1.** What is the probability that the hand is a straight flush?

**Puzzle 2.** What is the probability that the hand is a straight flush but not a royal flush?

**Puzzle 3.** What is the probability that the hand is a straight?

**Puzzle 4.** What is the probability that the hand is a straight but not a straight flush?

The hard part seems to be the shuffling – if we start from an ordered deck and do some standard shuffling how close will the deck be to a well-shuffled state?

There’s been a lot of research on this, with Persi Diaconis playing a leading role. Here’s a good quick overview with references:

• Shuffling playing cards – research, Wikipedia.

A rough rule of thumb is ‘7 riffle shuffles are enough’. But the details are complex and fascinating.

8 riffle shuffles may not shuffle at all.

http://en.wikipedia.org/wiki/Out_shuffle

Cool! These are ‘perfect’ shuffles, where you interleave the cards in a perfectly alternating way. And yet again, Diaconis seems to be behind this result:

• Persi Diaconis, Ronald Graham and William M. Kantor, The mathematics of perfect shuffles,

Advances in Applied Mathematics4(1983), 175–196.There are two kinds of perfect shuffles:

outshuffles, where the top card stays on top, andinshuffles, where it doesn’t. Here’s a wacky result from this paper: you have a deck of 24 cards, the group of permutations generated by in and out shuffles is the semidirect product of and the Mathieu groupThis Mathieu group is an amazing group with 12 × 11 × 10 × 9 × 8 = 95,040 elements. It acts in a

sharply quintuply transitiveway on a 12-element set, meaning that you can take any 5-tuple of distinct elements of that set and find a unique element of the group that maps it to any other 5-tuple of distinct elements! Apart from symmetric and alternating groups, there are only a few groups that are k-tuply transitive for k > 3, so this group is very special. This group is also ‘simple’, meaning that it doesn’t have any nontrivial normal subgroups. There’s also a cool description of this group in terms of 12 balls rolling on a ball of the same size!Ronald Graham is the guy that Graham’s number is named after. Diaconis and Graham won a writing prize at the Joint Mathematics Meetings in San Diego this January. Upon accepting the prize they played a card trick. I later asked Graham about the somewhat mysterious story behind Graham’s number, and he clarified it.

Ok, I give up, you win the Cool Maths of Shuffling Game.

Sorry, I’m a showoff… but I only learned this Cool Maths of Shuffling by checking out your reference and finding that paper by Diaconis on perfect shuffles. And I got so excited by this new appearance of the Mathieu group that I posted this! So thanks.

Note that an important point is that in most real games you’re not starting from just some ordered deck of cards, but because of patterns of play in the previous game (hands of whist, games of poker, etc, depending on the game) “high value” cards will be clustered together. This tends to mean that if there are also imperfections in the rifling they’re less likely to be separated and then the tend to get redistributed fairly evenly by a “rotating round the table” deal. So real shuffles+dealings tend to be more “balanced” than genuinely random selections, which have more very good and very bad hands.