Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do i know if this is random enough?

I wrote a program in java that rolls a die and records the total number of times each value 1-6 is rolled. I rolled 6 Million times. Here's the distribution:

#of 0's: 0
#of 1's: 1000068
#of 2's: 999375
#of 3's: 999525
#of 4's: 1001486
#of 5's: 1000059
#of 6's: 999487

(0 wasn't an option.)

Is this distribution consistant with random dice rolls? What objective statistical tests might confirm that the dice rolls are indeed random enough?

EDIT: questions have been raised over application: a game that i want to be as fair as can be reasonably achieved.

like image 248
David Avatar asked Apr 14 '10 21:04

David


People also ask

How do you know if data is random?

After you collect the data, one way to check whether your data are random is to use a runs test to look for a pattern in your data over time. To perform a runs test in Minitab, choose Stat > Nonparametrics > Runs Test. There are also other graphs that can identify whether a sample is random.

How do you know if a set of numbers is random?

The independence of numbers means there is no correlation between successive numbers. In addition, these numbers should occur in the distribution with approximately the same frequency. Random numbers are almost always derived from a set of single-digit decimal numbers: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

How do you validate randomness?

Run test of randomness is a statistical test that is used to know the randomness in data. Run test of randomness is sometimes called the Geary test, and it is a nonparametric test. Run test of randomness is an alternative test to test autocorrelation in the data.

How do you know if a random number generator is good?

There are two phases to test the random number generator process. First you need a source of entropy[1] that is impossible to guess like the weather. Second you need a deterministic algorithm to expand the seed into a multitude of sequences for keys and the like. Testing usually starts with checking your entropy.


2 Answers

To test whether this particular distribution is consistent with the expected distribution of numbers rolled with a "fair" dive, you need to perform the Pearson's Chi-square test.

Note that this still will not prove that your algorithm is "fair", only that these particular results look "fair".

To test whether your algorithm is "fair" in general, use the Diehard tests, as others have mentioned.

like image 161
Franci Penov Avatar answered Oct 04 '22 04:10

Franci Penov


If your random number generator passes the Diehard tests, that's the best you can do.

Even a physical die won't be perfect with 1/6 per face.

Increase the trials by an order of magnitude, then do it again. If you get 1/6 for each trial you'll be fine.

like image 35
duffymo Avatar answered Oct 04 '22 04:10

duffymo