# Central limit theorem magic

Oscar does a regular talent show, and I always try to come up with the most high-probability-of-failure magic trick idea. Important to lower the bar for everyone else and get others to feel good about going on stage with their own whacky idea (and do the same in their work). Here is one I came up with basic on the central limit theorem.

A few years ago, I read a great book called “The Book of Why” from the CS professor who invented Bayesian networks. In that book, he describes a scene where Francis Galton in 1877 at the Friday Evening Discourse at the Royal Institution of Great Britain talked about probability. Galton demoed a thing he called quincunx, which is a board with pins that marbles roll through, and as they make their way bouncing between pins, it creates a distinctive pattern: a normal distribution. That’s now called the central limit theorem. I thought, someone should make a magic trick out of that. Good that we had a talent show coming up. The question: how could I ask an audience to follow a bunch of random steps (= the marbles in Galton’s quincunx), but exploit the fact that a predictable distribution will result?

The idea: scramble an image and then ask an audience for help to decode it. So I created a little tool that lets me shift the columns of an image up and down. The image is 40 pixels wide, so a string of 40 numbers would be used to encode it by shifting each column. The number y at position x in that string shifts column x in the image up or down by y pixels. The image below is the output of an image that was encoded by such a string. The goal of the trick would be to have the audience decode it.

I had the audience follow three calculation steps on a piece of paper. In between each step, I asked people to pass the calculation paper to their neighbor, so that a different person would do each calculation step. That should make it (a) sufficiently clear to everyone in the audience that there is no way I could control who is calculating what, and (b) make it SO random that I can actually exploit the fact of its randomness.

(1) First, 40 people in the audience got a piece of paper handed out with a number on it.

(2) Second, each of them had to add to that number another number, and that number was written on a piece of paper stuck under their chair.

(3) Third, each of them had to use their iPhone stopwatch to time me as I walk across the stage, and then add 1 to the number on their piece of paper if my timing yielded an odd number of milliseconds, or subtract 1 if it was even.

(4) Fourth, I handed out another 40 pieces of paper with a number on each, and that number had to be added to the calculation.

This is where the normal distribution comes in. On 20 of the initial pieces of paper was written the number 1, on the other 20 was written the number -1. The same was the case for the papers glued under the chairs in calculation step two, and for the papers I handed out in step four. As to the third calculation step: no human being is able to time stuff down to the millisecond, so the distribution of odd and even milliseconds on an iPhone stopwatch is going to be pretty random too. So what happens when you add +1 or -1 four times, each time with a 50% probability? The potential outcomes of that are distributed in a normal distribution. However, you have to have enough “attempts”, because the resulting series will only converge to a normal distribution over time. 40 people’s (independent, random) calculations give me a fair likelihood that the distribution will look pretty normal, i.e., normal.

The key is that the calculations actually are random, and that’s more difficult than you would think. If you just ask people “imagine a random number”, 7 and 17 have much higher likelihood to occur. Apparently, some prey animals have biologically evolved random number generators in their brains so that they truly are unpredictable to their predators (so they don’t always run left when chased). So when I collect all 40 pieces of paper at the end of this – entirely randomized! – process, I know that I can expect to see around 14x 0, 10x 2 and 10x -2, 3x 4 and 3x -4. Of course it’s theoretically possible that I get 40x 0, but not particularly likely. That was the gamble behind the whole trick.

The conclusion of the trick was to type in the sequence of 40 numbers that I got back from the audience into the de-scrambler. I knew I would get a sequence of numbers back in which the probability of 0/2/-2/4/-4 was known, but I couldn’t predict the actual sequence in which the numbers would arrive: there were going to be around 14 0x, but I don’t know where in those 40 pieces of paper they were going to be. So if I wanted the sequence I’d get back from the audience to decode the image, for the original encoding step I would have to pick an encoding string that had a normal distribution of digits, and that I could also remember pretty well. The sequence below does that trick: it has 0s every 3 steps, it has a pair of -4/4 at the outer edges and right in the center, and it has the pair -2/2 in between the 0s. Its distribution of digits follows a normal distribution and it’s easy to remember/reproduce manually.

So now all I had to do was to type in each number I get back from the audience, and start filling up the decoder sequence so the resulting sequence sticks as closely as possible to the encoding sequence shown above. If I get a 15th 0, I would put it where otherwise a -2 would have been expected, because that would minimize the overall decoding error. And so on. The problem of course was that people totally screwed up their calculations (mostly because my performance was really confusing). So here is the sequence I actually got.

This is what the decoded image looked like. With some imagination, you can see the “Oscar” in there!

This is the actual source image. If the encoding sequence had been perfectly reproduced, this is what would have shown.

This is a pretty typical output from a randomized process. That’s how it should have looked. I guess I got into the fat tails of the central limit theorem on the actual evening of the performance. It is sort of a deep philosophical insight that people’s errors in following my confusing instructions actually led to less of the randomness I needed.

Here is the Excel file that lets you do the trick, if you so desire: