3 ms·
You keep choosing N to be an integer power of 10. Make it a power of 2 or 7 or pretty much any number, and you'll see different results.
by dmurray 7y ago
You keep choosing N to be an integer power of 10. Make it a power of 2 or 7 or pretty much any number, and you'll see different results.
- susam 7y agoI do not see different results: import random N = 8192 counts = [0] * 10 for n in range(N): first_digit = int(str(2**n)[0]) counts[first_digit] += 1 for i, count in enumerate(counts): print('{} => {:.3f}'.format(i, counts[i] / N)) Output: 0 => 0.000 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 I still see results that agree with Benford's law.
- logicallee 7y agoI did something similar (except you're a better coder, haha), but when I looked up how to get a random number in Python the first thing I saw was how to get one between 0 and 1 so I went with it. Here is my comment (very similar in spirit to yours): https://news.ycombinator.com/item?id=22341416 https://news.ycombinator.com/item?id=22341416 Any comments?
- susam 7y agoReplied on your comment thread.