Inversive congruential generators are a type of nonlinear congruential
pseudorandom number generator
A pseudorandom number generator (PRNG), also known as a deterministic random bit generator (DRBG), is an algorithm for generating a sequence of numbers whose properties approximate the properties of sequences of random numbers. The PRNG-generate ...
, which use the
modular multiplicative inverse In mathematics, particularly in the area of arithmetic, a modular multiplicative inverse of an integer is an integer such that the product is congruent to 1 with respect to the modulus .. In the standard notation of modular arithmetic this cong ...
(if it exists) to generate the next number in a sequence. The standard formula for an inversive congruential generator, modulo some prime ''q'' is:
:
:
Such a generator is denoted symbolically as and is said to be an ICG with parameters ''q'', ''a'', ''c'' and seed ''seed''.
Period
The sequence
must have
after finitely many steps, and since the next element depends only on its direct predecessor, also
etc. The maximum possible
period for the modulus ''q'' is ''q'' itself, i.e. the sequence includes every value from 0 to ''q'' − 1 before repeating.
A sufficient condition for the sequence to have the maximum possible period is to choose ''a'' and ''c'' such that the
polynomial
In mathematics, a polynomial is an expression consisting of indeterminates (also called variables) and coefficients, that involves only the operations of addition, subtraction, multiplication, and positive-integer powers of variables. An ex ...