Question: C++ please. Summary: analyze input file to see if data follows Benford's law Given a set of random positive integers, you would expect that 10%

 C++ please. Summary: analyze input file to see if data followsBenford's law Given a set of random positive integers, you would expectthat 10% would start with a 1, 10% would start with a

C++ please.

Summary: analyze input file to see if data follows Benford's law Given a set of random positive integers, you would expect that 10% would start with a 1, 10% would start with a 2, and so on. The numbers should be evenly distributed across the 10 digits, right? Not so much... Benford's law states that positive integers exhibit a certain behavior, if the numbers are truly random. For example, suppose the following numbers are collected at random (the -1 at the end denotes the end of the input and is not considered part of the data) 0123 22184 123456 9811 7812 123 12345 51613 2239 1 Benford's law states that approximately 31% of the numbers will start with the digit 1. In the example above, there are a total of 9 inputs and 3 start with a T-that's 3/9 or 33%, which would follow Benford's law. You can read more about Benford's law on Wikipedia. A practical application of Benford's law is the detection of fraud. Benford's law holds in practice when analyzing random sets of positive integers Write a complete C++ program that inputs a filename from the keyboard, and then opens and inputs N>0 integers from that file. The program counts how many of these integers start with the digit 0, the digit'T", the digit '2,. and the digit 9. After inputting all the data, the program outputs the percentages of numbers that started with each digit. For example, suppose the file "test01.txt' contains the following integers 0123 22184 123456 9811 7812 123 12345 51613 2239 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!