Party Groups

ExpectationRecursionRandom PermutationsHarmonic Numbers

Problem

There are guests at a party and they are making groups for a game. To do this they each write their name on a piece of paper and put it into a hat. One by one, each guest picks a name from the hat. Each guest will be a part of a group with the guest they pulled the name out of from the hat. If a guest pulls out their own name, they are in a group all by themselves. If Guest A pulls out Guest B's name, Guest B pulls out Guest C's name, and Guest C pulls out Guest A's name, they are all a part of the same closed group and no one else will be able to join them. How many groups will there be on average? Round your answer to the nearest tenth.


Original Problem Link: https://www.quantguide.io/questions/party-groups

Solution

We could, in principle, list out every possible way the names get drawn and count the groups in each. But with guests that's outcomes, and even organizing them by group structure is tedious. So instead, let's think recursively.

Step 1: Setting up the recursion

Let be the expected number of groups when there are guests.

Say we already have people, and they formed groups on average. Now an th person shows up. What can happen to the group count? Only two things:

  1. He makes a new group, with only him in it. This happens exactly when he pulls out his own name. The count goes up by .
  2. He joins an existing group. Someone's chain now passes through him before closing, so he slots into a group that was already there. The count doesn't change.

So if we can compute the probability of him making a new group, we get a recurrence in !

Step 2: What's the probability he picks his own name?

Here's the catch: we don't know when he draws. He could be the first to pick from the hat, or the last, or anywhere in between, and every position among is equally likely. So let's work it out position by position.

  • He picks first. All names are in the hat, so he draws his own with probability
  • He picks second. The first guest must not take his name, and then he must draw it from the left:
  • He picks third. Neither of the first two may take his name, then he draws it from the left:
  • He picks fourth. Same idea, one more factor:

Every time, the product telescopes. In general, if he picks th,

So every position gives . And each position itself happens with probability , so adding up over all positions,

Weird, but interesting! No matter where he sits in the drawing order, his own name ends up in his hand with probability exactly . (In hindsight this is symmetry at work: his slip is equally likely to end up in any of the hands, and one of those is his.)

Step 3: The recurrence

One subtle point before we write it down. In case 2, does joining a group really leave the other people's groups "untouched on average"? Yes: if he pulled out someone else's name, just splice him out of his chain (whoever drew his name now points to whoever he drew). That gives a valid drawing for the other guests with exactly the same number of groups, and every such drawing comes up equally often. So in both cases, the other guests contribute groups on average.

Conditioning on whether he picks his own name,

Each new guest adds exactly groups on average. Clean!

Step 4: Base case and unrolling

Base case? Of course: with there's one guest, who pulls out his own name, so (only 1 group possible lol).

Quick sanity check at : either both guests draw their own names ( groups) or they swap ( group), each with probability , so . The recurrence agrees: . ✓

Unrolling all the way up,

the th harmonic number. It has no neat closed form, so we let a computer add it up:

(As a rough check, , and .) Rounded to the nearest tenth, that's .

Thus, there will be about groups on average

View as Markdown (with the LaTeX source)