| ISSUE 423/456 · COMPUTER SCIENCE |
~4 MIN |
FOUNDATION / COMPUTER SCIENCE · READING DATE 2027-11-28 · NOVEMBER 2027 — MATTER AND COMPUTATION LIMITS
A counter can save space by skipping most updates
START HERE
A busy service may want the scale of its traffic without preserving an exact event count. An approximate counter stores a small summary from which it estimates how many events have arrived. A Morris counter is one version that makes its stored number increase less often as the total grows.
|
/ WHY NOW
Ordinary counting spends more bits as its maximum exact value increases. If a rough statistical answer is acceptable, a carefully chosen random update rule can cover a much larger range with the same small stored integer.
|
/ THE IDEA
Let the stored integer be c, starting at zero. For each arriving event, increase c by one with probability 2 raised to minus c; otherwise leave it unchanged. The reported estimate is 2 raised to c, minus one. Small values update often, while large values update rarely and represent larger jumps in the estimated count. The probability and jump size compensate: if an update happens, the estimate rises by 2^c, but the chance of that update is 1/2^c. Their product is one expected estimated event per real arrival.
THE FORMAL IDEA
estimate = 2^c − 1; update probability = 2⁻ᶜ
| c = stored non-negative integer, not the exact event count. | | The estimate counts events; the probability has no units. The rule describes independent random choices on arrivals, with enough stored range to avoid overflow. |
|
RUN THE TINY EXAMPLE
Change one thing. Predict what happens.
At c = 2, the estimate is 2² − 1 = 3. The next event leaves the estimate at 3 with probability 3/4 or raises it to 7 with probability 1/4. Expected next estimate = (3/4) × 3 + (1/4) × 7 = 4. Change c to 3: the estimate is 7 and update probability falls to 1/8, while the possible new estimate is 15.
|
At c = 3, the expected increase is (1/8) × (15 − 7) = 1 again. This does not mean each individual estimate is accurate: one run may stay still for many events and then jump. The arithmetic concerns an average over the counter’s random choices.
/ SO WHAT?
Storing c rather than the estimate is the memory saving. An integer c that grows like the logarithm of the traffic total itself needs only enough bits to represent that smaller integer. Practical approximate counters can use different bases or multiple copies to improve accuracy, paying additional storage for tighter uncertainty.
ONE CAVEAT |
| A single basic counter is noisy and unsuitable when every event must be billed or reconciled exactly. Accuracy guarantees require specifying the variant, random choices, range and failure probability; statistical unbiasedness is not a per-run error bound. |
KEEP THIS
When only traffic scale is needed, rarer random updates with larger represented jumps can exchange exactness for a dramatically smaller stored count.
|
NEXT: Why warm syrup moves more easily but warm gas may not
|