What is the Modulus in Linear Congruential Generators?

  • Context: Undergrad 
  • Thread starter Thread starter elgitano77
  • Start date Start date
  • Tags Tags
    Generator Linear
Click For Summary
SUMMARY

The discussion focuses on the calculation of the modulus in Linear Congruential Generators (LCGs), specifically the equation Xn+1 = a*Xn + c (mod m). The modulus operation, denoted as "mod m," yields the remainder of the expression a*Xn + c when divided by m. It is emphasized that most programming languages include a built-in "mod" function, facilitating efficient calculations. The LCG method, a classic pseudo-random number generator dating back to the 1950s, utilizes integer arithmetic, where m is typically a power of 2.

PREREQUISITES
  • Understanding of Linear Congruential Generators (LCGs)
  • Familiarity with modular arithmetic
  • Basic knowledge of programming languages and their arithmetic functions
  • Concept of integer and floating-point representation in computing
NEXT STEPS
  • Research the implementation of Linear Congruential Generators in Python
  • Learn about modular arithmetic in C++
  • Explore the history and applications of pseudo-random number generators
  • Study the differences between integer and floating-point arithmetic in programming
USEFUL FOR

Computer scientists, software developers, and mathematicians interested in random number generation and modular arithmetic will benefit from this discussion.

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.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 23 ·
Replies
23
Views
4K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 28 ·
Replies
28
Views
6K
  • · Replies 17 ·
Replies
17
Views
4K
  • · Replies 8 ·
Replies
8
Views
2K
Replies
12
Views
11K
  • · Replies 19 ·
Replies
19
Views
4K