[Math Talk #7] Benford's Law (Examples and Relationship with Logarithms)
[1]
Benford's Law
In this post, I will talk more about Benford sequence with more rigority in mathematics. For those of who want to see basic definitions and properties of Benford Sequence, see [Math Talk #6].
1. Well Definedness
Recall that the definition of Benford sequence of base is a sequence
satisfying
Since the function is the probability mass function, the sum of probabilities
should be 1. Direct computation gives
So it is a well defined probability mass.
2. Benford Sequence and Logarithm - [2]
2-1. Evaluating the first digit
First we need a simple fact.
Lemma 1.
If (i.e have the same fractional part), then
have the same first digit on base
.
Proof.
The first digit of a number in base
is soley determined by the fractional part of the logarithm, which is
Since for some integer
,
2-2. Logarithm of Equidistributed sequence is benford
Now we have the most important theorem for making benford sequence. If someone is curious about what is equidistribution of a sequence, go to Math Talk #5 - Distribution of Sequence.
Theorem 1.
If is equidistributed modulo 1 (i.e fractional part is equidistribution over
), then
is Benford of base
.
Proof.
For any to have a first digit
in base
, we should have
As is equidistributed modulo 1, by definition
Since , using Lemma 1
So that in the limit, the probability that first digit of sequence is
would be
proving that sequence is indeed Benford in base .
Remember the Weyl's Criterion and its groundbreaking consequence? Check Weyl's Criterion, Section 2-2 in Math Talk #5 if you are unfamiliar with. We proved that for any irrational number ,
The sequence
is equidistributed modulo 1.
Using this fact, we have a generalization of Theorem 1.
Theorem 2.
Let where
is irrational. Then
is Benford of base
.
Proof.
.
and
is just shifted version of
; it is equidistributed modulo 1 by the above fact. So by Theorem 1,
is Benford of base
.
2-3. Examples using Computer Experiment.
Example 1.
Going back to the decimals, , let's consider the first (or leading) digit of
. Since
is irrational, the leading digits,
1, 2, 4, 8, 1, 3, 6, 1, ...
should be Benford of base 10. Let's check. Using Python, we examine the frequency of leading digit of where
.
def is_Benford(N):
Digit_count = np.array([0 for i in range(9)])
for i in range(N + 1):
x = (i * math.log10(2)) - int(i * math.log10(2))
if x < math.log10(2):
Digit_count[0] += 1
elif x < math.log10(3):
Digit_count[1] += 1
elif x < math.log10(4):
Digit_count[2] += 1
elif x < math.log10(5):
Digit_count[3] += 1
elif x < math.log10(6):
Digit_count[4] += 1
elif x < math.log10(7):
Digit_count[5] += 1
elif x < math.log10(8):
Digit_count[6] += 1
elif x < math.log10(9):
Digit_count[7] += 1
else:
Digit_count[8] += 1
return Digit_count / N
#------------------------------------------------
Digit = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9])
Benford = [math.log10(1 + 1/i) for i in Digit]
for i in range(1, 6):
plt.plot(Digit, is_Benford(10 ** i), label = '$10^%d$' %i)
plt.grid(axis = 'y')
plt.legend()
plt.show()
plt.plot(Digit, Benford)
plt.grid(axis = 'y')
plt.xlabel('$n$')
plt.show()
We get a plot
which shows that the frequency converges to Benford probability mass,
Example 2.
Now take any arbitrary sequence such as . By Theorem 2, the leading digits should be Benford. Let's check.
You can see that even if it fluctuates a lot in small values, it converges to Benford extremely fast.
Example 3.
First digit of Fibonacci sequence, given by
also obeys Benford of base 10,
3. Connection with Central Limit Theorem - [3]
Central Limit Theorem (CLT); the most important theorem in statistics, states that average of iid random variables drawn from the pool of average
and variance
;
, converge in distribution by the relation
Now suppose you take the product of such random variables and take logarithm. The average,
converge in distribution to log-normal distribution with very large variance as we multiply more and more terms, so it will cover many orders of magnitude (which is power of some number) almost uniformly.
The x- axis in logarithm, so that we can deduce that covers many orders of magnitude when variance is large. But you should be careful, the original geometric sequence we've examined in section 2 multiplies same value at a time. So, the real world problems with exponential (or logarithmic rules) will likely follow Benford's Law not EXACT!
4. Conclusion
Benford's law tends to apply most accurately to data that are distributed uniformly across several orders of magnitude. As a rule of thumb, the more orders of magnitude that the data evenly covers, the more accurately Benford's law applies.
Real-world distributions that span several orders of magnitude rather uniformly (e.g. populations of villages / towns / cities, stock-market prices), are likely to satisfy Benford's law to a very high accuracy.
On the other hand, a distribution that is mostly or entirely within one order of magnitude (e.g. heights of human adults, or IQ scores) is unlikely to satisfy Benford's law very accurately, or at all. This clearly matches with our observation in Math Talk #5, when the restriction of range of random numbers are specified, Benford's Law does not apply.
Anyway, it is not always true neither numbers always matches with the Benford probability mass. The real world problems are chaotic, so that whether the data follows Benford's Law or not should be checked using Hypothesis Testing in Statistics.
5. Citations
[1] https://en.wikipedia.org/wiki/Benford%27s_law (only image is used)
[2] https://pdfs.semanticscholar.org/15b1/59294fecf600d9c1ecf3f71688cd69416eb9.pdf (Section 2)
[3] https://pdfs.semanticscholar.org/15b1/59294fecf600d9c1ecf3f71688cd69416eb9.pdf (Section 3)
All the plots are made by myself using Python and MATLAB (the last figure).