Is it really random?

November 07, 2024

I was using Python's random library today, when I started getting the same numbers in a row for a random integer.

In all likelihood, it was just a fluke - luck wanted me to see those numbers a few times in a row. But it planted a seed!

I could test if random.randint() really is behaving with an equal distribution over the long run...

26 lines of Python later, I have a fun little toy program that let me try it out myself.

Want to know whether the random library tends toward even distributions in the long run (i.e. 1,000,000+ iterations)? Download the code and play with it yourself!


Profile picture

I write something new every day for 2k software developers. You should sign up for the daily email.

© 2024