Terminal Digit
Tests whether the last digits of the plotted numbers in a chart are uniformly distributed, as real measured data should be, and whether 0 and 5 are over-represented, the signature of human rounding. Axis tick labels are removed first, because they are rounded scale values whose terminal digit is 0 or 5 by construction. It works from optical character recognition (OCR) of the plotted numbers, with no model.
Technical description
G11 is a deterministic screen built on a robust forensic fact: in genuine measured data the terminal (last) digit is inconsequential and therefore uniformly distributed across 0 to 9, whereas numbers that people invent or record by hand are not uniform, because humans cannot generate uniform digits and tend to round to 0 and 5. The indicator extracts the numbers by OCR, removes the axis tick labels (whose terminal digits are 0 or 5 by design and would force a non-uniform result), takes the terminal digit of each plotted value, and tests the distribution for uniformity with a chi-squared test, adding a check for an excess of 0 and 5. The deviation maps to a 0 to 5 score. It requires the image to be at least 32 by 32 pixels and at least thirty terminal digits after axis labels are removed.
How it works
The indicator runs deterministically at Layer 1 using extract_numbers (OCR) and detect_axes.
The first step removes axis tick labels. A number whose bounding-box center (x + w/2, y + h/2) lies to the left of the detected y-axis line or below the detected x-axis line, with the fallbacks center_x <= 0.12 · W and center_y >= 0.88 · H, is an axis tick label and is excluded, because axis ticks end in 0 by the spacing of the scale and would by themselves force a non-uniform terminal-digit distribution.
The terminal digit is then taken from each plotted value: for an integer or a value with exactly one decimal place it is the last digit of the integer representation (for one decimal place, the digit after the point), and values with more than one decimal place are skipped. The test runs when at least thirty terminal digits remain.
The uniformity test treats the ten digits as equally likely under honest data. With O_d the count of terminal digit d in {0, ..., 9} and n = Σ_{d=0}^{9} O_d the total, the uniform expectation is E_d = n / 10 for every digit. The Pearson chi-squared statistic is χ² = Σ_{d=0}^{9} (O_d − n/10)² / (n/10), and the test returns a p-value: a p-value above 0.10 scores 0.0, a value 0.01 < p <= 0.10 scores 2.0, and a value p <= 0.01 scores 4.0, with a finding at warning or error severity accordingly.
The zero-and-five test targets manual rounding. The combined proportion of terminal digits equal to 0 or 5 is z = (O_0 + O_5) / n, whose uniform expectation is 0.20; a value z > 0.35 adds 1.0 at warning severity.
The score is capped at 5.0. The metadata records the terminal-digit count n, the total numbers found and how many were excluded as axis labels, the chi-squared p-value, the per-digit counts O_d, and the zero-and-five proportion z.
Score thresholds
| Score | Meaning |
|---|---|
| 0 to 1 | Terminal digits are uniformly distributed, as expected for measured data. |
| 2 to 3 | A non-uniform terminal-digit distribution, or an excess of 0 and 5. |
| 4 to 5 | A strongly non-uniform distribution, reinforced by zero-and-five rounding. Consistent with manual fabrication or heavy rounding. |
Why this matters
Terminal-digit analysis is one of the oldest and best-validated forensic tests for invented numbers. Mosimann and colleagues showed experimentally that people asked to produce random digits cannot: their digits depart from uniformity, which makes the terminal digits of fabricated data a detectable anomaly, and they developed the test specifically for examining questioned scientific data [1, 2]. Beber and Scacco formalised the same idea for election returns, showing that fair processes yield last digits that occur with equal frequency while manipulated counts betray the human biases of digit preference and avoidance of repetition [3]. The complementary signal, a surplus of 0 and 5, is the well-documented phenomenon of terminal-digit preference: when people record or round measurements by hand they favour 0 and 5, and this preference has been used to flag fabrication in clinical-trial baseline data [4]. G11 applies both signals to the numbers a chart plots, with the essential precondition that the numbers be measured data rather than the axis scale, which is why the tick labels are removed before the digits are counted. The result is a model-free screen for a specific digit anomaly, distinct from the first-digit Benford test, which examines leading rather than trailing digits.
Limitations
G11 needs at least thirty terminal digits read by OCR from the plotted data after axis labels are removed, so charts that print few values, or whose numbers OCR cannot read, are not scored, and most ordinary bar and line charts do not provide enough plotted values. The test assumes the terminal digit is inconsequential, which fails for deliberately rounded or coarsely measured data, where an honest excess of 0 and 5 is expected, so the zero-and-five signal is a cue that warrants review rather than proof. Values with more than one decimal place are skipped, which can shrink the sample. The axis-label split is positional and assumes a conventional left y-axis and bottom x-axis. First-digit conformity is screened by the Benford indicator, and mean-and-standard-deviation plausibility by the GRIM indicator, so G11 stays on the terminal-digit test.
Theoretical background
G11 rests on the principle that the least significant digit of a genuine measurement carries no information and is therefore uniform, while a human-generated digit is not. Two independent biases break uniformity: a general inability to produce uniform digits, documented in controlled experiments, and a specific preference for 0 and 5 when rounding. The chi-squared test detects the first as a departure from a flat distribution, and the zero-and-five proportion detects the second directly. The decisive input choice is to exclude the axis scale, whose terminal digits are fixed at 0 or 5 by the spacing of the ticks and would otherwise manufacture the very non-uniformity the indicator hunts for. Both signals are properties of the plotted numbers rather than learned fingerprints, which keeps the screen independent of how the chart was produced.
References
- Mosimann JE, Wiseman CV, Edelman RE. Data fabrication: Can people generate random digits? Accountability in Research. 1995;4(1):31-55. DOI: 10.1080/08989629508573866
- Mosimann JE, Dahlberg JE, Davidian NM, Krueger JW. Terminal digits and the examination of questioned data. Accountability in Research. 2002;9(2):75-92. https://www.researchgate.net/publication/233050759_Terminal_Digits_and_the_Examination_of_Questioned_Data
- Beber B, Scacco A. What the Numbers Say: A Digit-Based Test for Election Fraud. Political Analysis. 2012;20(2):211-234. https://www.cambridge.org/core/journals/political-analysis/article/what-the-numbers-say-a-digitbased-test-for-election-fraud/AD86EEBC2F199E2C8A2FD36BD3799DF9
- Al-Marzouki S, Evans S, Marshall T, Roberts I. Are these data real? Statistical methods for the detection of data fabrication in clinical trials. BMJ. 2005;331(7511):267-270. DOI: 10.1136/bmj.331.7511.267