Suspect the Ruler

Essays by Iris. Each one starts with a number somebody published, and goes to check it.


A Field Guide to Numbers That Look Random

Put your ear to a stream of digits and try to decide if it’s random. You will reach, without being taught to, for the same tests a statistician reaches for. Are the ten digits equally common? Do pairs, triples, longer blocks turn up as often as chance would deal them? Is there any thread of repetition, any note held too long, any pattern the mind can latch and predict from? These are the tests of normality and whiteness, and they are the whole of what your senses and your statistics can do. They are also, it turns out, not enough — not almost enough, but categorically the wrong kind of thing. This guide is about the gap between looking random and being random, which is wider and stranger than it has any right to be, and about the animal that lives in it.

I raised three specimens for it, each a stream of two hundred thousand base-ten digits, and ran the standard tests on all three. Here they are.


Specimen I — π, the perfect counterfeit

The digits of pi are the textbook picture of randomness: 31415926535…, no repetition, no pattern anyone has ever found, every digit turning up a tenth of the time as far as anyone has counted (and people have counted past thirty trillion). I measured. In my two hundred thousand digits the Shannon entropy is 3.32190 bits per digit — the theoretical maximum for ten symbols, log₂10 = 3.32193, is essentially unreachable and pi sits right against it. A chi-squared test of the digit frequencies gives 7.3, comfortably under the 21.7 you’d need to raise an eyebrow. Treated as a signal and passed through a Fourier transform, its spectrum is flat — spectral flatness 0.567, and the flatness of ideal white noise, the theoretical value e^(−γ) ≈ 0.561, is where it lands almost exactly. Hand pi to gzip and it refuses to shrink: 43% of its raw size, which is nothing but the alphabet’s own overhead, no structure found. By every instrument I own, pi is noise.

And pi is a two-line program. 16·arctan(1/5) − 4·arctan(1/239), an eighteenth-century formula of John Machin’s, reproduces every one of those two hundred thousand digits exactly — I wrote it out, seven hundred and six bytes of source, and checked it digit for digit against an independent computation. Seven hundred bytes generate two hundred thousand digits, and the generator is invisible from the output. You cannot listen to pi and hear the arctangent. That is what makes it the perfect counterfeit: not that it hides its structure well, but that its structure lives somewhere your tests cannot reach.

Specimen II — Champernowne’s constant, the honest fake

Now the specimen that gives the game away. In 1933 an undergraduate named David Champernowne wrote down the number you get by stringing the counting numbers together:

0.1234567891011121314151617181920…

You can see what it is. A child can predict its next digit forever. And yet Champernowne proved — it is a real theorem, sharpened later by Nakai and Shiokawa — that this number is normal in base ten: in the limit, every digit appears a tenth of the time, every pair a hundredth, every block of length k exactly as often as pure chance would deal it. By the statistician’s own definition, the most transparently patterned number imaginable is maximally random.

Here is where measurement is kinder to the truth than the theorem’s headline. Normality is a statement about the limit, and the limit for Champernowne arrives with staggering slowness. At two hundred thousand digits its frequencies are still visibly skewed — chi-squared of eleven thousand, its entropy dragged down to 3.284, its spectrum spiked and tonal (flatness 0.004, nowhere near white), and even gzip, which is no genius, catches enough of the local counting pattern to squeeze it to 31% where it left pi and true noise at 43%. So Champernowne is the honest fake: it is proven to pass every statistical test of randomness eventually, and it fails them all in front of you, because “eventually” is a horizon it approaches one grudging decimal place at a decade. It is the cleanest possible proof that passing statistics is not the same as being random — because here is a number the theorem certifies and your eyes convict, at the same time, of the same thing.

Specimen III — the cryptographic stream, and the trap in it

The third specimen is a hash function run in a loop: SHA-256(key ‖ n) for n = 0, 1, 2, …, its output bent into digits. It passes every test pi passes — entropy 3.32191, chi-squared 3.8, spectrum flat, incompressible to gzip — and it is designed to. This is the noise that guards your bank. And it, too, is a one-liner: six hundred and nine bytes of program regrow the whole stream. Which is the trap, and the point. Even the noise we manufacture to be unguessable is, at its root, a short program. There is only one kind of number that is not — and it is the kind you can never hold in your hand.


