Generator

A 4×32 Count-Min table after 40,000 items

Rendered here at the parameters it defaults to, with every essay that calls it — which is the same list as the blast radius of changing it.
A 4×32 Count-Min table after 40,000 itemsEach cell is a counter and each row has its own hash, so a key lands in exactly one cell per row — the four ringed cells are where key 0 went. The darker a cell, the larger its count. Key 0 truly occurred 6,793 times; its four cells hold 7,315, 7,467, 7,423, 7,660, and the estimate is the smallest of them, 7,315. Every cell is the key's count plus whatever else collided there, so every cell is an overestimate and the minimum is the least bad one. The whole table is 4,096 bits against 86,265 for an exact counter.hash rowh1h2h3h4h1 → cell 30: 7,315h2 → cell 29: 7,467h3 → cell 19: 7,423h4 → cell 4: 7,660key 0 occurred 6,793 times · the minimum of the four is 7,315 · over by 522the additive bound at this width is e/w × N = 3,3984×32 counters · 4,096 bits · Zipf s = 1.1exact would take 86,265 bits

A 4×32 Count-Min table after 40,000 items

Each cell is a counter and each row has its own hash, so a key lands in exactly one cell per row — the four ringed cells are where key 0 went. The darker a cell, the larger its count. Key 0 truly occurred 6,793 times; its four cells hold 7,315, 7,467, 7,423, 7,660, and the estimate is the smallest of them, 7,315. Every cell is the key's count plus whatever else collided there, so every cell is an overestimate and the minimum is the least bad one. The whole table is 4,096 bits against 86,265 for an exact counter.

Drawn at 700 × 272, wide on the page. Everything above is what sketch-state returns with no arguments; the caption is the generator's own, computed from the numbers in the drawing rather than written beside it.

9 essays call sketch-state. The drawing above is what it returns with no arguments at all; every call below passes it something, because a placement that passes nothing draws whichever member of the family the generator happens to default to rather than the one its essay argues about — which is what optcheck and figfill exist to catch.

Where it is called

Changing this generator changes every one of these figures.

hash rowh1h2h3h4h1 → cell 30: 10,433h2 → cell 29: 10,624h3 → cell 19: 10,575h4 → cell 4: 10,895key 0 occurred 9,579 times · the minimum of the four is 10,433 · over by 854the additive bound at this width is e/w × N = 5,0974×32 counters · 4,096 bits · Zipf s = 1.1exact would take 162,288 bits One pass, and no room

A count that is never under

01325leading-zero rank keptregister, 0 to 255estimate 7,107truth 7,368error -3.54%0 still empty256 registers × 5 bits = 1,280 bitspredicted ±6.50% One pass, and no room

A count read off the leading zeros

0.010.10.11Jaccard index of the two setsrelative error of the intersectionas wrong as the answerinclusion–exclusionthe minimum valuesHyperLogLog p = 12, 20,480 bits · bottom-4,096, 131,072 bitstruth from a hash map over 200,000 keys One pass, and no room

The error of a difference

011228101214161820universe size ubits of statea u-bit bitmaplog₂ C(u, u/2)⌈log₂(u+1)⌉, a counterat u = 12: 924 subsets, 8 bitstwo collide → answers 6 and 7floor computed exactly · collision found by exhaustion at u = 12floor 9.85 bits The floors

The floor under a summary

1101001,0000.111010010³true count of the keyrelative errorheaviest keyrarest key4×64 counters · 8,192 bits · Zipf s = 1.1 · 3,528 distinct keys at 702 positions4.11% to 34100% What is taught wrongly

The guarantee that is one query wide

key 05,416short by 4,163key 1462short by 4,154key 31short by 2,099key 71short by 943key 19401short by 3counter held (bar) against true count (tick)12 counters · 768 bits · no randomnessbound N/(k+1) = 4,615 Structures

The items that survive k counters

Count-Min 4×64exact0 under200 overrms 303Count-Sketch 4×64-2,774-1,38701,3872,774120 under80 overrms 256cash register · insertions only, Zipf s = 1.1 · counts exact8,192 bits each Structures

A sketch that is allowed to be under

1,8103,6205,4297,239010,00020,00030,00040,000arrivals so farcount of key 1 in the last 4,096Misra-Gries, no clockblocks of Misra-Griesthe truth, and the ring buffera heavy hitter that stops · sampled every 5006,493 claimed, 0 true Structures

The count that outlives its arrivals

2585167741,032020,00040,000arrivals so farcountSpace-Saving's floorMisra-Gries's decrementsboth 93840,000 prefixes, 0 disagreementsk = 32 against k = 31 What is taught wrongly

Two structures that are one

The library, page 4 of 5 — where sketch-state sits