Testing random number generators

I found maths in lower years rather boring, what with me often getting through the questions quickly and sometimes being many chapters ahead of everyone else (of my own volition, I add, should my teachers be reading this post). One thing I did to wile away the time was using the random number function on my calculator, specificaly RanInt, and simulating dice rolls. I would tally every outcome for a number, and ended up compiling loads of pages which I may have lying around somewhere. The only thing I can remember off the top of my head was that 2 was being generated very frequently towards the end, perhaps distorting the expected probability of 1/6.

The RanInt function's not really random, it uses a formula and generates successive numbers based on it. Dice don't have this issue. There are many ways how you could try and make a random number generator more random, by using various different methods. Random.org pride themselves on using radio stations dotted across Europe, using the resultant noise to generate numbers, and thus are supposedly "better than the [other] pseudo-random number algorithms". 

I've decided to relive my bored 15 year old self and put some generators to the test. I ran the programs 100 times, and here are the results:

random.org results
 
This is the data for Random.org, with a range in probabilities of 15% - clearly some numbers were favoured less than others.
 
calculator results
 
This meanwhile is the data for the calculator - the range is greater, at 17%, and surprisingly enough, 4 has gone from the least frequent to the most frequent.
 
dice results
 
The dice, perhaps unsurprisingly, has the smallest range to this point at 11% - the numbers are more closely bunched together.
 
python results
Python, meanwhile, gave a similar range at 12%, though more distinctly has 5 and 6 both ahead of every other number, unlike the other generators.
 
Combining all four number sets, we get this:
 
overall results
 
2 and 4 are almost spot on, at probabilities of 16% and 16.25% respectively; 3 came in at 14.5%, which is also close but not exact. Unfortunately, every generator seems to have favoured 5 and 6, which picked up total probabilites greater than or equal to 20%. The overall range here, though, is 8.25% -  the lowest so far, which is a satisfying note.

Obviously this blogpost is misleading in a way:
  • randomness shouldn't equal an exact probability of 16.66...%, and thus the results are really great
  • 5 and 6 any other time may not be as favoured - it's merely coincidental all the generators threw them up so often (see 4 getting 27/65 results on one generation)
  • you can make up your own mind when it comes to the results, the ranges aren't necessarily the greatest indication of what is truly random or not
  • I'd personally consider the dice as the most random, purely because there's less evident "bias" present than with the other generations (note it's not bias because these programs have no conscience)

All in all, I'm not sure what I think.

Comments

Post a Comment