Randint doesn’t always follow uniform distribution

The problem seems to be in your grapher, seaborn, not in randint().

There are 50 bins in your seaborn distribution diagram, according to my count. It seems that seaborn is actually binning your returned randint() values in those bins, and there is no way to get an even spread of 110 values into 50 bins. Therefore you get those peaks where three values get put into a bin rather than the usual two values for the other bins. The values of your peaks confirm this: they are 50% higher than the other bars, as expected for 3 binned values rather than for 2.

Another way for you to check this is to force seaborn to use 55 bins for these 110 values (or perhaps 10 bins or some other divisor of 110). If you still get the peaks, then you should worry about randint().

Leave a Comment