Tell me more ×
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
1  
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

4 Answers

up vote 5 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

i think u should have to try for limit..i mean make that field for 1 to 9 no. only and see what are the results i dont know whether its gonna work or not...but this is a good Question.!

share|improve this answer
1  
Welcome to the site, 2988. Could you elaborate more on this? I'm having a hard time following it. Thanks! – corsiKa Sep 3 '12 at 5:27
i mean check that field of random no. generator only for one digit – Tarun Sep 3 '12 at 5:42
What if a certain number (e.g. 0 or 129) causes an overflow or another error? If you limit the testing set to only 1..9 it will certainly lead to further problems. Can you please elaborate how to define this limited set of values? – bytebuster Oct 1 '12 at 8:37
ask your developer to make the code only for one digit only, that's it..its so simple – Tarun Oct 23 '12 at 6:20

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

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
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

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.