Probability

Any unevenness brings the match sooner

Real birthdays are not spread evenly across the year, and every such departure pushes the famous twenty-three down rather than up. The proof is one move on two days at a time, and what it leaves behind is a single number — the one ecologists use to count species.

Worth reading first: Twenty-three people.

Twenty-three people is the answer for a year in which every day is equally likely to be somebody’s birthday, and no year is like that. Births bunch in late summer in much of the northern hemisphere, thin out at weekends wherever deliveries are scheduled, and avoid public holidays for the same reason. The calculation that produces twenty-three assumes all of that away.

The standard remark is that the assumption is conservative: unevenness can only make a shared birthday more likely, so twenty-three is an upper bound for real rooms. It is a claim worth checking rather than repeating, because it is not obvious in the way it sounds. An uneven calendar has busy days, where collisions pile up, and quiet days, where they become rarer. That the busy days always win — for every calendar, every room size, every shape of unevenness — is a theorem, and it has a short proof with a picture in it.

A year of birthdays with a seasonal swing of ±10%, peaking in September. Bars for the 365 days of a model calendar with a seasonal swing of ±10%, peaking in September, drawn as each day's excess or shortfall against an even year. A shared birthday among 23 people has chance 50.90% against 50.73% for the even year, the first group with an even chance is 23, and the calendar behaves like 363.2 equally likely days.
Fig. 1 A model year whose births swing ten per cent above and below the average, busiest in mid-September. The chance of a match among twenty-three people moves from 50.73%50.73\% to 50.90%50.90\%, and the first even chance is still at twenty-three.

A swing of ten per cent either way is roughly the size of the seasonal effect in national birth records, and it moves the answer in the second decimal place. That is the first thing worth knowing: the famous number is robust. The second is the direction, which never reverses, and the rest of this essay is why.

The chance of no match, for any calendar

The even-year calculation deals people in one at a time and asks each to avoid the days already taken. That works because every day has the same weight, so “avoid jj taken days” has the same probability whichever days they are. On an uneven calendar it does not, and the product breaks.

The repair is to count configurations instead. Label the days 11 to dd with probabilities p1,,pdp_1, \dots, p_d. The chance that kk people land on kk different days, in some order, is the sum over every set of kk distinct days of the product of their probabilities, times the k!k! orders in which the people could have been assigned to them:

Pr(all different)=k!  ek(p1,,pd),\Pr(\text{all different}) = k!\; e_k(p_1, \dots, p_d),

where eke_k is the elementary symmetric polynomial — the sum of all products of kk distinct pp’s. It is the coefficient of xkx^k in (1+p1x)(1+p2x)(1+pdx)(1 + p_1 x)(1 + p_2 x)\cdots(1 + p_d x), which is how it is computed: multiply in one day at a time, keep the first k+1k+1 coefficients, and the exact answer comes out for any calendar at all.

On an even year every pip_i is 1/d1/d, the polynomial is (dk)dk\binom{d}{k} d^{-k}, and k!k! times that is the familiar product ddd1ddk+1d\tfrac{d}{d}\cdot\tfrac{d-1}{d}\cdots\tfrac{d-k+1}{d}. The figures hold the two computations to each other at every size they draw.

A year of birthdays with two days in seven at 75% of the rest. Bars for the 365 days of a model calendar with two days in seven at 75% of the rest, drawn as each day's excess or shortfall against an even year. A shared birthday among 23 people has chance 51.24% against 50.73% for the even year, the first group with an even chance is 23, and the calendar behaves like 359.7 equally likely days.
Fig. 2 A different shape of unevenness: two days in every seven carry three quarters of the births of the other five, the pattern scheduled deliveries produce. The chance at twenty-three rises to 51.24%51.24\% — more than the seasonal swing achieved, from a pattern that looks milder on the page.

The weekly calendar is worth a second look, because it shows that the eye is a poor judge of which unevenness matters. The seasonal bars sweep dramatically across the year; the weekly ones are a fine comb that reads almost as noise. The comb does more. What decides the size of the effect turns out not to be how dramatic the pattern looks but how far each individual day sits from the average — and every weekend day in that calendar is a full fifth below it, while most seasonal days are within a few per cent.

Moving the share between two days

Here is the move the proof is built from. Take any calendar, pick two days aa and bb, and leave every other day alone. Their combined share s=pa+pbs = p_a + p_b is fixed; only the split between them changes.

Every term of eke_k contains both of those days, exactly one, or neither. So it can be written as

ek=papbEk2+(pa+pb)Ek1+Ek,e_k = p_a p_b \, E_{k-2} + (p_a + p_b)\, E_{k-1} + E_k,

