Random numbers, are they really random?

 

image

Output of 25,000 rolls of a 6 sided dice, somewhat distributed using my eyeball, but if I am rolling craps in Las Vegas, I might not be real happy about that distribution, let alone if I used one of the statistical analysis tools.  So what if I roll it again?

image

Bleh, it’s worse.  No sixes in 25,000 rolls, really?  This appears to be a noisy distribution.

Those rolls were done using the Random number generator supplied with the Framework.

Now, if you use the namespace “using System.Security.Cryptography;” RNGCryptoServiceProvider, you have a much better distribution:

image

Let’s do that again:

image

Nice distribution.

I used the example at RNGCryptoServiceProvider.GetBytes Method, which works quite easily, and added the random number generator code to the example code.

My modifications are shown in the file that is attached below.

dice.zip