The data that is not a number

The entropy that cannot see a copy

Two copies of a text have exactly the same symbol statistics as one, so every entropy on this site doubles when the second copy arrives and the second copy carries no information at all. The number of runs in the Burrows-Wheeler transform is 224 at two copies and 224 at thirty-two.

Take five hundred and twelve characters of English-like text and write it out thirty-two times.

The collection is now 16,384 characters and contains 512 characters of information. Every measure of compressibility this collection has built says otherwise.

copies characters nH3n \cdot H_3 rr
1 512 307 222
2 1,024 609 224
4 2,048 1,212 224
8 4,096 2,417 224
16 8,192 4,827 224
32 16,384 9,647 224
The entropy cannot see a copy, and the run count sees nothing elseEnglish-like of 512 characters, repeated. The upper curve is n·H₃ — the bound every compressed self-index on this site is measured against — which grows 15.8x across a collection that grew 16.0x, because the distribution of symbols in three-symbol contexts is the same in two copies as in one and the second copy is charged full price. The lower curve is r, the number of equal-letter runs in the Burrows-Wheeler transform, which is 224 at two copies and 224 at 32 — it does not move at all. The copies here are identical. Both axes are logarithmic.1,00010,00010³10⁴bits · runs12481632characters in the collection · copies aboven·H₃, bitsr, runs in thetransformEnglish-like · base 512 · divergence 0n·H₃ x15.8 · r x1.00
Fig. 1 The entropy bound and the run count against the same growing collection. One of them grows by a factor of sixteen and the other does not move.

nH3n \cdot H_3 grows 15.8× across a collection that grew 16×. The second copy is charged full price, and so is the thirty-second.

Why the entropy has to behave that way

HkH_k is a function of the distribution of symbols in kk-symbol contexts. Concatenate a text with itself and every context occurs twice, every symbol following it occurs twice, and the distribution is identical to two decimal places at the join and exactly identical away from it.

Hk(TT)=Hk(T)2nHk(TT)=2nHk(T)H_k(T \cdot T) = H_k(T) \quad\Longrightarrow\quad 2n \cdot H_k(T\cdot T) = 2 \cdot n H_k(T)

So an index bounded by nHk+o(n)n H_k + o(n) must double. Not because the analysis is loose — the bound is true and the structures this collection built reach it — but because the quantity is the wrong one. Everything above the third order does the same thing, and going to H8H_8 or H16H_{16} does not help: the repeat here is 512 characters long, and no fixed-order context model can see a correlation at that distance.

This is not a defect in the analysis. It is a defect in what is being counted, and it is the reason the indexes built for genome collections, document version histories and web crawls are not built on entropy at all.

The floor under one stream, at 5 model ordersH_k is the entropy of the next symbol given the k before it, measured from the stream's own frequencies. Every value here is a correct floor for the same data. The uniform source has nothing to condition on and stays at 3.00. The Markov source gives up 2.06 bits at order 1 and almost nothing after. Quoting "the entropy of this file" without an order names none of these.H0H1H2H3H4model order — symbols of contextbits per symbol0.02.14.2Uniform over 8 symbolsOrder-1 Markov chainWords from a fixed vocabulary32,768 symbols · at H4 the deepest source has 709 contexts, 0 seen oncemodels: orders 0, 1, 2, 3, 42.06 bits found by one symbol of context
Fig. 2 The floor under one stream at five model orders, from the field that built it. Every order here is a statement about contexts of a fixed width, and a text repeating itself at five hundred characters is invisible to all of them.

Two measures that are not entropies

rr, the number of equal-letter runs in the Burrows-Wheeler transform. The transform sorts every rotation of the text and reads off the last column, so characters that precede similar contexts end up adjacent. Repeat a text and every context occurs twice, so every character that would have been alone in the last column is now beside its twin — and the run count barely moves.

zz, the number of phrases in the greedy self-referential parse. Each phrase is the longest prefix of what remains that has occurred starting earlier in the text; the occurrence may overlap the phrase itself, which is what makes a thousand identical characters two phrases rather than five hundred. The second copy of a text is one phrase.

copies rr zz nH3n \cdot H_3
1 222 160 307
2 224 161 609
8 224 161 2,417
16 224 161 4,827

Both are flat and both move by one between the first copy and the second — the join, and the sentinel’s neighbourhood.

Neither is an entropy and neither is a function of a symbol distribution. Both are properties of the sequence, and the difference between “the distribution of symbols in this text” and “this text” is the whole subject.

What r counts is the differences

Repetition in the real world is not exact. Version histories, genomes and web crawls hold copies that have drifted, so the useful question is what happens between the two ends.

Hold the collection at eight copies and 4,096 characters and substitute a fraction of each copy after the first. The length never changes.

substituted positions edited rr zz nH3n \cdot H_3
0 0 224 161 2,417
0.2% 7 264 181 2,468
0.5% 18 328 206 2,515
1% 36 430 246 2,623
5% 179 1,061 521 3,179
25% 896 2,746 1,273 4,154
The run count follows the differences, and the entropy barely movesEight copies of 512 characters of English-like, 4,096 in total at every point, with each copy after the first substituted at the rate on the horizontal axis. Nothing about the length changes. r rises from 224 to 3,663 — a factor of 16.4x — while n·H₃ moves by 0.8x, and most of that is the substitutions flattening the context distribution rather than anything to do with repetition. What r counts is the number of places the copies differ. Both axes are logarithmic.1101001,00010³positions substituted, in totalbits · runsn·H₃, bitsr, runs8 copies · 4,096 characters at every pointr x16.4 · H₃ x0.76
Fig. 3 The three measures against the number of positions edited, on a collection whose length never changes. The run count rises by more than twelve times and the entropy bound by less than two.

rr rises 12.3× across the sweep and nH3n H_3 rises 1.72×. And the entropy’s rise is mostly not about repetition at all: substituting characters at random flattens the context distribution, which raises H3H_3 for reasons that would apply to a single copy.

So rr is counting the differences between the copies. Seven edits take it from 224 to 264 — about six runs per edit, which is roughly what breaking a run in the transform costs — and the relationship holds across two orders of magnitude of edit count.

That is the property the whole family of repetition-aware indexes is built on, and it is a measurement here rather than a citation.

Six runs an edit, and why that number

The rate at which rr rises with the edit count is worth deriving rather than fitting, because the derivation says what the measure is actually counting.

Substitute one character in one copy. That character occupied a position in the transform’s last column, inside a run of characters that all preceded the same context; changing it splits that run into three — the part before, the changed character alone, the part after. That is two extra runs.

But the substitution also changes the context of the characters around it, so a handful of neighbouring positions move elsewhere in the sorted order and each of them splits a run where it lands. How many depends on how deep the contexts have to go before the two copies diverge, which on English-like text is a small number.

Measured across the sweep:

positions edited extra runs runs per edit
7 40 5.71
18 104 5.78
36 206 5.72
72 354 4.92
179 837 4.68
896 2,522 2.81

Flat at 5.7 across a fivefold change in the edit count, and then falling by half.

The falling half is the measure saturating and it is worth reading. Once the edits are dense enough to land in runs that other edits have already broken, an edit splits a run that was already short and buys fewer new runs. At 25% divergence the copies are barely related and rr is approaching what eight unrelated texts would give — 2,746 against 3,663 — so the rate has nowhere left to go.

That gives the practical form of the claim, with its condition attached: for a collection whose copies are close, rr is of order +d\ell + d rather than of order cc\ellcc documents of length \ell differing in dd places — and it is the cc dropping out that makes the whole family of repetition-aware indexes possible. For a collection whose copies are not close, rr is of order cc\ell and there is nothing to exploit, which is the same statement read from the other end.

Where the empirical entropy stops being a measurement

Push the divergence to the end — substitute every position of every copy after the first, so the eight documents are unrelated — and something happens that is worth an entire section, because it is a trap rather than a result.

rr contexts seen of them once nH3n \cdot H_3
eight identical copies 224 224 0 2,417
eight unrelated texts 3,663 3,012 77% 1,841

The collection got sixteen times less repetitive by the run count, and the measured H3H_3 fell by a quarter.

The reason is that an empirical HkH_k is a measurement of the sample. A text of 4,096 characters over twenty-one symbols has 9,261 possible three-symbol contexts; the unrelated collection contains 3,012 of them and 77% occur exactly once. A context seen once has zero conditional entropy by definition — whatever followed it, followed it every time — so the estimate is reading its own sparsity and reporting it as compressibility.

