In theory the probability of randomly generating a number is determined by the set of possible numbers. Given a set pf possible numbers n the expected probability of generating any number in the set is 1/n. So the probability of rolling any one of a set of 10 numbers is expected to be 1/10. You are to write a program that will test this theory. Generate a random digit in the range 0 - 9 (inclusive), record the number of times that each digit 0 - 9 is thrown.
Your program should find the frequency of each digit for each number of iterations listed below: 100 1000 10000 100000 1000000 Output to the screen the frequency (as a percentage) that each digit (0 - 9) is thrown for each of the number of iterations listed above.
Aucun commentaire:
Enregistrer un commentaire