Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I have a program which generates random numbers. How can I test if the random number generator is generating actual random numbers?

share|improve this question
2  
A fact you will need to know: what distribution are these numbers sampled over? –  user246 Aug 20 '12 at 13:53
    
You have this tagged under manual testing. This is something that should be tested using software. –  Bruce McLeod Aug 20 '12 at 13:58
1  
Not a fully answer, but one of the best ways to determine if things are random are to try to compress them. Compression works by finding patterns, and if they're random, there won't be many patterns for it to find in order to compress. –  corsiKa Aug 20 '12 at 16:38
    
I corrected the tag. –  dzieciou Oct 6 '13 at 10:40

3 Answers 3

up vote 7 down vote accepted

If numbers are being computer generated, they won't be truly random, they will be pseudo-random numbers.

I would head over to math.stackexchange.com to get a good understanding of the problem you are trying to test.

Some good, related questions are:

How to generate REAL random numbers with some random and pseudo random

Are these numbers random?

You should also look in to ways you can automate the testing. To truly test this you will need to test a very large sample size, and then visualise the distribution of results.

share|improve this answer
    
I would take a simpler approach, how would you test manual random number (picked in a hat)? You want to validate that all numbers are eventually generated. You want to validate the distribution (number of occurrence of a number). For the software, I think the interesting point is also to focus on the performance. Do you generate the first number as fast as you generate the last number for example? –  Ahmet Sep 7 '12 at 21:46

Try this document - Chapter 10 of Beautiful Testing

For a simple example, have a look at this example blog post from Alan Page

share|improve this answer
1  
The Beautiful Testing chapter is actually really good, since it talks about testing without getting into any heavy-duty math or statistics. I really recommend it. –  joshin4colours Aug 20 '12 at 17:02
1  
Why shouldn't you get to heavy-duty math or statistics, if you're going to test random number generator? –  Edu Aug 20 '12 at 17:28

See for example http://en.wikipedia.org/wiki/Statistical_randomness for a list of possible tests to check randomness of the generator. http://en.wikipedia.org/wiki/Random_number_generation gives pointers to other things you might be interested in your generator.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.