The condition is computable before any text is looked at: the estimate is a measurement while nσkn \gg \sigma^k and an artefact when it is not. On the texts this collection has been measuring, H3H_3 over twenty-one symbols wants far more than four thousand characters:

characters of English-like text contexts of them once H3H_3
512 159 28% 0.600
2,048 224 22% 0.849
8,192 273 9% 0.951

H3H_3 rises with the length of the text, which is the wrong direction for a property of a source and the right direction for an estimate escaping its own sparsity. Every earlier essay in this field that quotes an H3H_3 is quoting a number measured on eight or sixteen thousand characters, where the singleton share is under a tenth — and the assertion carried with this machinery now requires that ratio rather than assuming it.

Three measures, three orderings

Five texts, 2,048 characters each, measured every way.

text rr zz H3H_3
repetitive 129 104 0.280
English-like 677 385 0.849
DNA-like 1,531 463 1.937
periodic 1,781 721 1.720
uniform 1,788 718 1.744
Two measures of repetition, five texts, two orderingsEach bar is the number of runs in the transform of 2,048 characters; the number beside it is z, the phrases in the self-referential parse of the same text. Both fall when a text repeats and neither is a function of the other — ordered by r the texts run repetitive, english, dna, periodic, uniform, and ordered by z they run repetitive, english, dna, uniform, periodic. Ordered by H₃, which is what every earlier size on this site follows, they run repetitive, english, periodic, uniform, dna. Three measures of "how compressible", three orderings, and a claim that one text is more compressible than another is not a statement until one of them is named.a text that repeats itself129z = 104 · H₃ 0.28English-like677z = 385 · H₃ 0.85four symbols, uniform1,531z = 463 · H₃ 1.94periodic, period 171,781z = 721 · H₃ 1.72eight symbols, uniform1,788z = 718 · H₃ 1.74r, runs in the transform2,048 characters of eachone unit = one run
Fig. 4 The run count as bars with the phrase count and the entropy printed beside each. Three measures of “how compressible”, and no two of them put these five texts in the same order.

Ordered by rr: repetitive, English, DNA, periodic, uniform. Ordered by zz: repetitive, English, DNA, uniform, periodic. Ordered by H3H_3: repetitive, English, periodic, uniform, DNA.

The DNA-like text is the interesting row. It has the highest third-order entropy of the five — over four symbols drawn independently there is nothing for a context model to learn, so H3H_3 is nearly log24=2\log_2 4 = 2 — and it sits in the middle by both repetition measures, because four symbols in two thousand characters produce plenty of accidental repeats.

Periodic and uniform swap places between rr and zz, which is the sharpest available statement that the two repetition measures are not the same quantity: one of them counts places where the transform changes character and the other counts phrases in a parse, and no argument makes them agree.

So “this text is more compressible than that one” is not a statement until a measure is named. This collection has been careful about that for entropy orders since the text field opened; the same care has to extend to a second axis now that there is one.

Why the transform is where the runs are

It is worth being precise about why the transform is the place to count runs, because the text itself has runs too and they are useless.

The transform sorts every rotation of the text and takes the last column. Two positions land next to each other in that column exactly when the text that follows them is similar — the sort key is the suffix, and the character reported is the one before it. So a run in the last column is a set of positions all preceded by the same character and all followed by similar text, which is precisely the pattern a repeated passage creates.

The text’s own runs measure nothing of the kind. On the same collection the transform has a fifth as many runs as the text does in the stretch drawn, and the text’s count would be identical if the copies were shuffled into a different order — which would destroy nothing about the repetition and everything about the transform’s runs.

And the transform’s symbol distribution is the text’s, exactly. This field measured that two essays ago and treated it as a curiosity: the transform is a permutation, so H0H_0 of one equals H0H_0 of the other to fifteen decimal places, and a structure charging one bit per bit cannot see the transform at all. Put the two facts together and the transform’s role is precise — it converts a property invisible to a symbol distribution into one that is a symbol distribution, of runs. That is the entire mechanism, and it is why the next essay’s structure stores runs rather than symbols.

What this changes about the earlier essays

Three results in this field stand and one of them acquires a footnote.

