Coo, shiver my sceptre!

A couple weeks ago James Grime linked on Twitter to a puzzle in the January 8, 1981 issue of New Scientist, which runs as follows:

“Beauty? Courage? Generosity? Patience? Wisdom? Which do you wish for the new-born Princess?” asked the Good Fairy.

“Beauty and Wisdom will do nicely, thank you,” replied the King, not wanting to seem greedy.

“Wait! For each gift you name, I shall bestow on her two of the other gifts instead. Each name of a gift triggers a different pair. Each gift is triggered by two of the names. But if you mention both names, they cancel out and she will not get that gift at all.”

“Coo, shiver my sceptre!” exclaimed His Majesty.

“Quite simple! For instance if you ask for Beauty and Courage, she will receive Generosity and Patience. If you ask for Beauty, Generosity and Patience, she will receive those three and Wisdom too. You in fact wished for Beauty and Wisdom. She shall have them, provided you ask for them in the simplest way.”

What gift or gifts should His Majesty ask for?

So we can associate each of the five gifts — let’s denote them by B, C, G, P, W — with two of the others. Let’s denote this by f(B) = X + Y, for example, where X and Y are the two gifts triggered by B. So what we know is

f(B) + f(C) = G + P


f(B) + f(G) + f(P) = B + G + P + W.

Formally, B, C, G, P, W are generators of (\mathbb{Z}/2\mathbb{Z})^5; informally they’re symbols that when added to themselves cancel out. Now, this function f is a homomorphism from (\mathbb{Z}/2\mathbb{Z})^5 to itself – that is, f(x+y) = f(x) + f(y). (This means we can do the cancelling either before or after translating from the language of what was wished for to what actually happens.) So therefore we know

f(B+C) = G+P, f(B+G+P) = B+G+P+W.

Adding these together we get

f(C+G+P) = B+W

which gives a way to get both beauty and wisdom — namely, asking for courage, generosity, and patience.

But what’s f(B+C+G+P+W) — that is, what do you get if you ask for everything? We have that “each name of a gift triggers a different pair, and each gift is triggered by two of the names”. So we have
f(B+C+G+P+W) = 2B+2C+2G+2P+2W
since each gift is triggered twice. And the right-hand side there is just zero. So
f(B+C+G+P+W) = 0
and we can rewrite this:
f((C+G+P) + (B+W)) = 0.
But since f is a homomorphism that’s just
f(C+G+P) + f(B+W) = 0
which is another way of saying f(C+G+P) = f(B+W). So in fact f(B+W) = B+W — that is, to get beauty and wisdom, just ask for them.

To see that this is the simplest possible solution, we need to show that no single gift triggers both beauty and wisdom. I can’t come up with a “clean” way to do this, but we can go brute force. Beauty must trigger wisdom, wisdom must trigger beauty, and beauty and wisdom both trigger the same other gift. This gift can’t be courage – if it were, then we’d have f(B) = W+C, but we know f(B+C) = G+P, so adding these we’d have $f(C) = W+C+G+P$, which is impossible. So the “other” gift is either generosity or patience. Repeatedly applying the constraints that every gift can occur twice and the facts we already know, those lead to the solutions

f(B) = W+G, f(C) = W+P , f(G) = C+P, f(P) = B+C, f(W) = B+G


f(B) = W+P, f(C) = W+G, f(G) = B+C, f(P) = C+G, f(W) = B+P

respectively, which differ by exchanging G and P wherever they appear. In no case is there a single gift X with f(X) = B+W, so the solution f(B+W) = B+W is indeed the simplest one.

Note: Jim Randell has been doing programmatic solutions to these puzzles for quite a while now.

Posted in Uncategorized | 2 Comments

Help with social science about science

Perhaps of interest to many of my readers: Melanie Sinche, a career counselor and consultant, and research associate at Harvard Law’s Labor and Worklife Program, is working on a study of the career paths of PhD receipients in the sciences.  If you:

– Earned a PhD in any of the physical, computational, social, life sciences or engineering between 2004 and 2014

– Has ever worked, trained, or studied in the U.S.

then you should fill out this survey and help to paint a more accurate picture of what PhD recipients actually do.

Edited, April 16: turns out I forgot to link to the actual survey.

(H/T Tamara Broderick)

Posted in Uncategorized | 2 Comments

Various computations of the odds of a perfect March Madness bracket

