DEV Community

Cover image for Benford's Law Calculator
John Rock
John Rock

Posted on

Benford's Law Calculator

Benford's Law is a little known law that observes first digits in a naturally occurring data set. I just recently found out about it after watching episode four ("Digits") of the Netflix original series Connected. The law states that given a set of data, the first digits do not display a uniform distribution, but instead are arranged in a way that the digit "1" occurs most often, followed by "2", "3", etc.

Per Wikipedia

"It has been shown that this result applies to a wide variety of data sets, including electricity bills, street addresses, stock prices, house prices, population numbers, death rates, lengths of rivers..."

Because of this, Benford's Law has been used to detect anomalies and fraud.

I found this fascinating and wanted to build a calculator to test it on my own.

Using React and a little bit of Recharts I created an app that lets you input data, grab the first digits, calculate the percent of occurrence, and outputs the data to a chart.

Play around with the app here.
Screenshot of Benford's Law Calculator
View source

I highly recommend taking a look into Benford's Law yourself. It's one of those mind-boggling pieces of information that makes you question everything you've learned.
Alt Text

Cover photo by Ian Panelo from Pexels

Top comments (1)

Collapse
 
thomas_james_24f9e9edc897 profile image
Thomas James

This is a fascinating concept! It's incredible how Benford's Law can apply to so many types of data. If you're interested in uncovering more about data trends and information, you might want to explore various records and searches related to public information. For example, you can check Arrests-ca.org or look into criminal history for comprehensive data insights. This can be a valuable resource for anyone working with large datasets or just curious about how such laws can reveal hidden patterns.