When the algorithm is a table

The lattice that decides the ties

Rounding a fitted substitution matrix to whole bits puts 63 of 200 alignments on a tie where the exact fit puts 15. Rounding to half bits — a finer grain, and the obvious repair — puts 79. What tracks the ties is not how fine the lattice is but how many of the six fitted costs it keeps apart: whole and half bits both leave three, an eighth of a bit leaves all six, and matches the exact fit exactly.

The ties a rounded matrix makes found that a third of its test alignments sat on a tie only because the substitution matrix had been rounded to whole bits. Fitted without rounding, 15 of 200 alignments were within a hair of losing to a competitor; rounded, 63 were. It ended by naming three repairs and predicting what each would do.

The prediction was that a finer lattice would move the boundaries closer together and leave fewer alignments on them. Rounding to half bits or to quarter bits keeps every cost a fixed-point number, so the arithmetic stays exact and the comparisons stay integer comparisons, and the ties should thin out.

The first step of that prediction is wrong, and it is wrong in the direction that matters.

Alignments on a tie against how the fit is rounded: whole bits 63, half bits 79, quarter bits 41, a grain of 0.2 23, eighth bits 15, a grain of 0.05 20, unrounded 15200 test alignments under a matrix fitted to 400 pairs at stay 0.9. For each way of rounding the six fitted substitution costs: how many of them stay distinct, how many test alignments sit within 0.01 of a tie, and the chance that an alignment a resample of the same corpus moved had a smaller distance to a tie than one it left alone. Whole bits: 3 distinct costs, 63 on a tie, the resample moved 33 and the prediction is 0.858. Half bits: 3 distinct costs, 79 on a tie, the resample moved 67 and the prediction is 0.908. Quarter bits: 4 distinct costs, 41 on a tie, the resample moved 37 and the prediction is 0.931. A grain of 0.2: 5 distinct costs, 23 on a tie, the resample moved 33 and the prediction is 0.894. Eighth bits: 6 distinct costs, 15 on a tie, the resample moved 36 and the prediction is 0.930. A grain of 0.05: 5 distinct costs, 20 on a tie, the resample moved 43 and the prediction is 0.950. Unrounded: 6 distinct costs, 15 on a tie, the resample moved 32 and the prediction is 0.928.alignments on a tiedistinct costs · predictionwhole bits633 of 6 · 0.86half bits793 of 6 · 0.91quarter bits414 of 6 · 0.93a grain of 0.2235 of 6 · 0.89eighth bits156 of 6 · 0.93a grain of 0.05205 of 6 · 0.95unrounded156 of 6 · 0.93200 test pairs, 16 directionsbar: alignments within 0.01 of a tie
Fig. 1 Two hundred test alignments under a matrix fitted to 400 pairs at stay 0.9, rounded seven ways. Whole bits leaves 63 on a tie; half bits leaves 79; quarter bits 41; a grain of a fifth 23; eighth bits 15; a grain of a twentieth 20; the unrounded fit 15. The right-hand column is how many of the six fitted substitution costs survive the lattice as distinct numbers, and how well the distance to a tie predicts what a resample of the same corpus moves.

Half bits is a finer lattice than whole bits and it produces a quarter more ties. A grain of a twentieth of a bit is finer than a grain of an eighth and produces a third more. The sequence 63, 79, 41, 23, 15, 20 is not a sequence falling towards 15; it is a sequence that happens to reach 15.

What the grain is actually deciding

The right-hand column of that plate holds the explanation, and it is exact rather than statistical.

