lundi 12 décembre 2016

Randint doesn't always follow uniform distribution

I was playing around with the random library in Python to simulate a project I work and I found myself in a very strange position.

Let's say that we have the following code in Python:

from random import randint
import seaborn as sns

a = []
for i in range(1000000):
    a.append(randint(1,150))

sns.distplot(a)

The plot follows a “discrete uniform” distribution as it should.

Range betwee 1 and 150

However, when I change the range from 1 to 110, the plot has several peaks.

from random import randint
import seaborn as sns

a = []
for i in range(1000000):
    a.append(randint(1,110))

sns.distplot(a)

Range from 1 to 110

My impression is that the peaks are on 0,10,20,30,... but I am not able to explain it.




Aucun commentaire:

Enregistrer un commentaire