jeudi 14 décembre 2017

Is the random library in Python not very random?

I have used the random library for multiple projects and started feeling like the numbers were not random enough. Now I know how "random" works and that you can roll a die 10 times and get only 5s sometimes, but I decided to test the random module randint as shown below:

from random import randint
from collections import Counter
import numpy

myList = []
for x in range(100000):
  roll = randint(0,9)
  myList.append(roll)


print(Counter(myList))
print(numpy.std(myList))

What I'm finding is the standard deviation is quite consistent, after 10 trials I get a mean standard deviation of 2.870. Perhaps it is a lack of understanding in statistics, but shouldn't the standard deviation be much less, considering the large scale of trials?




Aucun commentaire:

Enregistrer un commentaire