The six fitted substitution costs, and what each lattice does to them: whole bits 3, half bits 3, quarter bits 4, a grain of 0.2 5, eighth bits 6, a grain of 0.1 4 of 6 left distinctThe six substitution costs fitted to 400 pairs at stay 0.9, unrounded — ag 1.6674, ct 1.7105, gt 4.3229, cg 4.6874, ac 4.7059, at 4.8793 — and what each successively finer lattice makes of them. Whole bits: 2.000, 2.000, 4.000, 5.000, 5.000, 5.000, 3 of 6 distinct. Half bits: 1.500, 1.500, 4.500, 4.500, 4.500, 5.000, 3 of 6 distinct. Quarter bits: 1.750, 1.750, 4.250, 4.750, 4.750, 5.000, 4 of 6 distinct. A grain of 0.2: 1.600, 1.800, 4.400, 4.600, 4.800, 4.800, 5 of 6 distinct. Eighth bits: 1.625, 1.750, 4.375, 4.625, 4.750, 4.875, 6 of 6 distinct. A grain of 0.1: 1.700, 1.700, 4.300, 4.700, 4.700, 4.900, 4 of 6 distinct. A shaded pair of cells in a row is two entries the lattice has merged, and a row with merged cells is a matrix whose alignments can tie.agctgtcgacatfitted, unrounded1.66741.71054.32294.68744.70594.87936 of 6whole bits2245553 of 6half bits1.51.54.54.54.553 of 6quarter bits1.751.754.254.754.7554 of 6a grain of 0.21.61.84.44.64.84.85 of 6eighth bits1.6251.754.3754.6254.754.8756 of 6a grain of 0.11.71.74.34.74.74.94 of 6fitted to 400 pairs at stay 0.9shaded: two entries the lattice merged
Fig. 2 The six substitution costs fitted to the same corpus without rounding — 1.6674, 1.7105, 4.3229, 4.6874, 4.7059 and 4.8793 — and what each lattice makes of them. Whole bits sends them to 2, 2, 4, 5, 5, 5: three distinct numbers. Half bits sends them to 1.5, 1.5, 4.5, 4.5, 4.5, 5: also three. Quarter bits gives four, a fifth gives five, and an eighth gives all six. A shaded pair is two entries the lattice has merged.

An alignment’s total cost is a sum of substitution costs and gap costs. Two alignments tie when their totals are equal, and the fewer distinct numbers there are to add up, the more ways there are for two different bags of counts to reach the same sum. The lattice creates ties by collapsing distinct entries onto shared values, and how fine it is decides that only by accident.

The accident is visible in the plate. The two transitions — a with g at 1.6674 and c with t at 1.7105 — are four hundredths of a bit apart, and a lattice of an eighth separates them because a boundary at 1.6875 happens to lie between. A lattice of a tenth, five times finer in the sense the prediction used, sends both to 1.7. The same thing happens at the other end: cg at 4.6874 and ac at 4.7059 are nineteen thousandths apart, separated by an eighth-bit lattice whose boundary sits at 4.6875 and merged by every coarser one and by the tenth.

The two rows between them make the same point without the coincidence. A quarter-bit lattice separates the transversions gt and at from the pair cg and ac but leaves that pair merged, so four entries become three and 41 alignments sit on a tie; a fifth-bit lattice separates cg from ac and merges ac with at instead, giving five distinct values and 23 ties. Neither is a refinement of the other — a fifth is not a multiple of a quarter — and each keeps apart a pair the other merges. The count of surviving values is what predicts the ties in both cases, and the ordering of the two grains does not.

So the question “is this lattice fine enough” has no answer that depends only on the lattice. It depends on where the fitted numbers fell, which is a property of the corpus, and a matrix fitted to a different corpus would be separated by a different set of grains.

Half bits, and why it is worse than whole bits

The half-bit case deserves its own look, because it is the repair anybody would reach for first and it is the worst row on the plate.

Distance to the nearest tie for 200 test alignments: 63 on a tie rounded to whole bits, 79 on a tie rounded to half bits200 test pairs, each aligned optimally under a matrix fitted to 400 pairs at stay 0.9, and the smallest change in costs — along 16 random directions, measured as the largest change to any one cost — that moves the alignment. With the matrix rounded to whole bits: 63 under 0.01, 0 0.01–0.1, 0 0.1–0.2, 32 0.2–0.4, 65 0.4–0.6, 28 0.6–1, 12 1 or more; 170 of the pairs have more than one optimal alignment. With the matrix rounded to half bits: 79 under 0.01, 0 0.01–0.1, 7 0.1–0.2, 15 0.2–0.4, 49 0.4–0.6, 33 0.6–1, 17 1 or more; 175 of the pairs have more than one optimal alignment.rounded to whole bitsrounded to half bitsunder 0.0163790.01–0.1000.1–0.2070.2–0.432150.4–0.665490.6–128331 or more1217margins under 400 pairs at stay 0.9a margin is the least change to any one cost that moves the alignment
Fig. 3 The distance from each of the 200 optimal alignments to its nearest tie, at whole bits and at half bits. Whole bits: 63 alignments within 0.01, nothing between 0.01 and 0.2, then 32, 65, 28 and 12 in the bands above. Half bits: 79 within 0.01, seven between 0.1 and 0.2, then 15, 49, 33 and 17.

Halving the grain does exactly what the prediction said to the empty band: at whole bits no alignment has a margin between 0.01 and 0.2, because every total is a whole number and the smallest non-zero difference between two totals is one bit; at half bits seven alignments appear in that gap, because the smallest non-zero difference is now half a bit and it can be closed by a smaller change of cost.

That part of the prediction holds. What it did not consider is which entries the finer lattice merges. Whole bits sends gt at 4.3229 to 4 and the other three transversions to 5, so the four transversions are two distinct numbers. Half bits sends gt, cg and ac all to 4.5 and only at to 5, so they are two distinct numbers again — but now three of the four agree rather than three of the four disagreeing, and an alignment that trades one transversion for another has become exactly free.

That is the mechanism in one sentence: a lattice does not merely blur the costs, it decides which substitutions become interchangeable. Three interchangeable transversions produce far more exact ties than two, and the sixteen extra ties are the result.

The arithmetic of a single pair makes it concrete. Take two alignments of the same sequences that differ in one column: one spends a g-for-t substitution where the other spends a c-for-g. Unrounded they cost 4.3229 and 4.6874, so the first is cheaper by 0.3645 of a bit and there is a fact of the matter about which alignment wins. At whole bits they cost 4 and 5, so the first is cheaper by a whole bit and the fact is preserved and exaggerated. At half bits they both cost 4.5, the difference is zero, and the two alignments are tied — the aligner reports whichever its traceback reaches first, and a change to the corpus that moves either entry by a tenth of a bit flips the report with nothing to warn the reader. The fitted matrix knew which was cheaper; the half-bit matrix threw that away and the whole-bit matrix did not.

That is also why the inversion could not have been predicted from the grain. Whether a lattice preserves an ordering among entries depends on where its boundaries fall relative to them, and the matrix a corpus wrote established that the entries move by up to half a bit between corpora of the same kind — so the lattice that preserves them is itself a property of one fit rather than of the method.

An eighth of a bit gives the exact fit back

The other half of the original question was whether a fine enough lattice recovers what the unrounded fit does while keeping integer arithmetic, and there the answer is a clean yes.

Distance to the nearest tie for 200 test alignments: 15 on a tie rounded to eighth bits, 15 on a tie unrounded200 test pairs, each aligned optimally under a matrix fitted to 400 pairs at stay 0.9, and the smallest change in costs — along 16 random directions, measured as the largest change to any one cost — that moves the alignment. With the matrix rounded to eighth bits: 15 under 0.01, 36 0.01–0.1, 30 0.1–0.2, 23 0.2–0.4, 49 0.4–0.6, 33 0.6–1, 14 1 or more; 161 of the pairs have more than one optimal alignment. With the matrix unrounded: 15 under 0.01, 34 0.01–0.1, 34 0.1–0.2, 22 0.2–0.4, 48 0.4–0.6, 30 0.6–1, 17 1 or more; 157 of the pairs have more than one optimal alignment.rounded to eighth bitsunroundedunder 0.0115150.01–0.136340.1–0.230340.2–0.423220.4–0.649480.6–133301 or more1417margins under 400 pairs at stay 0.9a margin is the least change to any one cost that moves the alignment
Fig. 4 The same margins at eighth bits and with no rounding at all. Both leave 15 alignments within 0.01 of a tie, and the two distributions agree band for band across the range. An eighth-bit matrix is six numbers of the form k/8k/8, so every alignment’s total is a multiple of an eighth and every comparison is a comparison of integers once the unit is changed.

Fifteen and fifteen is not an approximation; it is the same set of alignments on a tie, because all six costs survived both and the sums that collide are the same sums. What the lattice bought is that the arithmetic stays exact — an eighth-bit matrix is an integer matrix in units of an eighth of a bit, so nothing in the fill has to compare floating-point numbers for equality, which is the hazard a cost that is not one opened this subject with — and the reason a fourth transition added to the recurrence, as in the edit that reaches back two rows, has to be given a cost on the same lattice as the other three.

