🔢 Benford's Law
Explore the surprising frequency of leading digits in real-world data. Benford's Law is used to detect fraud in financial records. Interactive chi-squared goodness-of-fit test.
About Benford's Law — Leading Digit Frequency Simulator
Benford's Law is a remarkable statistical phenomenon that predicts the frequency of leading (first) digits in many naturally occurring numerical datasets. Instead of each digit 1 through 9 appearing equally at about 11%, digit 1 leads approximately 30.1% of the time, digit 2 about 17.6%, and so on down to digit 9 at just 4.6%, following the logarithmic formula P(d) = log10(1 + 1/d). This simulator lets you generate various datasets — Fibonacci numbers, powers of integers, random products, synthetic city populations — and visually compare their empirical leading-digit frequencies against the theoretical Benford curve, while a chi-squared goodness-of-fit test quantifies the match.
Benford's Law applies to any dataset that spans several orders of magnitude and is not artificially bounded, including stock prices, river lengths, national GDPs, earthquake magnitudes, and scientific constants. It has become a cornerstone of forensic accounting and fraud detection, since fabricated numbers tend to have leading digits that are too evenly distributed compared to the Benford expectation.
Frequently Asked Questions
What exactly is Benford's Law?
Benford's Law states that in many real-world datasets the probability that a number begins with digit d is P(d) = log10(1 + 1/d). This gives digit 1 a 30.1% chance, digit 2 about 17.6%, and digit 9 only 4.6%. The law holds whenever data spans many orders of magnitude and arises naturally without artificial upper or lower bounds.
How do I use this simulator to explore Benford's Law?
Select a dataset from the dropdown (Fibonacci numbers, powers of 2 or 3, random products, city populations, or uniform random for a non-Benford control), adjust the sample size with the slider, and click Regenerate. The bar chart compares empirical leading-digit frequencies (green) against the theoretical Benford prediction (purple). Switch to Overlay line mode to see the Benford curve drawn over the empirical bars. You can also paste your own comma-separated numbers using the Custom input option.
Why does the digit 1 appear so much more often than digit 9?
On a logarithmic scale, the interval from 1 to 2 spans log10(2) - log10(1) = 0.301 of a decade, while the interval from 9 to 10 spans only log10(10) - log10(9) = 0.046 of a decade. Because scale-invariant data is uniformly distributed on a log scale, numbers with leading digit 1 are roughly six times more likely than numbers with leading digit 9. This is not a coincidence but a mathematical necessity for any truly scale-invariant distribution.
What is the mathematical derivation of Benford's Law?
The law follows from scale invariance: a probability distribution f(x) is scale-invariant if multiplying all values by a constant c leaves the distribution of leading digits unchanged. The only continuous distribution satisfying this property is the logarithmic uniform distribution, meaning the probability that log10(x) falls in any interval is proportional to the interval's length. The probability that the leading digit is d equals the length of the log10 interval [d, d+1), which is log10(d+1) - log10(d) = log10(1 + 1/d).
How is Benford's Law used to detect financial fraud?
Forensic accountants apply the chi-squared goodness-of-fit test to the leading digits of entries in financial records — invoices, expense reports, tax filings, or accounting journals. Humans who fabricate numbers tend to choose digits too uniformly, because uniform randomness feels natural to intuition. A statistically significant deviation (p-value below 0.05 with 8 degrees of freedom) flags the dataset for further investigation. Benford analysis has been used in major fraud prosecutions, including the Enron scandal, and by tax authorities in dozens of countries.
What is a common misconception about Benford's Law?
A common misconception is that Benford's Law applies to all numerical data. In fact, it fails for datasets confined to a narrow range (such as heights of adult humans, all within roughly 1.5-2.1 m), datasets with a built-in minimum like phone numbers, and randomly generated numbers from a uniform distribution. It also does not apply to assigned numbers like ZIP codes or ID numbers. The law requires data that spans multiple orders of magnitude without artificial constraints.
Who discovered Benford's Law and when?
The phenomenon was first noted by American astronomer and mathematician Simon Newcomb in 1881, who observed that the early pages of shared logarithm tables were far more worn than later pages — indicating that people looked up numbers beginning with 1 far more often. The observation was largely forgotten until physicist Frank Benford independently rediscovered it in 1938, analysed over 20,000 numbers from 20 different datasets including river areas, atomic weights, and baseball statistics, and published the statistical regularities that now bear his name.
Does Benford's Law work in number bases other than base 10?
Yes. In any integer base b greater than 1, the probability that the leading digit equals d is P(d) = log_b(1 + 1/d). In binary (base 2) every number starts with 1, so the law is trivially true. In base 16 (hexadecimal) the leading digit 1 appears log16(2) ≈ 25% of the time. The logarithmic structure is universal and independent of the choice of numeral system, confirming that it reflects deep mathematical properties of scale-invariant distributions.
What real-world datasets are good examples of Benford's Law?
Classic examples include: the populations of all cities and towns in a country (spanning thousands to tens of millions), the lengths of the world's rivers (hundreds to thousands of kilometres), stock market prices over time, the physical constants listed in physics handbooks, national budget figures, earthquake magnitudes (in terms of seismic moment), the number of citations for scientific papers, and Fibonacci numbers. All of these span many orders of magnitude without being artificially capped, which is the key requirement for the law to hold.
How is Benford's Law applied in technology and data science?
Beyond fraud detection, Benford's Law is used in data quality auditing to spot errors in large databases, in image forensics to detect digitally manipulated photographs (natural images follow Benford-like distributions in their DCT coefficients), and in network traffic analysis to identify anomalous behaviour. Machine learning systems have also been trained to flag financial anomalies using Benford deviation as one of their features. Some election monitoring organisations use it as a preliminary screen for electoral irregularities, though its applicability to vote counts is debated among statisticians.
What are current research directions related to Benford's Law?
Active research areas include: extending Benford analysis to second and higher leading digits (Generalised Benford's Law), applying it to cryptocurrency transaction ledgers and blockchain forensics, developing more statistically robust tests that work with small sample sizes (the chi-squared test requires at least ~100 observations), using it in machine learning anomaly detection pipelines, and theoretical work on characterising precisely which probability distributions converge to Benford's Law under products and powers. Researchers are also studying its connections to the Riemann hypothesis through the distribution of prime numbers.
Count leading digits in Fibonacci numbers, populations or your own data and see how closely they follow Benford's log-scale first-digit law.
3D · Three.js / WebGL renderer · 60 FPS target · runs fully client-side, no install