What is the Modulus in Linear Congruential Generators?

  • Context: Undergrad 
  • Thread starter Thread starter elgitano77
  • Start date Start date
  • Tags Tags
    Generator Linear
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 2K views
elgitano77
Messages
1
Reaction score
0
I am trying to understand LCG and although the equation looks really straightforward I don't know how to calculate the module of the expression.

Xn+1= a*Xn+c (mod m)

As stated before, my problem is understanding the concept of mod m and how to calculate it.

Any help and example would be appreciated.
 
Physics news on Phys.org
a*Xn+c Modulo m gives the remainder of a*Xn+c when divided by m.
See http://en.wikipedia.org/wiki/Modulo_operation

Most computer programming languages have a "mod" function. In machine language the integer divide will provide the quotient in one register, and the remainder in another - this makes this very fast. This is a very old pseudo-random number generator which was already in use in the 1950's - I used to have an IBM publication copyright 1953 or so which provided all of the details.

http://en.wikipedia.org/wiki/Linear_congruential_generator
 
Typical random number generators will use integer arithmetic, where m is 2k, where k = 1+largest single precision integer. a*Xn+c will produce an integer covering a double precision register. Keep the lower half.

The above method then is followed by division (after floating) by the float of k.