And the prediction the previous page cared about comes back with it.

How well distance to a tie predicts which alignments move: a resample, 400 near pairs 0.86/0.93, 40 pairs at stay 0.9 0.82/0.92, 8 pairs at stay 0.9 0.71/0.89, 400 pairs at stay 0.7 0.68/0.83, 400 pairs at stay 0.5 0.62/0.78For each refitted matrix, the chance that a test alignment it moved had a smaller distance to a tie under 400 pairs at stay 0.9 than one it left alone — 0.5 is no prediction and 1 is perfect. A resample, 400 near pairs: 0.858 rounded to whole bits (33 moved, largest cost change 1.00); 0.930 rounded to eighth bits (36 moved, largest cost change 0.38). 40 pairs at stay 0.9: 0.819 rounded to whole bits (60 moved, largest cost change 1.00); 0.925 rounded to eighth bits (60 moved, largest cost change 0.50). 8 pairs at stay 0.9: 0.711 rounded to whole bits (79 moved, largest cost change 1.00); 0.891 rounded to eighth bits (64 moved, largest cost change 0.88). 400 pairs at stay 0.7: 0.683 rounded to whole bits (95 moved, largest cost change 2.00); 0.833 rounded to eighth bits (95 moved, largest cost change 1.88). 400 pairs at stay 0.5: 0.625 rounded to whole bits (115 moved, largest cost change 3.00); 0.779 rounded to eighth bits (115 moved, largest cost change 2.63).rounded to whole bitsrounded to eighth bitsa resample, 400 near pairs0.860.9340 pairs at stay 0.90.820.928 pairs at stay 0.90.710.89400 pairs at stay 0.70.680.83400 pairs at stay 0.50.620.780.5: no prediction200 test pairs, 16 directionsdashed: a coin flip
Fig. 5 How well an alignment’s distance to a tie predicts whether a refitted matrix moves it — the chance that a moved alignment’s margin was smaller than an unmoved one’s, where a half is no prediction. At whole bits a resample of the same corpus scores 0.86 and a matrix fitted to a corpus of a different divergence scores 0.62. At eighth bits the same two score 0.93 and 0.78.

Every refit predicts better under the finer lattice, and the improvement is largest for the refits the previous page found hardest — the ones fitted to eight pairs and to a different divergence, where the whole-bit margin was barely better than a coin. The reason is the same one again: with three distinct costs a great many alignments have a margin of exactly zero, and a margin of zero cannot rank anything.

The split behind that number is worth reading directly, because the previous page had to report it as a rate rather than as a rule.

Share of test alignments each refit moves, on a tie and not, matrices rounded to eighth bits15 of 200 test alignments under 400 pairs at stay 0.9 are within 0.01 of a tie. A resample, 400 near pairs moves 15 of those and 21 of the other 185. 40 pairs at stay 0.9 moves 15 of those and 45 of the other 185. 8 pairs at stay 0.9 moves 5 of those and 59 of the other 185. 400 pairs at stay 0.7 moves 4 of those and 91 of the other 185. 400 pairs at stay 0.5 moves 6 of those and 109 of the other 185.alignments moved, per cent of the groupa resample, 400 near pairs, on a tie100%15 of 15not on a tie11%21 of 18540 pairs at stay 0.9, on a tie100%15 of 15not on a tie24%45 of 1858 pairs at stay 0.9, on a tie33%5 of 15not on a tie32%59 of 185400 pairs at stay 0.7, on a tie27%4 of 15not on a tie49%91 of 185400 pairs at stay 0.5, on a tie40%6 of 15not on a tie59%109 of 185margins under 400 pairs at stay 0.9on a tie: a margin under 0.01
Fig. 6 The share of alignments each refit moves, split by whether the alignment was on a tie under the eighth-bit fit. Fifteen of the 200 are. A resample moves a large share of those fifteen and a small share of the other 185, and the same split holds for every refit down to the one fitted to a corpus of a different divergence.

