An approach to nonlinear congruential methods of generating uniform pseudorandom numbers in the interval [0,1) is the Inversive congruential generator with prime modulus. A generalization for arbitrary composite moduli m = p 1 , … p r {\displaystyle m=p_{1},\dots p_{r}} with arbitrary distinct primes p 1 , … , p r ≥ 5 {\displaystyle p_{1},\dots ,p_{r}\geq 5} will be present here.
Let Z m = { 0 , 1 , . . . , m − 1 } {\displaystyle \mathbb {Z} _{m}=\{0,1,...,m-1\}} . For integers a , b ∈ Z m {\displaystyle a,b\in \mathbb {Z} _{m}} with gcd (a,m) = 1 a generalized inversive congruential sequence ( y n ) n ⩾ 0 {\displaystyle (y_{n})_{n\geqslant 0}} of elements of Z m {\displaystyle \mathbb {Z} _{m}} is defined by
y 0 = s e e d {\displaystyle y_{0}={\rm {seed}}} y n + 1 ≡ a y n φ ( m ) − 1 + b ( mod m ) , n ⩾ 0 {\displaystyle y_{n+1}\equiv ay_{n}^{\varphi (m)-1}+b{\pmod {m}}{\text{, }}n\geqslant 0}where φ ( m ) = ( p 1 − 1 ) … ( p r − 1 ) {\displaystyle \varphi (m)=(p_{1}-1)\dots (p_{r}-1)} denotes the number of positive integers less than m which are relatively prime to m.
Example
Let take m = 15 = 3 × 5 a = 2 , b = 3 {\displaystyle 3\times 5\,a=2,b=3} and y 0 = 1 {\displaystyle y_{0}=1} . Hence φ ( m ) = 2 × 4 = 8 {\displaystyle \varphi (m)=2\times 4=8\,} and the sequence ( y n ) n ⩾ 0 = ( 1 , 5 , 13 , 2 , 4 , 7 , 1 , … ) {\displaystyle (y_{n})_{n\geqslant 0}=(1,5,13,2,4,7,1,\dots )} is not maximum.
The result below shows that these sequences are closely related to the following inversive congruential sequence with prime moduli.
For 1 ≤ i ≤ r {\displaystyle 1\leq i\leq r} let Z p i = { 0 , 1 , … , p i − 1 } , m i = m / p i {\displaystyle \mathbb {Z} _{p_{i}}=\{0,1,\dots ,p_{i}-1\},m_{i}=m/p_{i}} and a i , b i ∈ Z p i {\displaystyle a_{i},b_{i}\in \mathbb {Z} _{p_{i}}} be integers with
a ≡ m i 2 a i ( mod p i ) and b ≡ m i b i ( mod p i ) . {\displaystyle a\equiv m_{i}^{2}a_{i}{\pmod {p_{i}}}\;{\text{and }}\;b\equiv m_{i}b_{i}{\pmod {p_{i}}}{\text{. }}}Let ( y n ) n ⩾ 0 {\displaystyle (y_{n})_{n\geqslant 0}} be a sequence of elements of Z p i {\displaystyle \mathbb {Z} _{p_{i}}} , given by
y n + 1 ( i ) ≡ a i ( y n ( i ) ) p i − 2 + b i ( mod p i ) , n ⩾ 0 where y 0 ≡ m i ( y 0 ( i ) ) ( mod p i ) is assumed. {\displaystyle y_{n+1}^{(i)}\equiv a_{i}(y_{n}^{(i)})^{p_{i}-2}+b_{i}{\pmod {p_{i}}}\;{\text{, }}n\geqslant 0\;{\text{where}}\;y_{0}\equiv m_{i}(y_{0}^{(i)}){\pmod {p_{i}}}\;{\text{is assumed. }}}Theorem 1
Let ( y n ( i ) ) n ⩾ 0 {\displaystyle (y_{n}^{(i)})_{n\geqslant 0}} for 1 ≤ i ≤ r {\displaystyle 1\leq i\leq r} be defined as above. Then
y n ≡ m 1 y n ( 1 ) + m 2 y n ( 2 ) + ⋯ + m r y n ( r ) ( mod m ) . {\displaystyle y_{n}\equiv m_{1}y_{n}^{(1)}+m_{2}y_{n}^{(2)}+\dots +m_{r}y_{n}^{(r)}{\pmod {m}}.}This theorem shows that an implementation of Generalized Inversive Congruential Generator is possible, where exact integer computations have to be performed only in Z p 1 , … , Z p r {\displaystyle \mathbb {Z} _{p_{1}},\dots ,\mathbb {Z} _{p_{r}}} but not in Z m . {\displaystyle \mathbb {Z} _{m}.}
Proof:
First, observe that m i ≡ 0 ( mod p j ) , for i ≠ j , {\displaystyle m_{i}\equiv 0{\pmod {p_{j}}},\;{\text{for}}\;i\neq j,} and hence y n ≡ m 1 y n ( 1 ) + m 2 y n ( 2 ) + ⋯ + m r y n ( r ) ( mod m ) {\displaystyle y_{n}\equiv m_{1}y_{n}^{(1)}+m_{2}y_{n}^{(2)}+\dots +m_{r}y_{n}^{(r)}{\pmod {m}}} if and only if y n ≡ m i ( y n ( i ) ) ( mod p i ) {\displaystyle y_{n}\equiv m_{i}(y_{n}^{(i)}){\pmod {p_{i}}}} , for 1 ≤ i ≤ r {\displaystyle 1\leq i\leq r} which will be shown on induction on n ⩾ 0 {\displaystyle n\geqslant 0} .
Recall that y 0 ≡ m i ( y 0 ( i ) ) ( mod p i ) {\displaystyle y_{0}\equiv m_{i}(y_{0}^{(i)}){\pmod {p_{i}}}} is assumed for 1 ≤ i ≤ r {\displaystyle 1\leq i\leq r} . Now, suppose that 1 ≤ i ≤ r {\displaystyle 1\leq i\leq r} and y n ≡ m i ( y n ( i ) ) ( mod p i ) {\displaystyle y_{n}\equiv m_{i}(y_{n}^{(i)}){\pmod {p_{i}}}} for some integer n ⩾ 0 {\displaystyle n\geqslant 0} . Then straightforward calculations and Fermat's Theorem yield
y n + 1 ≡ a y n φ ( m ) − 1 + b ≡ m i ( a i m i φ ( m ) ( y n ( i ) ) φ ( m ) − 1 + b i ) ≡ m i ( a i ( y n ( i ) ) p i − 2 + b i ) ≡ m i ( y n + 1 ( i ) ) ( mod p i ) {\displaystyle y_{n+1}\equiv ay_{n}^{\varphi (m)-1}+b\equiv m_{i}(a_{i}m_{i}^{\varphi (m)}(y_{n}^{(i)})^{\varphi (m)-1}+b_{i})\equiv m_{i}(a_{i}(y_{n}^{(i)})^{p_{i}-2}+b_{i})\equiv m_{i}(y_{n+1}^{(i)}){\pmod {p_{i}}}} ,which implies the desired result.
Generalized Inversive Congruential Pseudorandom Numbers are well equidistributed in one dimension. A reliable theoretical approach for assessing their statistical independence properties is based on the discrepancy of s-tuples of pseudorandom numbers.
Discrepancy bounds of the GIC Generator
We use the notation D m s = D m ( x 0 , … , x m − 1 ) {\displaystyle D_{m}^{s}=D_{m}(x_{0},\dots ,x_{m}-1)} where x n = ( x n , x n + 1 , … , x n + s − 1 ) {\displaystyle x_{n}=(x_{n},x_{n}+1,\dots ,x_{n}+s-1)} ∈ [ 0 , 1 ) s {\displaystyle [0,1)^{s}} of Generalized Inversive Congruential Pseudorandom Numbers for s ≥ 2 {\displaystyle s\geq 2} .
Higher bound
Let s ≥ 2 {\displaystyle s\geq 2} Then the discrepancy D m s {\displaystyle D_{m}^{s}} satisfies D m {\displaystyle D_{m}} s {\displaystyle ^{s}} < m − 1 / 2 {\displaystyle m^{-1/2}} × ( 2 π {\displaystyle ({\frac {2}{\pi }}} × log m + 7 5 ) s {\displaystyle \log m+{\frac {7}{5}})^{s}} × ∏ i = 1 r ( 2 s − 2 + s ( p i ) − 1 / 2 ) + s m − 1 {\displaystyle \textstyle \prod _{i=1}^{r}(2s-2+s(p_{i})^{-1/2})+s_{m}^{-1}} for any Generalized Inversive Congruential operator.Lower bound:
There exist Generalized Inversive Congruential Generators with D m {\displaystyle D_{m}} s {\displaystyle ^{s}} ≥ 1 2 ( π + 2 ) {\displaystyle {\frac {1}{2(\pi +2)}}} × m − 1 / 2 {\displaystyle m^{-1/2}} : × ∏ i = 1 r ( p i − 3 p i − 1 ) 1 / 2 {\displaystyle \textstyle \prod _{i=1}^{r}({\frac {p_{i}-3}{p_{i}-1}})^{1/2}} for all dimension s :≥ 2.For a fixed number r of prime factors of m, Theorem 2 shows that D m ( s ) = O ( m − 1 / 2 ( log m ) s ) {\displaystyle D_{m}^{(s)}=O(m^{-1/2}(\log m)^{s})} for any Generalized Inversive Congruential Sequence. In this case Theorem 3 implies that there exist Generalized Inversive Congruential Generators having a discrepancy D m ( s ) {\displaystyle D_{m}^{(s)}} which is at least of the order of magnitude m − 1 / 2 {\displaystyle m^{-1/2}} for all dimension s ≥ 2 {\displaystyle s\geq 2} . However, if m is composed only of small primes, then r can be of an order of magnitude ( log m ) / log log m {\displaystyle (\log m)/\log \log m} and hence ∏ i = 1 r ( 2 s − 2 + s ( p i ) − 1 / 2 ) = O ( m ϵ ) {\displaystyle \textstyle \prod _{i=1}^{r}(2s-2+s(p_{i})^{-1/2})=O{(m^{\epsilon })}} for every ϵ > 0 {\displaystyle \epsilon >0} .1 Therefore, one obtains in the general case D m s = O ( m − 1 / 2 + ϵ ) {\displaystyle D_{m}^{s}=O(m^{-1/2+\epsilon })} for every ϵ > 0 {\displaystyle \epsilon >0} .
Since ∏ i = 1 r ( ( p i − 3 ) / ( p i − 1 ) ) 1 / 2 ⩾ 2 − r / 2 {\displaystyle \textstyle \prod _{i=1}^{r}((p_{i}-3)/(p_{i}-1))^{1/2}\geqslant 2^{-r/2}} , similar arguments imply that in the general case the lower bound in Theorem 3 is at least of the order of magnitude m − 1 / 2 − ϵ {\displaystyle m^{-1/2-\epsilon }} for every ϵ > 0 {\displaystyle \epsilon >0} . It is this range of magnitudes where one also finds the discrepancy of m independent and uniformly distributed random points which almost always has the order of magnitude m − 1 / 2 ( log log m ) 1 / 2 {\displaystyle m^{-1/2}(\log \log m)^{1/2}} according to the law of the iterated logarithm for discrepancies.2 In this sense, Generalized Inversive Congruential Pseudo-random Numbers model true random numbers very closely.
See also
- Pseudorandom number generator
- List of random number generators
- Linear congruential generator
- Inversive congruential generator
- Naor-Reingold Pseudorandom Function
Notes
- Eichenauer-Herrmann, Jürgen (1994), "On Generalized Inversive Congruential Pseudorandom Numbers", Mathematics of Computation, 63 (207) (first ed.), American Mathematical Society: 293–299, doi:10.1090/S0025-5718-1994-1242056-8, JSTOR 2153575