The transform is a permutation, so H0H_0 of the transform equals H0H_0 of the text. That was measured to fifteen decimal places and is unaffected — and it is the reason rr is the right thing to count about the transform, because the run structure is exactly what the permutation creates and the symbol distribution is exactly what it does not touch.

A compressed self-index’s size orders texts as H3H_3 does. Measured across five texts and still true — of texts. Of collections it is a statement about the wrong quantity, and the next essay measures the structure that follows rr instead.

And the entropies quoted in this field are quoted at lengths where they are measurements. That was true and was not checked. It is checked now.

Seven sizes of one text: English-like, 2,048 charactersThe first five are the sizes this collection has been measuring since the text field opened, and every one of them is a function of how the symbols are distributed. The last two are functions of how the text repeats itself: r = 677 runs in the transform and z = 385 phrases in the self-referential parse, each shown at the bits it takes to write down. They are not sizes of an index — no structure here is that small — they are the information the two measures say the text contains. On this text they say 2,708 and 4,235 bits against n·H₃'s 1,738.English-like, 2,048 characters, alphabet 21the file, 8 bits a byte16,384packed, 5 bits a character10,240n·H₀7,8783.85 b/chn·H₁4,5592.23 b/chn·H₂2,2951.12 b/chn·H₃1,7380.85 b/chr·log₂(n/r) + 2r, the runs2,708z·log₂ n, the phrases4,235one unit = one bit · alphabet 21r 677 · z 385
Fig. 5 Seven sizes of one text on one scale. The first five are functions of how the symbols are distributed; the last two are functions of how the text repeats itself, and on this text they disagree with the entropies by a factor of three.
Seven sizes of one text: a text that repeats itself, 2,048 charactersThe first five are the sizes this collection has been measuring since the text field opened, and every one of them is a function of how the symbols are distributed. The last two are functions of how the text repeats itself: r = 129 runs in the transform and z = 104 phrases in the self-referential parse, each shown at the bits it takes to write down. They are not sizes of an index — no structure here is that small — they are the information the two measures say the text contains. On this text they say 774 and 1,144 bits against n·H₃'s 574.a text that repeats itself, 2,048 characters, alphabet 18the file, 8 bits a byte16,384packed, 5 bits a character10,240n·H₀7,7533.79 b/chn·H₁4,4012.15 b/chn·H₂1,3620.66 b/chn·H₃5740.28 b/chr·log₂(n/r) + 2r, the runs774z·log₂ n, the phrases1,144one unit = one bit · alphabet 18r 129 · z 104
Fig. 6 And the same seven on a text that repeats itself at long range. The entropies fall and the two repetition measures fall much further, which is the gap the next two essays are about.

How much of a collection is left, as a number

The divergence sweep has two anchors in it that are worth using together, and the essay has been reading it one column at a time.

Eight identical copies give r=224r = 224. Eight unrelated texts of the same length give r=3,663r = 3{,}663. Those are the two ends of the scale — perfect repetition and none — and every measurement in the sweep sits between them. Normalising against both says what fraction of the exploitable repetition survives a given amount of drift:

substituted rr repetition retained
0 224 100%
0.2% 264 98.8%
0.5% 328 97.0%
1% 430 94.0%
5% 1,061 75.7%
25% 2,746 26.7%

Read down that last column and the shape of the whole family becomes visible in a way no single row shows. The relationship is not linear and it is not close to linear: changing one character in four removes three quarters of what a repetition-aware structure had to work with, while changing one in a hundred removes six per cent of it. The regime where these indexes are extraordinary is narrow and it is exactly the regime real version histories and genome collections live in — successive commits differ in a fraction of a per cent, and human genomes differ in about a tenth of one.

Two things are worth saying about that normalisation before it is used for anything.

It is a measurement of this collection at this length, not a universal curve. The unrelated anchor depends on the alphabet and the length — eight unrelated DNA-like texts have a different rr than eight unrelated English-like ones — so the denominator has to be measured alongside the numerator rather than assumed. What is portable is the procedure, not the percentages.

And it says nothing about what a structure costs, only about what a measure reports. An index proportional to rlog(n/r)r\log(n/r) does not halve when rr halves, because the second factor moves the other way. A measure of repetition is not a size, and the step from one to the other is the next essay’s subject rather than this one’s — which is why the column above is labelled as repetition retained rather than as space saved.

