I need to test a random number generator which produces numbers randomly. How to make sure the numbers generated are random.
相关问题
- Unity - Get Random Color at Spawning
- How to generate a random number, then display it o
- Get access to Angular service instance from JavaSc
- Port of the Rails app when running Cucumber tests
- how to randomly loop over an array (shuffle) in ba
相关文章
- Web Test recorder does not allow me to record a te
- why 48 bit seed in util Random class?
- Factory_girl has_one relation with validates_prese
- What is the difference between `assert_frame_equal
- Need help generating discrete random numbers from
- How do I send cookies with request when testing Fl
- Unit test Angular 2 service subject
- Unit/Integration testing FTP access
Often if you have your generator draw dots at random locations in a bitmap, any nonrandomness will easily be discernable to the eye as clumping, banding or lines.
It's a very difficult thing.
You may try ENT from Fourmilab and compare it with the results against their RNG, HotBits. You may also like to review Random.org.
This also looks interesting: Diehard tests (I've not worked with it though).
Create a log file which will contains the random number for atleast 500 instances and audit it for randomness. Also have a look at below link,
http://burtleburtle.net/bob/rand/testsfor.html
There is a good tool for this puprose: http://www.phy.duke.edu/~rgb/General/dieharder.php
for example you can test build-in urandom
Or write your own script that will create a file with random numbers
Unless you have access to the random number generator and can use it to generate numbers at will, you can't test if a sequence of numbers is random. Think about it: you have a random number generator. Let's say it's a uniform random number generator, generating random integers in the range [0,9]. Given a sequence:
can you tell if it is random? There is a finite probability 10−10, that our uniform random number generator will generate this exact sequence. In fact, given any length-10 sequence, we have the same probability of our uniform random number generator generating that sequence. Hence, by definition, you can't determine if a given sequence is random.
If you do have access to the generator itself, and can use it to generate multiple sequences, then it makes sense to "check for randomness". For this, I would look at Diehard tests. There are various implementations.
It depends how severe your requirement for randomness is. If it is not too severe, what I do is generate a large number of random numbers, find their frequencies and then use the frequencies to plot a graph using a spreadshhet like that in Open Office. If the distribution looks OK, then I'm good to go.