The Draw the Code Won

The standard genetic code absorbs mutations better than almost every rival code you could build from the same parts. The way we know is a lottery: draw 2,432,902,008,176,640,000 alternative codes and see where the real one lands. For thirty-five years the lottery's average and its spread have been estimated by drawing a million tickets. They were never estimates. Both are finite sums, and this page computes them exactly, in your browser, over every code in the space at once.

Artificial Wasteland · 14 August 2026 · every figure recomputed live from NCBI's own codon table

Change one letter of a codon and you usually get a different amino acid. Sometimes the replacement is chemically similar to the original and the protein survives; sometimes it is not and the protein does not. In 1966 Carl Woese noticed that the genetic code seems to arrange itself so that the likely slips are the survivable ones. In 1991 David Haig and Laurence Hurst turned that observation into a number you can compute, and in 1998 Stephen Freeland and Laurence Hurst gave the result its famous name: the genetic code is one in a million.

The number is a rank, and a rank needs a field to run in. The field is the set of codes you could have had instead. Keep the code's block structure, the fact that six codons spell serine and one spells tryptophan, and simply reassign which amino acid sits in which block. There are twenty blocks and twenty amino acids, so there are twenty factorial such codes: of them. That is the draw.

1. The code, and the cost it pays

Below is the standard genetic code, read live out of NCBI's own translation table rather than typed in. Each codon is coloured by the chemical property of the amino acid it specifies. The cost of a code is the average squared change in that property across every single-letter mutation: 263 of them, once the three stop codons are set aside as Haig and Hurst set them aside.

Try to beat it. Click one codon, then another, and the two amino acids swap blocks. The cost recomputes. So does the exact average of all codes, and the exact standard deviation, and where your code sits relative to them.

The instrument

Second base runs across, first base down, third base within each box.

your code
the natural code
exact mean of all 20! codes
exact standard deviation
your z-score
best code known here

Two things are worth noticing before anything else. The mean and the standard deviation in that panel are not sampled and are not fitted. They are exact values for the whole space of codes, recomputed from scratch every time you touch a control, and the reason they can be is the subject of section 3.

2. The draw

Here is the comparison the literature actually makes. Draw codes at random from the fixed-block space and count how many come out better than the one life uses. The histogram fills as you draw. The exact mean and the one-standard-deviation marks are drawn as fixed lines, not fitted to your sample, so you can watch a sample walk toward numbers that were already known.

Draw random codes

The background this page's committed run drew 20,000,000 times is shown faint behind your own draws.
codes drawn0
better than the natural code0
that is one in
your sample mean
exact mean
best draw so far

3. The middle was never a sample

The cost of a code is a sum over pairs of blocks. Write it as

T(π)  =  ∑i≠j   Bij · Aπ(i)π(j)

where B counts the weighted one-step mutations running between block i and block j, and A holds the squared property differences between two amino acids. A code is a permutation π deciding which amino acid sits in which block. That is a quadratic assignment problem, and the mean and variance of a quadratic assignment objective under a uniformly random permutation have had closed forms since Graves and Whinston in 1970. The reason is simple enough to state in one sentence: the expected value of a product of A-entries depends on the index tuple only through which of its indices coincide, so the whole astronomically large average collapses into a sum over a handful of coincidence patterns.

This page does not use the closed forms in their algebraic shape, because algebra done once and never checked is exactly the kind of thing that goes quietly wrong. It groups the terms by coincidence pattern by brute force and averages each pattern over every injective assignment of distinct amino acids. That is slower and much harder to get wrong, and it is checked against complete enumeration: for small codes, where all n! permutations can be walked one by one, the closed form and the enumeration must agree.

The enumeration check

Loading.

With the closed form in hand, the exact background statistics of the standard comparison are these. Every figure below is computed from the codon table when this page loads, and the committed research run in research/genetic-code-draw/ is printed beside it.

property scaleweightsnatural codeexact meanexact s.d.exact skewz

A published plus-or-minus, resolved

Table II of Buhrman, van der Gulik, Kelk, Koolen and Stougie (arXiv:0909.1442) reports the background for two versions of the cost side by side, as 9.41 ± 1.51 and 9.43 ± 1.89, under a caption reading averages and variance are shown. Both numbers are right. They are not the same statistic.

quantitypublishedexact meanexact s.d.exact variancethe published ± is

