# Benford's Law with more than 1 leading digit

I am bit confused on the algorithm of Benford's Law using more than the first leading digit.

I have read a thesis here that states the law for leading 2 digits is:

$\log_{10} \left( 1 + {\small\dfrac 1 {10d_1 \! + d_2}} \right)$ where $d = d_1 d_2$ and $d$ is within the bounds of 10 to 99.

Would that not be equivalent to the original formula of:

$\log_{10} \left( 1 + {\small\dfrac 1 d} \right)$ where $d$ is within the bounds of 10 to 99.

Is that correct? I have tried googling for a good night, but do not seem to be able to find a formula which applies to leading digits > 1.

Appreciate any help, below is the sample code I have used to generate the results in Python.

expected = [log10(1+1/d) for d in range(1,10)]
expected2 = [log10(1+1/(10 *d1+d2)) for d1 in range(1,10)
for d2 in range(0,10)]
expected22 = [log10(1+1/(d1)) for d1 in range(10,100)]

print(expected22,expected2)

Yes, under Benford’s law the expected frequency of a specific leading pair of digits $d_1d_2$ $\big( = 10d_1 \! + d_2 = d$, with $d \in \{10,11,12,\ldots,99\} ~\big)$ is just as your program calculated.

\begin{align} P ( \text {first two digits are} ~ d_1 d_2 ) & = P ( \text {first two digits are} ~ 10d_1 \! + d_2 ) \\[1ex] & = P ( \text{first two digits are} ~ d ) \\[1ex] & = \log_{10} \left( 1 + {1 \over d}\right) \end{align}

Agreeing with your implicit conjecture, this holds in general for $n$ leading digits where $d = d_1 d_2 d_3 ... d_n$ with $d_1 \in \{ 1,2,3,...,9 \}$, as gathered from An Introduction to Benford's Law, Chapter 1, Princeton University Press (no author or year given) — stated slightly differently here in a subtractive format that facilitates many applications.

\begin{align} P ( \text {first} ~ n ~ \text{digits are} ~ d_1 d_2 d_3 ... d_n ) & = P ( \text{first} ~ \text{digits are} ~ d ) \\[1ex] & = \log_{10} (d{+}1) - \log_{10} d \kern 7.5em \end{align}

An example for the original question gives the same result as the familiar format.

\begin{align} P ( \text{first} ~ 2 ~ \text{digits are} ~ 76 ) & = \log_{10} 77 - \log_{10} 76 \\[1ex] & = \log_{10} {\small { 77 \over 76 }} \\[1ex] & = \log_{10} \left( 1 + { \small{ 1 \over 76 }} \right) \kern 6em \end{align}

The subtractive format shows its flexibility on other conceivable questions about the first two digits.

\begin{align} P ( \text {first 2 digits are equal} ) & = P ( \text {first are 11} ) + P ( \text{first are 22} ) + \cdots + P ( \text{first are 99} ) \\[2ex] & = ( \log_{10} 12 - \log_{10} 11 ) + ( \log_{10} 23 - \log_{10} 22 ) \\[.5ex] & \kern 12em + \cdots + ( \log_{10} 100 - \log_{10} 99 ) \\ & = \log_ {10} {\small{ 12 \cdot 23 \cdots 100 \over 11 \cdot 22 \cdots 99 }} \\[1.5ex] & = 10.9 \% \end{align}

\begin{align} \kern 3.5em \raise 2ex \strut P ( \text {2nd digit is} ~ 6 ) & = P ( \text {first are 16} ) + P ( \text{first are 26} ) + \cdots + P ( \text{first are 96} ) \\[2ex] & = ( \log_{10} 17 - \log_{10} 16 ) + ( \log_{10} 27 - \log_{10} 26 ) \\[.5ex] & \kern 12em + \cdots + ( \log_{10} 97 - \log_{10} 96 ) \\ & = \log_ {10} {\small{ 17 \cdot 27 \cdots 97 \over 16 \cdot 26 \cdots 96 }} \\[1.5ex] & = 9.3 \% \end{align}

This format also telescopes nicely when verified against the most famous prediction of Benford’s law, that 1 is the first significant digit in approximately 30.1% of suitably random numbers. The first 3 digits are employed this time for variety.

\begin{align} \kern 4.5em P ( \text {first digit is} ~ 1 ) & = P ( \text {first are 199} ) + P ( \text{first are 198} ) + \cdots + P ( \text{first are 100} ) \\[2ex] & = ( \log_{10} 200 - \log_{10} 199 ) + ( \log_{10} 199 - \log_{10} 198 ) \\[.5ex] & \kern 12em + \cdots + ( \log_{10} 101 - \log_{10} 100 ) \\ & = \log_{10} 200 - \log_{10} 100 \\[1.5ex] & \equiv 30.1 \% \end{align}

(The material above was learned while applying Benford’s law to Roman numbers in a puzzle.)