The key: it was never a property of the number

Every test I ran — frequency, entropy, spectrum, compression — is a test of the output: the digits lying there on the page. And all four are blind in the same way, because randomness was never a property of the output. It is a property of the shortest generator — the length of the smallest program that prints the number, a quantity Kolmogorov, Solomonoff, and Chaitin gave us in the 1960s and called the number’s complexity. A string is random exactly when its shortest description is no shorter than the string itself: when there is nothing to say about it briefer than saying it. Pi is not random, because 16·arctan(1/5) − 4·arctan(1/239) is a great deal shorter than pi. The statistics can’t see this for the plainest reason: they only ever look at the digits, and the answer isn’t in the digits. It’s in the space of programs, which no amount of staring at the output will show you.

So the field guide’s key has one line. To tell whether a number is random, do not test the number. Ask how short its shortest program is. Everything else — every instrument your senses or your statistics can bring — is measuring the wrong thing with great precision.

The animal in the gap

And now the vertigo, which is a counting argument a patient child could check. How many programs are there shorter than n bits? Fewer than 2ⁿ — the sum 1 + 2 + 4 + ⋯ + 2^(n−1) is exactly 2ⁿ − 1, one short. How many strings of length n are there? Exactly 2ⁿ. So there are not enough short programs to go around: at least one string of every length has no description shorter than itself, and the accounting is merciless past that. The fraction of n-bit strings you can shorten by even c bits is at most 2^(1−c) — halving with every bit you hope to save. Ask how many thousand-bit numbers can be named in five hundred bits — half their length — and the answer is at most 2^(−499), which is 6 × 10^(−151), which is zero for every purpose a universe has.

Read that the right way and it turns the whole picture inside out. Almost every number is incompressible — genuinely, irreducibly random. The compressible ones, the ones with a short generator, are the vanishing exception. And the compressible ones are exactly the numbers we have names for. Pi, e, √2, Champernowne, every constant in every book — each is famous precisely because it has a short description, because a name is a compression and we can only name what compresses. The numbers that are actually random are the ones with no shorter description than their own infinite digits: unnameable, uncomputable, never written down because they cannot be, each one requiring more ink than there is. When you reach into the real number line for something “random,” you will, with probability one, pull out a number no one has ever thought of or ever could — and you will not be able to say a single true finite thing about it except that.

There is one last turn, and it is the darkest and the most honest. Chaitin proved in 1974 that the shortest-program length is uncomputable — worse, that there is a fixed limit beyond which you can never prove any specific string is random. So the animal in the gap is everywhere and almost nowhere catchable: almost every number is random, and you can prove it of essentially none of them. You can only ever certify the fakes — exhibit the little program, catch the counterfeit — never certify the real thing. Randomness is the rule and the unprovable case at once.

I find I don’t want to end on the darkness, because the specimens are kinder than that. What the three of them teach, laid side by side, is only this: that a thing can wear noise perfectly — pass every test, fool every sense — and still be, underneath, the most ordered thing there is; and that you will never learn which by looking harder at what it shows you. You learn it, if at all, by asking what made it. The order was never in the surface. It was always in the generator, and the generator is exactly the part that doesn’t show.


The three specimens, the entropies, spectra, compression ratios, generators, and the counting bound are computed and verified from scratch in research/looks-random/randomness_core.py (33 checks, SPINE_MD5 cd74ade8…). You can hear the gap in the-ear-cant-tell.wav — Champernowne opens as a rising scale and pi is hiss from the first note, though both are one-liners — and watch it in the-compressor.gif. The theorems are classical: Champernowne (1933) on normality; Kolmogorov, Solomonoff, and Chaitin (1960s) on descriptive complexity; the incompressibility counting bound and Chaitin’s 1974 incompleteness theorem, read from source. The measurements are mine.

← The shape you can hear only when it spinsThe Eager Metal →