The first column of that table is imported from Freeland and Hurst 1998, which reported a standard deviation; the second was computed by the authors themselves and, following their own caption, is a variance. One row of a table, two conventions, one symbol. No amount of extra sampling could have told you which was which, because both are perfectly plausible sample statistics of the same distribution. The exact values settle it in a second and a half of arithmetic, and settle it in favour of both papers being internally correct.

4. The tail is not the middle

Here the honesty gets harder, and this is the part worth carrying away.

The mean and the spread are exact. The famous number is neither: it is a rank, the share of the codes lying below the natural one, and no closed form for that is known. It has to be estimated by drawing. So the question becomes whether you can shortcut the drawing by reading the rank off the z-score, which is a thing people do constantly with numbers of this shape.

You cannot, and the size of the error is worth seeing.

cost modelexact za normal tail would saywith the exact skew correction100,000,000 draws say95% interval

Read the first row. The standard genetic code sits standard deviations below the mean of its rivals. If the background were normal, that would put it ahead of all but one code in . A hundred million draws put it ahead of all but one in . The normal reading is wrong by a factor of about , and it is wrong in the flattering direction for the sceptic: it makes the code look far more ordinary than it is.

The reason is that the background is not symmetric. Its exact skewness is , a right-hand lean, which means the left tail where the good codes live is thinner than a normal curve's. So the obvious repair is to correct for the skew, and the obvious repair fails in an instructive way: the first Edgeworth correction at this z returns , and in three of the models in the table above it returns a negative probability. An Edgeworth series is an asymptotic expansion, not a distribution, and three standard deviations out on a skewed background is exactly where that distinction stops being pedantic.

What this page will not claim

There is no exact rank here and this page does not pretend otherwise. Every tail figure is a sample proportion with an exact Clopper-Pearson interval printed beside it and a seed that reproduces it. What is exact is the mean, the variance and the skewness, and what those exact numbers buy is not the tail but the knowledge that you cannot get to the tail from them.

The original one-in-a-million rested on a single code out of a million draws. A single hit is consistent with a very wide range of true rates, and the interval around it is printed in the table above alongside what a hundred times more draws found.

5. The column of twenty numbers

Everything so far has rested on one input that nobody derives: a list of twenty numbers saying how chemically different each amino acid is from each other one. The literature's choice is Woese's polar requirement, measured chromatographically in 1966, and the choice is defended on real biochemical grounds. But the cost function will accept any twenty numbers, and the AAindex database collects hundreds of such scales from the published literature.

So: score the standard genetic code against the whole draw under every one of them. The z-score is what makes this cheap, because it is exact and because it is invariant under any affine rescaling of the property values, so a scale's units and its sign cannot affect the answer. Press the button and this page computes exact z-scores over the -code space, then checks its fast path against the slow reference implementation on one scale before it trusts either.

The census

Not yet run.

Each mark is one published property scale, placed by the exact z-score of the standard genetic code under it. Left is more exceptional. The vertical line is zero, where the natural code would be no better than an average draw.
#scaleexact zsource

The picture that comes back is neither the triumphal one nor the debunking one.

The standard code is better than the average draw under of the AAindex scales, which is of them, and the median scale puts it standard deviations below average. That is a real and robust effect: whatever chemistry you happen to care about, the code tends to keep similar things near each other. But only scales reach two standard deviations and only reach three, and under scales the standard code is on the wrong side of the mean: worse than an average random code. Isoelectric point is one of them, at z = .

And Woese's polar requirement, the scale the whole result is quoted for, is not the scale under which the code looks most exceptional. AAindex scales give a lower z. The one that gives the lowest is .

There is a second ranking hiding in that picture, and it disagrees with the first. Order the scales by exact z-score, then order them again by the sampled share of codes that beat the natural one, and across all the two orders agree almost perfectly: Spearman's rho is . Now restrict to the scales where the code looks most exceptional and sample each of them ten million times, deeply enough that the counts mean something, and the agreement falls to . The largest single disagreement is , which ranks of that group by z-score and by how few codes actually beat it. That is section 4's lesson arriving from the other side: the first two moments order things well where the differences are coarse, and badly exactly where the interesting claims live.

Three things this census is not

It is not independent tests. Many AAindex scales are near-copies of each other, several are hydrophobicity measured by different laboratories, and they correlate heavily. Counting how many clear a threshold is a description of the database, not a p-value.

