Question

Benford’s Law is an observation about the distribution of the frequencies of the first digits of...

Benford’s Law is an observation about the distribution of the frequencies of the first digits of the numbers in many different data sets. It is frequently found that the first digits are not uniformly distributed, but follow the logarithmic distribution P(d) = log10 ((d + 1)/d)

That is, numbers starting with 1 are more common than those starting with 2, and so on, with those starting with 9 the least common. The probabilities follow:

1 0.301
2 0.176
3 0.125
4 0.097
5 0.079
6 0.067
7 0.058
8 0.051
9 0.046

Benford’s Law is most accurate for data sets which span several orders of magnitude and can be proved to be exact for some infinite sequences of numbers.

1 Demonstrate in Python that the first digits of the first 500 Fibonacci numbers follow Benford’s Law quite closely.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below. Thumbs up if you like the solution.

# Program to display the Fibonacci sequence up to n-th term where n is provided by the user
nterms = 500
# first two terms
n1 = 0
n2 = 1
count = 0
lst=[]

# check if the number of terms is valid
if nterms <= 0:
print("Please enter a positive integer")
elif nterms == 1:
print("Fibonacci sequence upto",nterms,":")
print(n1)
else:
print("Fibonacci sequence upto",nterms,":")
while count < nterms:
print(n1,end=' , \n')
#Creating a list with the starting of each fibonacci number.

numStr = str(n1)
numStr = int(numStr[0])
lst.append(numStr)
nth = n1 + n2
# update values
n1 = n2
n2 = nth
count += 1

# Initializing the counters.

counter1 = 0
counter2 = 0
counter3 = 0
counter4 = 0
counter5 = 0
counter6 = 0
counter7 = 0
counter8 = 0
counter9 = 0

#Counting the unique numbers in the list

for items in lst:
if items == 1:
counter1 +=1
if items == 2:
counter2 +=1
if items == 3:
counter3 +=1
if items == 4:
counter4 +=1
if items == 5:
counter5 +=1
if items == 6:
counter6 +=1
if items == 7:
counter7 +=1
if items == 8:
counter8 +=1
if items == 9:
counter9 +=1

#Dividing the probabilities by 1000 as dividing by 500 would give double the value as that of values in Benford's Law

print('Probability of 1 = ', counter1/1000)
print('Probability of 2 = ', counter2/1000)
print('Probability of 3 = ', counter3/1000)
print('Probability of 4 = ', counter4/1000)
print('Probability of 5 = ', counter5/1000)
print('Probability of 6 = ', counter6/1000)
print('Probability of 7 = ', counter7/1000)
print('Probability of 8 = ', counter8/1000)
print('Probability of 9 = ', counter9/1000)

Let me know if this works for you.