Joseph Nebus has written a series of posts on the entropy in basketball results: for a single team, for both teams, in the win-loss results for a 64-team tournament like March Madness. For the final question he gets an answer of about 48 bits. That is, the probability of guessing the winners and losers of a tournament correctly is on the order of 248.

From blind guessing one gets 1 in 263, quoted for example in this USA Today story, with the caveat that:

Even so, allowing for some knowledge of college basketball and taking it account the norms of the NCAA tournament, the odds of a perfect bracket are still about 1 in 128 billion, according to DePaul math professor Jay Bergen.

This refers to Jeff Bergen’s video, “where does 1 in 128 billion come from”. Note 128 billion is roughly 237. Bergen’s strategy is to assume that the top seeds always win, since this is the most likely outcome.

The fact that two reasonable people gave two such different answers is an example of just how hard it is to estimate small probabilities. But both of these models gave up on using empirical data after the first round. Yet matchups between the “favorite” seeds should happen fairly often, and there will be data! Let’s look at win probabilities by seed as compiled at In a tournament where all the favorites win, we’ll have:

  • in the first round, four matches of 1 vs. 16, 2 vs. 15, …, 8 vs. 9, one in each region
  • four matches of 1 vs. 8, 2 vs. 7, 3 vs. 6, 4 vs. 5, one in each region
  • four matches of 1 vs. 4, 2 vs. 3, one in each region
  • four matches of 1 vs. 2, one in each region
  • three matches of 1 vs. 1, from different regions, of course

Historically, 1 seeds are 124-0 against 16 seeds, 2 seeds are 117-7 against 15 seeds, and so on until 8 seeds are 79-69 against 9 seeds. So the probability of picking all eight first-round games in one region perfectly is

(124/124)(117/124)(104/124)(99/123)(97/144)(95/144)(90/148)(79/148) = 0.09188

