* datakit: how likely is a published number wrong? A new package, moved from Solon: checks a figure against its own series, the parts of its table and a second publisher, and a seeded benchmark that scores the checks on planted mistakes. Private until its first publish, which needs one npm sign-in. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvTCDbJAYNKQpNyKzz * datakit: a figure is not compared with neighbours years away Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvTCDbJAYNKQpNyKzz * datakit: publishable (0.1.0) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019MDtmvTCDbJAYNKQpNyKzz --------- Co-authored-by: Claude <noreply@anthropic.com>
@bitbaum/datakit
How likely is a published number wrong?
A figure read from a statistics office or an international database is a claim
by its publisher, and publishers make mistakes: an empty cell exported as 0,
a series broken by a change of currency, a sign or a digit lost. datakit looks
at a figure beside the rest of its own series, the parts of its table and a
second publisher, and says how likely it is to be such a mistake, with the
check that caught it. It judges nothing about the subject of the data.
No dependencies, no I/O, pure functions: the same input gives the same answer.
import { assessSeries, stateOf } from "@bitbaum/datakit";
// OECD, Latvia's top income tax rate, per cent (read 2026-11-28).
const doubts = assessSeries(
[
{ period: 2022, value: 31.155779 },
{ period: 2023, value: 31.155779 },
{ period: 2024, value: 31.155779 },
{ period: 2025, value: 0 },
// …earlier years
],
{ fixedByLaw: true },
);
// → [{ period: 2025, check: "zero_in_nonzero_series", likelihood: 0.9, expected: 31.16 }]
stateOf(0.9); // "held"
What it checks
| Function | Question |
|---|---|
assessSeries(observations, context) |
Is a figure unlike the rest of its own series? Not a number, outside the measure's band, a zero where nothing is near zero, a lone figure of the opposite sign, a spike that returns, a newest figure far from everything before. |
checkIdentity(total, parts, { grain }) |
Do the parts of the publisher's own table add up to its total, within rounding? |
compareSources(a, b, { relative }) |
Do two publishers agree, period by period? |
runBenchmark(series, { seed }) |
How many planted mistakes do the checks catch, and how many true figures do they wrongly doubt? |
A likelihood of HOLD_AT (0.9) or more means the figure should not be shown;
from FLAG_AT (0.5) it should be shown and marked. The likelihoods are
judgements written beside each rule in src/checks.ts, not measured
frequencies; the benchmark is the measurement.
The context says what only the caller knows: the band the measure can lie
in, whether it is fixed by law (a tax rate moves in steps), and whether
nothing is an ordinary value (canBeZero: dwellings built in a village).
Every rule comes from a real figure
The tests name them: Latvia's top income tax rate and Venezuela's government consumption (publishers' zeros, held); Iceland's 2016 capital transfers (a real spike, marked and shown); Lithuania's balanced budget, Iceland's years without a homicide and a commune of 86 people where no dwelling was built (real zeros, left alone). A mistake found in any app becomes a test here.
First score
On the 2,437 national series of solon.orangecat.ch (65,918 figures,
2026-11-28): no true figure wrongly held, 5 marked. Of planted mistakes held:
thousand-fold 99.6 %, hundred-fold 92.0 %, sign 92.4 %, zero 83.1 %, ten-fold
74.2 %; a tenth of the size is only marked (77.8 %) and two swapped digits
mostly pass (13.6 % marked). Those need checkIdentity or compareSources.
Install
pnpm add @bitbaum/datakit