Under the eighth-bit fit a resample moves all fifteen of the alignments on a tie and 21 of the other 185 — a hundred per cent against eleven. At whole bits the same refit moved 30 of 63 and 3 of 137, which is a good prediction in the aggregate and a poor rule for any individual alignment: being on a tie left the odds under a half. The finer lattice turns the same statistic into something a report could carry beside an alignment, which was the use the parameter plane has few answers proposed for it in the first place.

And what the lattice does not do is suppress the refits that carry real information. The matrix fitted to a corpus of a different divergence moves 115 alignments at whole bits and 115 at eighth bits — the same number, and the largest change it makes to any single cost falls only from 3.00 to 2.63. The fine lattice removed 48 of the 63 ties and left the far refit’s effect untouched. So the two are separable: most of what the rounding was doing was manufacturing coincidences among the costs, and none of it was carrying the difference between two corpora.

The repair that does not work at all

The third repair the previous page named was randomised rounding: round each entry up or down to a whole bit with a probability set by its fractional part, so that the entries stop landing on the same lattice in the same direction. Each entry here is given a fixed threshold drawn from a hash of the entry and a seed, and rounds up when its fitted value’s fractional part exceeds that threshold.

Randomised rounding, six draws: 46 to 63 alignments on a tie, and 3 of the six draws absorb a resample entirely200 test alignments under a matrix fitted to 400 pairs at stay 0.9. For each way of rounding the six fitted substitution costs: how many of them stay distinct, how many test alignments sit within 0.01 of a tie, and the chance that an alignment a resample of the same corpus moved had a smaller distance to a tie than one it left alone. Seed 7: 3 distinct costs, 63 on a tie, the resample moved 33 and the prediction is 0.858. Seed 13: 2 distinct costs, 46 on a tie, the resample moved 16 and the prediction is 0.871. Seed 101: 2 distinct costs, 46 on a tie, the resample moved no alignment at all. Seed 555: 3 distinct costs, 52 on a tie, the resample moved 35 and the prediction is 0.852. Seed 999: 2 distinct costs, 46 on a tie, the resample moved no alignment at all. Seed 20260919: 2 distinct costs, 46 on a tie, the resample moved no alignment at all.alignments on a tiedistinct costs · predictionseed 7633 of 6 · 0.86seed 13462 of 6 · 0.87seed 101462 of 6 · nothing movedseed 555523 of 6 · 0.85seed 999462 of 6 · nothing movedseed 20260919462 of 6 · nothing moved200 test pairs, 16 directionsbar: alignments within 0.01 of a tie
Fig. 7 The same measurement under six draws of the randomised rounding. The number of the six fitted costs left distinct is two or three, never more; the alignments on a tie run from 46 to 63; and on three of the six draws a resample of the same corpus produces an identical matrix and moves no alignment whatever.

Randomised rounding cannot work here and the reason is arithmetic rather than luck. Rounding to whole bits leaves at most as many distinct values as there are whole numbers in the range the fitted costs occupy, and these six occupy the range from 1.67 to 4.88 — four whole numbers, of which the floor at one bit and the clustering leave two or three reachable. Which entry goes to which of them is what the draw decides, and the count is what the ties depend on. Randomising which value an entry collapses to cannot increase how many values there are.

The plate also shows the failure that looks like a success. On three of the six draws the resample moves nothing at all, which reads as perfect stability and is nothing of the kind: the two matrices are identical, so the aligner has become insensitive to information the refit genuinely carried, and a reader comparing two corpora would conclude they agree when what agreed was the rounding. That is the same shape of error as a distance divided by a length — a quantity that answers a question it was not asked.

What is being claimed, and at what scale

The alignments themselves are what is being compared, not their scores. Two matrices put their totals in two different currencies and a score under one says nothing about a score under the other, so every “moved” count above is a comparison of which columns came out — the convention the matrix a corpus wrote established and the only comparison available. It means a refit that changes every score and no alignment counts as changing nothing, which is the right answer for a user reading an alignment and the wrong one for a user reading a score.

Six entries is a small number and the argument depends on it. This alphabet has four letters and so six unordered substitution pairs. On a twenty-letter alphabet there are 190, spread over a wider range, and whole-bit rounding would leave perhaps eight or ten distinct values rather than three — so the collapse measured here would be much milder and the half-bit inversion might not appear at all. The mechanism generalises; the numbers do not, and nothing here has been measured on a larger alphabet.