Add a comment
Know the answer?
Add Answer to:
Benford’s Law is an observation about the distribution of the frequencies of the first digits of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Benford's Law states the relative frequencies of the first digits in a dataset of naturally occurring...

    Benford's Law states the relative frequencies of the first digits in a dataset of naturally occurring random numbers will follow the trend seen in the table. Benford's law is used to detect fraud in accounting and other fields. We will consider three business called Business A, B, and C. We have their accounts payable database and have given the relative frequencies of the first digit for each item in their accounts payable. Relative Frequency First Benfords Business Business Business Digit...

  • Bentood's law first nou zero numher in a snolom distrihatin of it's " 56 PlXex)] 0.301...

    Bentood's law first nou zero numher in a snolom distrihatin of it's " 56 PlXex)] 0.301 0.176 0.125 0.097 0,079 0.067 0.056 0.051 0.046 A seuple i taken and returned x 1 1 2 3 4 5 6 7 & q ol &3 49 32 22 25 18 13 17 16 Use Goodness of fit to test the sample ? Benfond I at a=6.05. 1: Test at &=0.05 if sample & Normal (754) ol 63 64 67 69 71 72...

  • Benford’s Law gives the distribution of leading digits in a variety of different data sets. An...

    Benford’s Law gives the distribution of leading digits in a variety of different data sets. An investigator for the Brooklyn district attorney analyzed the digits of the amounts of 784 checks issued by seven suspect companies. Leading digit       1                 2       3         4         5           6          7           8           9 Benford’s Law      30.1%     17.6     12.5     9.7      7.9        6.7         5.8       5.1          4.6 Observed counts   0           15          0       76      479      183            8        23             0 1. Consider the claim that the amounts on those checks have...

  • The first signifcant digit in any number must be 1.2. 3. 4. 5.0.7.8. or e. It was discovered that Srst digits do not occur with equal frequency Probabilities of occurrence to the first digit in a num...

    The first signifcant digit in any number must be 1.2. 3. 4. 5.0.7.8. or e. It was discovered that Srst digits do not occur with equal frequency Probabilities of occurrence to the first digit in a number are shown in the accompanying table. The probability distribution is now known as Benford's Law. For exampe te o own g der but on represents the frst digits n 220 al eged y fraudulent check wrtten to ฮ bogus oompany by an employee...

  • 6. Creating a bar graph and Benford's Law Aa Aa Here's an interesting exercise: Write down...

    6. Creating a bar graph and Benford's Law Aa Aa Here's an interesting exercise: Write down all the numbers you see on the front page of your college newspaper (excluding the page number). Calculate the proportion of numbers beginning with 1 and the proportion of numbers beginning with 4. Which proportion is greater? Your intuition may suggest that you are equally likely to find both kinds of numbers, so the proportions should be roughly the same. However, more often than...

  • The first significant digit in any number must be 1, 2, 3, 4, 5, 6, 7,...

    The first significant digit in any number must be 1, 2, 3, 4, 5, 6, 7, 8, or 9. It was discovered that first digits do not occur with equal frequency. Probabilities of occurrence to the first digit in a number are shown in the accompanying table. The probability distribution is now known as Benford's Law. For example, the following distribution represents the first digits in 194 allegedly fraudulent checks written to a bogus company by an employee attempting to...

  • 5) A book claims that more hockey players are born in January through March than in October through December. The following data show the number of players selected in a draft of new players for a hoc...

    5) A book claims that more hockey players are born in January through March than in October through December. The following data show the number of players selected in a draft of new players for a hockey league according to their birth month. Is there evidence to suggest that hockey players' birthdates are not uniformly distributed throughout the year? Use the level of significancealpha equalsα=0.05Birth MonthObserved CountExpected CountJanuary-March60April-June51July-September26October-December374) A traffic safety company publishes reports about motorcycle fatalities and helmet use....

  • 5) A book claims that more hockey players are born in January through March than in...

    5) A book claims that more hockey players are born in January through March than in October through December. The following data show the number of players selected in a draft of new players for a hockey league according to their birth month. Is there evidence to suggest that hockey​ players' birthdates are not uniformly distributed throughout the​ year? Use the level of significance alpha equalsα=0.05 Birth Month Observed Count Expected Count ​January-March 60 ​April-June 51 ​July-September 26 ​October-December 37...

  • A random sample of 40 adults with no children under the age of 18 years results...

    A random sample of 40 adults with no children under the age of 18 years results in a mean daily leisure time of 5.31 hours, with a standard deviation of 2.49 hours. A random sample of 40 adults with children under the age of 18 results in a mean dailyleisure time of 4.02 hours, with a standard deviation of 1.97 hours. Construct and interpret a 90% confidence interval for the mean difference in leisure time between adults with no children...

  • Recall that Benford's Law claims that numbers chosen from very large data files tend to have "1" as the first nonzero di...

    Recall that Benford's Law claims that numbers chosen from very large data files tend to have "1" as the first nonzero digit disproportionately often. In fact, research has shown that if you randomly draw a number from a very large data file, the probability of getting a number with "1" as the leading digit is about 0.301. Now suppose you are an auditor for a very large corporation. The revenue report involves millions of numbers in a large computer file....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT