Hacker News new | past | comments | ask | show | jobs | submit login

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.



I 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.


I 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

Any comments?


Replied on your comment thread.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: