Session Ready
Exercise

Benford's Law for first digit

Benford's Law states that the probability that the first digit equals d is approximately the logarithm of (1 + 1/d). By plotting the expected frequencies, it will be clear that the digits 1,…,9 do not occur with equal frequency.

Instructions
100 XP
  • Implement Benford's law as a function benlaw for the first digit using log base 10 .
  • Calculate the expected frequency for having 5 as a first digit.
  • Create a dataframe with one column digit holding digits from 1 to 9, and one column probability holding their respective probabilities under Benford's Law.
  • Click Submit Answer to plot the expected frequencies for the digits 1, 2, …, 9 in a barplot.