Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I have to generate millions of non-repeating random numbers and came across this equation: $x_{i+1} = x_i+c \space(mod \ m)$, where c and m are relative primes and $m \geq total\ to\ be\ generated$.

This works ok since I don't need good random numbers and don't have to memorize them. My question is, what is the demonstration and name of this method? I will have to write about it, but can't find any information not knowing how to formulate my question.

share|improve this question
    
this is a number generator but not a random number generator –  miracle173 Jun 14 '11 at 11:50
4  
If this works for your needs, fine. However, if it is known that you use a linear congruential generator, any math major in the room can easily predict the next "random" number after they have seen a couple. For starters in cracking this, see the recent discussion on this site math.stackexchange.com/q/43948/11619 –  Jyrki Lahtonen Jun 14 '11 at 12:01
    
I added the random tag. Just in case. –  Jyrki Lahtonen Jun 14 '11 at 12:24
add comment

2 Answers

up vote 5 down vote accepted

Your method is called a "linear congruential generator".

Please have also a look at this question:

how to generate real random numbers

The linear congruential generators are commonly considered to be a bad choice, with much better algorithms available, but it will depend on your application which generator turns out to be good or bad.

share|improve this answer
add comment

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.