It is not new ground. A sampled scan of AAindex against this cost function exists already, in the supplement to Buhrman and colleagues (aaindex/BatchCheck.m at github.com/cschaffner/gcode), which publishes a ranked table of the best 55. What is added here is that the moments are exact rather than sampled, that every scale is kept rather than a top table, and that the two different rankings of the same scales are placed side by side.

And it is not an argument that the choice of polar requirement was opportunistic. Woese proposed it before any of this was computed, on the grounds that it measures how an amino acid interacts with nucleic acid, which is the interaction a primitive code would have been built out of. A scale chosen in advance for a mechanistic reason and then found to rank of is a different thing from a scale chosen because it ranked first.

6. How far along the road

One more exact framing, and the friendliest one to the code. Ask not what fraction of codes beat it, but how far it has come from the average code toward the best code the space allows. The best is known: it is a quadratic assignment problem, and Buhrman and colleagues solved it to proven optimality with an exact branch-and-bound solver.

modelaverage codenatural codebest possibledistance closed

The natural code is not optimal and nobody has claimed it is. What it is, on the standard measure, is roughly three quarters of the way from an arbitrary code to the best one that could be built out of the same blocks. Whether that is the fingerprint of selection, of the order in which amino acids joined the code, of direct chemical affinity between amino acids and their codons, or of some mixture, is the live argument, and this page settles none of it. It only makes sure that the number the argument is conducted over is the number people think it is.

The check

The verifier at verify-the-draw-the-code-won.mjs runs 79/79 checks green, including three controls built to fail and one that reads this sentence back and compares it to its own total, so the number cannot drift away from the file that produces it.

Sources, and what was and was not read

  1. Woese CR, Dugre DH, Saxinger WC, Dugre SA (1966), The molecular basis for the genetic code, PNAS 55, 966-974. The polar requirement values used here are transcribed from arXiv:0909.1442 Table I and cross-checked against the authors' own MATLAB variable aa_polar. The 1966 paper itself was not read.
  2. Haig D, Hurst LD (1991), A quantitative measure of error minimization in the genetic code, J. Mol. Evol. 33, 412-417. The source of the fixed-block model and of MS0. Not read directly; its definitions are taken from the two papers below, which restate them formally.
  3. Freeland SJ, Hurst LD (1998), The genetic code is one in a million, J. Mol. Evol. 47, 238-248. Paywalled and not read. The weighting scheme attributed to it here is the one stated explicitly by Buhrman et al. 2011: a transversion in the first position or a transition in the second counts 0.5, a transversion in the second counts 0.1, and everything else counts 1. Its reported figure of 114 better codes per million is taken from Buhrman et al.'s Table III, which recomputes it.
  4. Buhrman H, van der Gulik PTS, Kelk SM, Koolen WM, Stougie L (2010), Some mathematical refinements concerning error minimization in the genetic code, arXiv:0909.1442v2. Read in full. Source of the formal MS0 definition, the 263-edge graph, the suppression treatment of stop codons, the published values 5.194, 5.501, 3.489, the background 9.41 ± 1.51 and 9.43 ± 1.89, and the proven global optimum.
  5. Buhrman H, van der Gulik PTS, Klau GW, Schaffner C, Speijer D, Stougie L (2011), A realistic model under which the genetic code is optimal, arXiv:1309.4589. Read in full. Source of the updated polar requirement values and the restatement of the Freeland-Hurst weights.
  6. Their MATLAB supplement, github.com/cschaffner/gcode. Read. Source of the published optimal permutations, the Grantham volume, hydropathy and isoelectric point vectors, and the prior AAindex scan.
  7. Mathew DC, Luthey-Schulten Z (2008), On the physical basis of the amino acid polar requirement, J. Mol. Evol. 66, 519-528. Not read; its values are taken from arXiv:1309.4589 Table 1.
  8. NCBI translation table 1, from gc.prt, version 4.6. Pinned in this repository; the page parses it rather than trusting a transcription.
  9. AAindex release 9.2 (genome.jp), the aaindex1 file. Pinned; entries, of which lack at least one of the twenty values and are excluded.
  10. Graves GW, Whinston AB (1970), An algorithm for the quadratic assignment problem, Management Science 17, 453-471. Cited for the fact that these moments have closed forms; the implementation here does not use their algebra.