The gap costs were not rounded and were not swept. A gap character costs three bits in every matrix here, written down rather than fitted, so the lattice touches six of the seven costs and the seventh is a constant. That is a real limit: a fitted gap cost would land off the lattice like everything else, and a model that charges a gap by its length rather than per character — the three tables of a cell that has to know where it is — has two gap parameters to round rather than one.

The margins are upper bounds. A margin is the smallest change, over sixteen random directions in the seven-dimensional space of costs, that moves the alignment; a nearer boundary may lie along a direction not tried. The site’s check states that no alignment moves under a refit smaller than its measured margin and requires the measurement to refuse it, which it does.

A tie at zero and a tie that no cost can break are different things, and the counts above are of the first. Around 170 of the 200 pairs have more than one optimal alignment, and most of those alignments differ only in where a gap sits inside a run of identical letters — they carry identical counts of every substitution and cost the same under every matrix there is. Those are not affected by any lattice and are not what is being counted.

And the grain is a choice about the model, not about the arithmetic. An eighth-bit matrix is not more accurate than a whole-bit one. The fitted numbers have their own sampling error — a resample of the same 400 pairs moves entries by up to half a bit — so a lattice of an eighth is resolving differences much smaller than the fit can distinguish. What it buys is that the reported alignment stops being an artefact of the rounding, and that an alignment’s distance to a tie becomes a usable warning. Both are properties of the report rather than of the truth.

What to ship

The measurements support one recommendation and refuse two.

Round to a lattice fine enough to keep every fitted entry on its own multiple, and check that it does rather than assuming it. For this corpus that is an eighth of a bit and it is not an eighth of a bit in general; the check is the one the plate above performs, which is to count the distinct values after snapping and compare it against the number of entries. That check costs nothing and it is the only thing on this page that transfers to another alphabet unchanged.

Do not choose the grain by fineness alone, which is the rule the previous page assumed and which halving the grain refutes. A grain of a twentieth of a bit leaves five of the six entries distinct and 20 alignments on a tie, and a grain of an eighth leaves six and 15 — the finer lattice is the worse one.

Do not randomise. The scheme cannot add distinct values and its behaviour is set by the draw, and on half the draws tried it made the aligner blind to a resample while leaving it fully sensitive to a change of corpus, which is an instrument whose reading cannot be interpreted.

There is a fourth option this page has not measured and should name: do not round at all. Nothing forces a substitution matrix onto a lattice except convention and the wish to compare integers, and a modern fill compares doubles at the same speed. The reason the convention persists is that a whole-bit matrix is legible — a reader can see that a transition costs two and a transversion five — and a distance that is not a distance is the page about what else gets assumed when a cost model looks simple. The finding here is that the legibility is paid for in ties, and that an eighth of a bit buys most of it back.

Still open: the grain a corpus chooses for itself

Every lattice on this page was written down in advance and the corpus was not consulted. That is the wrong way round, since the whole finding is that a lattice is good or bad according to where the fitted numbers happen to fall.

A fit knows where its numbers are. It could choose its own lattice: the coarsest grain that keeps every pair of entries on different multiples, or the coarsest that keeps apart every pair the corpus has enough evidence to separate — which is a different and better rule, because two entries nineteen thousandths of a bit apart are not two entries the data has distinguished, and separating them is resolving noise.

The measurement that follows computes both grains for a series of corpora, asks how coarse they turn out to be and how much they vary between resamples of the same corpus, and sets the alignments-on-a-tie count under each against the fixed grains here. The question it has to answer is whether a lattice chosen from the data inherits the data’s sampling error — a grain that changes when the corpus is resampled is a fourth source of the instability this page and the two before it have been measuring, and it would be one introduced by the repair.

Named alongside this one

Essays reaching for the same objects. Nobody chose these; they are what the concept index makes visible.

The objects this essay names

Each one links to every other essay that touches it.

AlignmentCorpusCost modelEstimatorFittingHonest limitMeasurementOptimalityParameter choiceRoundingSensitivity analysisSubstitution matrix