where the EE’s are symmetric polynomials of the other days and do not move. The middle term sees only the sum, which is fixed. The last term sees neither day. The split enters only through the product papbp_a p_b, and a product of two numbers with a fixed sum is largest when they are equal.

Two days sharing 20.0% of the births between them. The chance that 4 people from a 12-slot calendar all differ, as the combined share of two slots is moved from one to the other. The curve is a downward parabola, highest when the two shares are equal: 0.513 at the calendar's own split against 0.530 at the even one.
Fig. 3 A twelve-slot calendar in which two slots share a fifth of all births, three to one. Moving that fifth between them traces the chance that four people all differ as a downward parabola: 0.5130.513 at the uneven split, 0.5300.530 when the two slots are equal. No other split does better, and every split does better than one further from equal.

The curve is a parabola because papb=(s/2)2t2p_a p_b = (s/2)^2 - t^2 when the imbalance is written papb=2tp_a - p_b = 2t. Its second differences are constant and its top is at the even split, which the figure computes directly rather than trusting the algebra.

So evening out any two days never lowers the chance that everybody differs, and raises it strictly whenever the two were unequal and Ek2E_{k-2} is positive — which it is whenever at least k2k-2 other days are possible at all. Read in the other direction: making any two days less equal never lowers the chance of a match.

From two days to the whole calendar

One move on two days is not yet a theorem about calendars, and the step from one to the other is where a hurried version of this argument goes wrong.

It is tempting to say: keep averaging pairs of days until the calendar is flat. Repeated averaging does drive a calendar toward uniform, but it never arrives in finitely many steps, and an argument that needs a limit needs continuity to carry the inequality across. It is available — eke_k is a polynomial — but there is a cleaner route that avoids the process altogether.

The set of all calendars on dd days is a closed, bounded region: non-negative numbers adding to one. A continuous function on such a region attains its maximum somewhere. Take a calendar where the chance of all-different is as large as it can be. If any two of its days were unequal, averaging them would make it strictly larger, contradicting maximality. So every pair is equal, which means the maximum is the even year and nowhere else.

That is the whole theorem. For every room size kk up to the number of days and every calendar, the chance of a shared birthday is at least the even-year value, with equality only on the even year. Twenty-three is therefore an upper bound on the threshold for any population whatever, and a room drawn from a real one needs twenty-three people or fewer.

Nothing in the argument mentions seasons, weekends or any particular shape. It never needed to. The only fact it uses is that the probability of all-different is a symmetric function that rewards balance between any two coordinates, and the same shape of argument settles the isoperimetric inequality by symmetrisation and Jensen’s inequality for averages. A function that improves every time two coordinates are pulled together is maximised where they all agree.

Comparing two uneven calendars

The theorem compares every calendar with the even one. It says nothing yet about two uneven calendars compared with each other, and the sweeps below draw curves that never fall as a calendar is made more lopsided — which is a stronger claim than the even year is the minimum, and needs a stronger reason.

The reason is that the two-day step proves more than was used. It does not need the two days to be made equal: moving any amount of share from the busier of two days toward the quieter one, without overshooting, moves the product papbp_a p_b toward its top and so never lowers the chance of all-different. A transfer of that kind — from richer to poorer, stopping before they swap places — is what economists call a Robin Hood transfer, and a calendar that can be reached from another by a sequence of them is said to be majorised by it.

So the result is a monotone statement along a whole partial order. If one calendar can be turned into another by Robin Hood transfers, the first produces matches sooner at every room size. A function with that property is called Schur-convex, and the chance of a shared birthday is one.

The seasonal family is an instance. A calendar with a swing of 0.40.4 is exactly a mixture of the even year with the calendar whose swing is 0.80.8, taken in equal parts, and mixing any calendar with the even year is a sequence of Robin Hood transfers — every busy day gives some of its excess to every quiet one in proportion. So each calendar in the family majorises every smaller swing, and the chance of a match has to climb as the swing grows. The weekly family is the same argument in a less obvious form. Thinning the weekend moves share away from days that are already below average, which is the opposite of a Robin Hood transfer, so the comparison has to be read from the other end. Every calendar in the family gives one value to all 261 weekdays and another to all 104 weekend days, and calendars of that shape lie on a single line through the even year. The fuller weekend therefore sits between the even year and the emptier one — a mixture of the two — and a mixture with the even year is majorised by what was mixed. The emptier weekend wins, and the curve cannot fall.

Not every pair of calendars is comparable. A year that is busy in September and one that is busy on weekends cannot be reached from each other by transfers of this kind, and for such pairs the ordering of their answers depends on the room size and can in principle change as the room grows. Majorisation is a partial order, and the theorem is exactly as strong as the order is.