The parse depends on the order of the documents and the runs do not

One more difference between rr and zz, and it is the one with a practical consequence attached.

The greedy parse reads the collection left to right and each phrase may only refer to text that has already been seen. So the first document is parsed against nothing and pays its full phrase count, and every later document is parsed against everything before it. Reorder the collection and the parse changes: put the most representative document first and every other document is a short chain of references to it, put an outlier first and the second document pays nearly full price before the rest can begin referring to either.

The transform has no such preference. It sorts every rotation of the whole collection at once, so which document a matching context came from is not a question the sort asks, and two orderings of the same documents produce the same runs apart from what happens at the joins. zz is a property of the collection as a sequence and rr is a property of the collection as a set, near enough, and the two measures disagree about what the object even is.

That decides something a practitioner would otherwise discover by benchmark. A version history arriving in chronological order is close to the best order for a parse, because each revision resembles the one before it; a collection of genomes arriving in whatever order the files were listed in is not, and sorting it by similarity is a real and cheap improvement to an LZ-based index and no improvement at all to a run-based one. The same rearrangement that pays for one structure is invisible to the other.

It also explains the swap in the five-text table above without appealing to anything else. Periodic and uniform change places between rr and zz because a periodic text is a sequence with a strong left-to-right structure that a parse captures directly, while its rotations sort into an order the transform finds no more compressible than noise. Two measures, two definitions of what a text is, and no argument that makes them agree — which is the section heading three above, arrived at from a different direction.

What is not measured here

Other repetition measures. rr and zz are two of several. The smallest straight-line grammar, the smallest bidirectional macro scheme and the attractor size all measure repetition and all order texts differently again; none is built here, and γz\gamma \le z and γr\gamma \le r are known relations that nothing above tests.

Which measure a structure can be built on. zz is measured here and no index in this collection is proportional to it. That is a real gap: the Lempel-Ziv index family exists and is a different construction from anything built here.

Real corpora. Every collection above is synthetic and its repetition is a parameter. That is deliberate — the dial is the instrument — and it means nothing here says what r/nr/n is for a genome collection or a source repository.

The entropy cannot see a copy, and the run count sees nothing elsefour symbols, uniform of 512 characters, repeated. The upper curve is n·H₃ — the bound every compressed self-index on this site is measured against — which grows 16.0x across a collection that grew 16.0x, because the distribution of symbols in three-symbol contexts is the same in two copies as in one and the second copy is charged full price. The lower curve is r, the number of equal-letter runs in the Burrows-Wheeler transform, which is 393 at two copies and 393 at 32 — it does not move at all. The copies here are identical. Both axes are logarithmic.1,00010,00010³10⁴bits · runs12481632characters in the collection · copies aboven·H₃, bitsr, runs in thetransformfour symbols, uniform · base 512 · divergence 0n·H₃ x16.0 · r x1.00
Fig. 7 The same experiment on a DNA-like base text, where the entropy has nothing to learn and the run count still does not move. The flatness is a property of the repetition rather than of the text being repeated.
The run count follows the differences, and the entropy barely movesEight copies of 512 characters of four symbols, uniform, 4,096 in total at every point, with each copy after the first substituted at the rate on the horizontal axis. Nothing about the length changes. r rises from 393 to 3,098 — a factor of 7.9x — while n·H₃ moves by 1.1x, and most of that is the substitutions flattening the context distribution rather than anything to do with repetition. What r counts is the number of places the copies differ. Both axes are logarithmic.1101001,00010³positions substituted, in totalbits · runsn·H₃, bitsr, runs8 copies · 4,096 characters at every pointr x7.9 · H₃ x1.13
Fig. 8 And the divergence dial over four symbols, where substituting a position is much more likely to leave the character unchanged. The run count rises more slowly for exactly that reason, and the shape is the same.

What this makes readable

Essays that name this one as a prerequisite.

Named alongside this one

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

What links here

The 8 essays that link to this one and share the most of its objects, of 12 that link here.

The objects this essay names

Each one links to every other essay that touches it.

AlphabetBurrows-wheelerCompressibilityConditional entropyContext modelEntropyFittingHonest limitLempel zivMeasurementRepetitionRun-length