What is Benford's Law?
Benford's law, also known as the Newcomb–Benford law, the law of anomalous numbers, or the first-digit law, is an observation that in many real-life sets of numerical data, the leading digit is likely to be small. In sets that obey the law, the number 1 appears as the leading significant digit about 30 % of the time, while 9 appears as the leading significant digit less than 5 % of the time. If the digits were distributed uniformly, they would each occur about 11.1% of the time.

[BETA VERSION]

Benford's Law and Electoral Data
The goal of this webpage is to explain the mathematical properties behind Benford's Law, and the reasons why it cannot be relied upon to detect electoral fraud. First, we will generate an array of 1 000 000 numbers (you can vizualize the array by pressing F12 and clicking on "console"), following the calculation formula that is written in the text field (In Javascript), then return the distribution percentage of first digits in that array. It is meant as a demonstration of the importance of mutltiplication in a data-set that follows benford's law.
suggested formulas:

As you can see, just by multiplying random numbers with each other, we can achieve a distribution of First Digits that follows Benford's Law. But what happens if we change the formula used for the generation of this data-set? Find out yourself thanks to the three different formulas i've provided, or write your own formula in the above text field.

Now how about diving a little deeper in the matter? Let's actually simulate an election and see what we can learn from it. The table bellow is the product of this simulation. What happens in the program is fairly simple: We have a list of 83 counties (Michigan counties, for the purpose of the demonstration) for each county, we will generate a number of voter between 0 and whatever number you want to type in the text field (By default, 20 000 max. voters per county). Once we have our voters, we'll have to make them vote and distribute their ballots between each candidate. For the purpose of this exemple, the first candidate will recieve about 46% of the votes, while the second will recieve the remaining 54%. As previously, we will return the distribution percentage of each first digit to observe if this data-set follows Benford's Law.

Number of voters:

Counties Candidate 1 Candidate 2

Candidate 1:

Candidate 2:

As you can see, the results are rather erratic. Don't hesitate to press "Apply" multiple times to observe the variation between each generation. We only have 83 numbers to analyse for each candidate, so you will see a much greater variation than you did on the previous data-set, which generated 1 000 000 numbers (Fitting a table with 1 000 000 counties on a web-page would be rather complicated, as you can probably understand). Nonetheless, the result is very clear, we end up with a rather homogeneous distribution of first digits that does not follow Benford's Law's predictions. But that isen't all, let's go a little deeper, try to change the number of voters from 20 000 to 10 000, and observe the percentages. Done? Odd isen't it, now we have a distribution of first digits that favors digits between 1 and 5. Why is that? Well, we are splitting these votes between two candidates, just about 50-50, So if we get 10 000 voters in a county, our candidates will get about 5000 votes each, it is therefore much less likelly that we would have numbers that start with a 6,7,8 or 9, than it is to have numbers that start with a 1,2,3,4 or 5, as these possibilities only represent 500 numbers (from 500 to 999) out of the average maximum of 5000 avaliable. This is another major aspect of why Benford's law cannot be relied upon to detect electoral fraud, as the number of voter in a county and the percentage of distribution between candidates is the one aspect that will dictate the first digit of the resulting number.