How far the answer moves

The theorem gives a direction. The size is a separate question, and the answer is that ordinary unevenness moves the threshold by very little, while extreme unevenness moves it a long way.

A seasonal swing, from none to the whole mean. The chance of a shared birthday among 23 people for a family of model calendars running from an even year to an extreme one. It rises from 50.73% to 65.56% and never falls, and the first group with an even chance falls from 23 to 19.
Fig. 4 The seasonal swing grown from nothing to the whole mean, so that the quietest day of the year has no births at all. The chance at twenty-three climbs from 50.73%50.73\% to 65.56%65.56\% and the threshold steps down to 22 at a swing of 0.40, 21 at 0.63, 20 at 0.80 and 19 at 0.95.

It takes a swing of forty per cent either side of the mean — a September with nearly two and a half times the daily births of a March — before a room of twenty-two has an even chance. Real seasonal variation is a small fraction of that, which is why measurements on birth records leave the answer at twenty-three.

The curve is also flat at its start, and that flatness is the more informative feature. A small swing changes the answer by an amount proportional to the square of the swing, not the swing itself. That is exactly what the two-day parabola predicts: at the even split the curve is at its top, where the slope is nought, so a small departure costs only a second-order amount.

A weekend, from full to empty. The chance of a shared birthday among 23 people for a family of model calendars running from an even year to an extreme one. It rises from 50.73% to 63.16% and never falls, and the first group with an even chance falls from 23 to 20.
Fig. 5 The weekend thinned from full to empty. With no weekend births at all the calendar has only 261 usable days and behaves exactly like a year of that length: the chance at twenty-three reaches 63.16%63.16\% and the threshold steps down to 22 at 0.53, 21 at 0.75 and 20 at 0.93.

The weekly sweep ends at a calendar that is simply shorter — 261 equally likely weekdays — and the even-year formula for 261 days gives a threshold of 20. The seasonal sweep ends at a calendar that is not a shortened year of anything, but it lands at nineteen, which is what an even year of about 243 days would give. That coincidence is the next thing to explain.

One number for any calendar

An even year of dd days has a threshold that depends only on dd. An uneven calendar has 364 free parameters. It would be surprising if a single number could stand in for all of them, and it very nearly can.

The quantity is the chance that two particular people share a birthday. Each lands on day ii with probability pip_i, so they match with probability

ipi2.\sum_i p_i^2 .

On an even year that is 1/d1/d. On an uneven calendar it is larger, and the excess is exactly the calendar’s spread:

ipi2  =  1d+i(pi1d)2,\sum_i p_i^2 \;=\; \frac1d + \sum_i \Big(p_i - \frac1d\Big)^2 ,

because the cross term sums to nought. So 1/pi21/\sum p_i^2 is a number of days — the size of an even year with the same pairwise collision chance — and it is at most dd, with equality only on the even year. Call it the effective number of days.

The reason it nearly determines the threshold is the pair-counting argument that explained twenty-three in the first place. A room of kk holds (k2)\binom{k}{2} pairs, each matching with chance pi2\sum p_i^2, and treating them as independent gives a chance of no match close to exp ⁣((k2)pi2)\exp\!\big(-\binom k2 \sum p_i^2\big). The calendar enters that estimate only through the one sum. Everything else about its shape is a correction of higher order — involving the sums of cubes of the pp’s, which govern three people landing together — and those corrections are small until the calendar is very lopsided.

Every calendar, placed by its effective number of days. 18 model calendars plotted by how many equally likely days they behave like against the exact size of room each needs for an even chance of a shared birthday. The stepped curve is an even year of that many days, and every calendar sits on it or one person above.
Fig. 6 Eighteen calendars, eight built by rule and ten at random with increasingly lopsided weights, each placed at its effective number of days. The stepped curve is the even-year threshold at that many days. Fourteen calendars sit exactly on it and the other four sit one person above, including a calendar with a fifth of all births on one day, which behaves like 24 days and needs 8 people rather than 7.

The four that sit above the curve are the instructive ones. They are the calendars with a few very heavy days, where three people landing on the same day stops being negligible — and every one of them needs one more person than the effective count predicts, never one fewer. A heavy day makes triple coincidences common, and a triple is one event that the pair count had been counting three times, so the pair estimate is slightly optimistic about how soon a match comes.

The same sum, counting species and markets

The sum of squared shares has been invented independently at least three times, for three purposes that have nothing to do with birthdays, and in each it was chosen for the same reason.

In 1949 the statistician Edward Simpson proposed measuring the diversity of an ecological community by the chance that two individuals drawn at random belong to the same species. That is pi2\sum p_i^2 with species in place of days. Its reciprocal is used as the effective number of species — the number of equally common species that would give the same chance of a same-species draw — which is precisely the effective number of days above, applied to a meadow.

In economics the same sum, applied to the market shares of the firms in an industry, is the Herfindahl–Hirschman index, and competition regulators set their thresholds for scrutinising mergers in terms of it. A market with four equal firms scores a quarter and behaves, in this sense, like four firms; a market where one firm holds most of the trade scores near one and behaves like one.

And in cryptography it is the collision probability of a key source: a random number generator whose outputs are not quite uniform has a larger pi2\sum p_i^2, and an attacker searching for two equal outputs needs about 1/pi21/\sqrt{\sum p_i^2} draws rather than the square root of the output space. That is why randomness has to be earned rather than assumed: a small bias costs little in any one output and shortens every collision search by exactly the factor above.

All three are asking the birthday question — how likely is it that two draws agree — and all three found that the answer is carried by one number that the even case makes as small as possible.

When pairs are the wrong thing to count

The proof above works for every room size, but the effective-days summary is a statement about pairs, and there are questions it gets wrong.

Three people sharing is governed by pi3\sum p_i^3 rather than pi2\sum p_i^2, and two calendars with the same effective number of days can have quite different cube sums. A calendar with one enormous day and a calendar with a moderately uneven spread might both behave like 200 days for pairs while the first produces triple birthdays far sooner. The averaging argument still shows the even year is the worst case for triples, since eke_k is the right object for any kk, but the one-number shortcut does not transfer.

Near-birthdays — two people within a day of each other — depend on how the busy days are arranged, not just on their sizes. Put all the heavy days next to each other and near-matches become much commoner than if the same days were scattered. Nothing symmetric in the pp’s can see that, and the averaging argument does not apply, because moving share between two days that are not neighbours changes the adjacency structure.

And dependence between people is outside the model entirely. Twins, or a room assembled from a school year, break the assumption that each person’s birthday is an independent draw from the calendar. The inequality says nothing about such rooms, and the direction of the effect is not fixed: a room of people born in one school year has a calendar confined to twelve months, which helps matches, but also skews away from the cut-off date, which may help or hinder depending on how the year is defined.

What a flat line of bars hides

Every calendar drawn above is a model, and saying so is not a formality. The seasonal cosine, the weekly comb, the blocks and the spikes are shapes chosen to exhibit the theorem, not measurements of any population, and their numbers should not be read as statements about any country’s births.

The effective-days figure also shows less than it seems to. Eighteen calendars, all sitting within one person of the curve, is evidence about eighteen calendars. That no calendar can sit two people above the curve is not proved here, and the four that sit one above show that the pair approximation is not exact; a sufficiently strange calendar — many medium-heavy days arranged so that the cube sum is large while the square sum is modest — might do worse.

And the averaging parabola is drawn on twelve slots and four people because a year of 365 days and a room of 23 produces a curve so flat that its top cannot be told from its ends at any printable scale. The algebra that makes the curve a parabola does not depend on the size, but the picture of it does, and the picture is of the small case.

Still open: which lopsided calendars are worst

The theorem fixes the best case for avoiding matches: the even year, uniquely. The opposite question is much less tidy. Among calendars with a given effective number of days, which one needs the largest room for an even chance, and by how much can it exceed the even-year value at that many days?

The figure suggests the excess is at most one person for anything resembling a birth record, and the reason offered — that the cube sum is what pushes a calendar above the curve — suggests the worst calendars concentrate their weight in a few very heavy days while keeping the square sum fixed. Whether the gap stays bounded as the calendar grows, or can be made as large as desired by a clever enough arrangement, is a question about the higher symmetric sums of a distribution with a prescribed second moment. It is a question about concentration of a count around its mean rather than about birthdays, and the figures here do not answer it.

A proof that never looks at the whole calendar

The argument is worth keeping for its shape more than for its conclusion. It never examines a whole calendar. It looks at two days at a time, shows that bringing them together always helps one side of an inequality, and lets compactness do the rest. That shape — improve locally, conclude globally at the maximiser — is how most inequalities that say the symmetric case is extreme are proved, from the arithmetic–geometric mean inequality to the coupon collector’s slowest calendar, where the same even distribution turns out to be the one that finishes the collection fastest.

The birthday version has the unusual merit that the local step can be drawn — a parabola with its top at the even split — and that its global conclusion is one a reader can check against a real room. Anyone expecting a lopsided calendar to spread people out has the direction backwards: busy days gather people together faster than quiet days keep them apart, and the gathering always wins.

Reads more easily once this is understood

Essays that name this one as worth reading first.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

Birthday problemCollisionComplementary countingConvexityIndependenceSymmetric functionVariance