Archived

This topic is now archived and is closed to further replies.

writing a lcrng

This topic is 5936 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

As the title implies, I'm currently trying to write a linear congruential random number generator, which looks like this: S(n+1) = ((a * S(n) + c) mod m) where m = (2^32) - 1 (as this is for 32-bit numbers) An article I've reading on the subject states that: b= a - 1 is a multiple of p, for every prime p that divides m. And the example they give uses 16 for m. That's all fine and good, but I'm really at a loss when it comes to testing this condition for all the primes up to (2^32) -1. I mean, that's a lot of primes, man! It's very likely that I'm missing something painfully obvios here, as my math skill as they say, suck. Any help would be greatly appreciated. Edit: typo. [edited by - Shi-no-Mitsukai on September 15, 2002 2:59:49 AM]

Share on other sites
If this is for game development, then perhaps you can look for a simpler random number generator. Otherwise, this isn''t my area of expertise and I can''t advise you, and suggest you consider posting your question here:

http://mathforum.org/dr.math/

Graham Rhodes
Senior Scientist
Applied Research Associates, Inc.

Share on other sites

After bit of research, I''ve decided to go with a Multiply-with-Carry generator rather than the LCG.

If anybody''s interested, you can find more information on the various types of RNGs at http://cliodhna.cop.uop.edu/~hetrick/na_faq.html

-Shi

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
A4L
13
5. 5

• 13
• 26
• 10
• 11
• 44
• Forum Statistics

• Total Topics
633744
• Total Posts
3013658
×