Generating numbers for possible Benford's law distribution I did the experiment described in my previous comment and got a distribution that was similar to but not close enough to the expected one. I generated 2 million numbers as follows. Let ranges_top = 999. Then generate a sequence of 2 million numbers based on this formula. randint(1, randint(1, ranges_top)) In other words, to generate a number select a number at random between 1 and 999. Then select a number between 1 and that number. The distribution was as follows (along with the expected results). {1: (0.24, 0.30), 2: (0.18, 0.18), 3: (0.15, 0.12), 4: (0.12, 0.10), 5: (0.09, 0.08), 6: (0.08, 0.07), 7: (0.06, 0.06), 8: (0.05, 0.05), 9: (0.03, 0.05)} That is, about 24% of my numbers began with 1 compared to an expected 30%, etc. I did this experiment a number of times using Python's random number library. The results were all substantially the same. Disappointing. Is there anything known about the distribution I generated? Reply
I did the experiment described in my previous comment and got a distribution that was similar to but not close enough to the expected one.
I generated 2 million numbers as follows. Let ranges_top = 999. Then generate a sequence of 2 million numbers based on this formula.
randint(1, randint(1, ranges_top))
In other words, to generate a number select a number at random between 1 and 999. Then select a number between 1 and that number.
The distribution was as follows (along with the expected results).
{1: (0.24, 0.30), 2: (0.18, 0.18), 3: (0.15, 0.12), 4: (0.12, 0.10), 5: (0.09, 0.08), 6: (0.08, 0.07), 7: (0.06, 0.06), 8: (0.05, 0.05), 9: (0.03, 0.05)}
That is, about 24% of my numbers began with 1 compared to an expected 30%, etc.
I did this experiment a number of times using Python's random number library. The results were all substantially the same.
Disappointing.
Is there anything known about the distribution I generated?