and the probability of getting all 32 first-round games right is the fourth power of this, about 7.12 \times 10^{-5} or one in 14,000. (The different denominators correspond to different numbers of times each matchup has occurred, presumably due to changes in the tournament structure; the 64-team field only dates back to 1985. Oddly enough, the Washington Post reports that nobody ever seems to pick a perfect first round. This isn’t a contradiction – nobody is boring enough to pick the strategy with the highest expected value for that bet, when the bet most people are interested in is trying to win their pool.

The probability of picking a perfect second round in any given region is (65/81)(64/88)(46/84)(49/88) = 0.17796; for all four regions it’s the fourth power of this, about 1.00 \times 10^{-3}.

The third round in each region consists of a 1-vs-4 game and a 2-vs-3 game, where the favorites win with probability 46/68 and 36/59 respectively; the probability of picking all eight third round games correctly is ((46/68)(36/59))^4 = 0.0290.

The fourth round in each region is a 1-vs-2 game, where the 1 seed has historically won with probability 38/69; the probability of picking all four correctly is (38/69)^4 = 0.0919.

Finally, the probability of picking all three Final Four games correctly is 1/8 – the model knows nothing beyond seeding.

Multiplying this all out, I get that the probability of picking all 63 games correctly is

(7.12 \times 10^{-5}) (1.00 \times 10^{-3}) (0.0290) (0.0919) (1/8) = 2.38 \times 10^{-11}

or about one in 42 billion, in a generic tournament. For what it’s worth, FiveThirtyEight gave 1 in 1.6 billion this year and 1 in 7.4 billion last year, using a model that actually knew something about basketball.

Posted in Uncategorized | 1 Comment

Distribution of sick time

Carl Erickson, the president of a small software company, writes that sick time follows a logarithmic distribution.  His terminology is a bit nonstandard, but here’s what he’s saying.  Take all the people who have worked for his company and list the amount of sick time they’ve taken, in hours.  Sort that list in descending order.  Then the xth entry on the list will be about -52 ln x + 236.  There were a total of 86 employees.

Does this translate into a more standard statement about the distribution of about of sick time taken? Let F(z) be the probability that someone took at least z sick days.  Then we have F(236 – 52 ln x) = x/86.  Let z = 236 – 52 ln x and solve for x in terms of z.  This gives x = exp((236 – z)/52).  So we get 

F(z) = exp((236 – z)/52) / 86

and as commenters at Hacker News pointed out, exp(236/52) is about 86, so we very roughly have

F(z) = exp(-z/52)

which also forces F(0) = 1, which is necessary because amounts of sick time must be nonnegative.  This is exactly the exponential distribution – which is memoryless.  So sick time is exponential with mean 52 hours.

 Is there a good theoretical reason that this should happen, though? The exponential distribution is memoryless but I don’t see why sickness times should be, especially since we’re talking about the total amount of time that people spend sick, not the time they spend dealing with any single illness.  Or is this just an example of everything looking linear (with the right variable transformation) if you try hard enough.

Posted in Uncategorized | 1 Comment

An approximation of quarterly growth from monthly growth

An approximation from Justin Wolfers: “Quarterly growth ˜ 0.33 * this month’s growth + 0.67 * (t-1) + 1.0 * (t-2) + 0.67 * (t-3) + 0.33*(t-4)”.

I stared at this one for a while. But it’s actually pretty easy to prove, assuming that we’re expressing growth as a difference and not a quotient. Say it’s month t now. The quarterly growth of some quantity f which varies with time, for the most recent quarter over the quarter before that, is f(t) + f(t-1) + f(t-2) - f(t-3) - f(t-4) - f(t-5).

The weighted sum of monthly growths there is

{1 \over 3} (f(t) - f(t-1)) + {2 \over 3} (f(t-1) - f(t-2)) + {3 \over 3} (f(t-2) - f(t-3)) + {2 \over 3} (f(t-3) - f(t-4)) + {1 \over 3} (f(t-4) - f(t-5))

and most terms here cancel, leaving

{1 \over 3} (f(t) + f(t-1) + f(t-2) - f(t-3) - f(t-4) - f(t-5)).

This is one-third the quarterly growth in Wolfers’ tweet – but if both figures are annualized, as is conventional in economic data, that takes care of the factor of 3.

Posted in Uncategorized | Leave a comment

Math bracketologyology

Jordan Ellenberg wrote a piece for Sunday’s New York Times on The Math of March Madness. It’s centered around a paper by Michael J. Lopez and Gregory J. Matthews which claims that a model combining point spreads and “possession based team efficiency metrics” (i. e. average numbers of points scored or given up per possession) did quite well in Kaggle’s 2014 March Madness competition. (For legal reasons, Kaggle had to call it “March Machine Learning Mania”.)

Sadly, this article doesn’t include Jordan’s own contribution to bracketology, the “Math Bracket”, in which the school with the better math department is picked to win each game: here are the 2015, 2014,”>2013, and 2010 (the original). If there are 2011 or 2012 math brackets, they don’t appear on his blog. In 2010 the math bracket picked Berkeley (excuse me, “Cal”, since we’re talking athletics) to win; in 2013 through 2015, Harvard.

I don’t know how well a totally random bracket (i. e. picked by coin flips) would do, but the math bracket at least starts out better than this. The math bracket usually picks the higher-seeded team in the first round – 19 of 32 in 2015, 22 of 32 in 2014, 23 of 32 in 2013, and 23 of 32 in 2010. This is because bigger schools (up to a point) tend to have better math departments and are better at basketball. (Quality of a department is judged by how many people an anonymous group of number theorists and geometric group theorists can name so is correlated with department size, which in turn is correlated with undergraduate enrollment, etc.)

The math brackets seem to break down in the later rounds, though. The 2010 bracket has a final four featuring teams seeded 2, 4, 8, and 11; 2013 is 2, 6, 12, and 14; 2014 is 2, 2, 10, and 12; 2015 is 7, 11, 11, and 13. The average final four team in the math brackets is therefore an 8 seed (the average of those numbers is 127/16 = 7.9375); the average team in the tournament is of course an 8.5 seed. The very best basketball teams just aren’t at schools with the best math departments.

Posted in Uncategorized | Leave a comment

Worst pi approximation ever

The average sinuosity of rivers – their length as the river travels, divided by the distance from source to mouth as the crow flies – is supposed to be π.  But it’s actually 1.94, and depends heavily on the river.  Via James Grime, writing for the Grauniad.  

That’s worse than the Indiana pi bill or 1 Kings 7:23.  To be fair to the Biblical text, which refers to a “molten sea” that is “round all about”, thirty cubits around and ten cubits across, nobody there is claiming those are high-precision measurements.  And if you want to try really hard to make things work out you can argue that the inner brim was thirty cubits around and the outer diameter was ten cubits, which is stated three verses later.  

(It’s a shame that approximation isn’t in 1 Kings 7:22…)

This post is scheduled to go out at 12:26, because I am in Eastern time and Pi Day was originally invented in San Francisco. Or actually because I forgot to do a pi day post until after I saw other people did.

Posted in Uncategorized | 2 Comments