Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
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
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
up vote 8 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 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
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
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 for a list of possible tests to check randomness of the generator. gives pointers to other things you might be interested in your generator.

share|improve this answer

Your Answer


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.