最后更新于3年前
METHOD1: 线性同余法选取种子x0x_0x0选取m,a,cm,a,cm,a,c,使得2≤a<m,0≤c<m,0≤x0≤m2\leq a<m,0\leq c<m,0\leq x_0\leq m2≤a<m,0≤c<m,0≤x0≤mxn+1≡a⋅xn+c(mod m)x_{n+1}\equiv a\cdot x_n+c\left(\mod m\right)xn+1≡a⋅xn+c(modm)METHOD2: 纯乘法同余法选取素数mmm(通常为梅森素数M31=231−1M_{31}=2^{31}-1M31=231−1),aaa取其原根,最大周期长度为m−1m-1m−1xn+1≡a⋅xn(mod m)x_{n+1}\equiv a\cdot x_n\left(\mod m\right)xn+1≡a⋅xn(modm)METHOD3: 平方伪随机xn+1≡xn2+1(mod m)x_{n+1}\equiv x_{n}^{2}+1\left(\mod m\right)xn+1≡xn2+1(modm)
METHOD1: 线性同余法
选取种子x0x_0x0
选取m,a,cm,a,cm,a,c,使得2≤a<m,0≤c<m,0≤x0≤m2\leq a<m,0\leq c<m,0\leq x_0\leq m2≤a<m,0≤c<m,0≤x0≤m
xn+1≡a⋅xn+c(mod m)x_{n+1}\equiv a\cdot x_n+c\left(\mod m\right)xn+1≡a⋅xn+c(modm)
METHOD2: 纯乘法同余法
选取素数mmm(通常为梅森素数M31=231−1M_{31}=2^{31}-1M31=231−1),aaa取其原根,最大周期长度为m−1m-1m−1
xn+1≡a⋅xn(mod m)x_{n+1}\equiv a\cdot x_n\left(\mod m\right)xn+1≡a⋅xn(modm)
METHOD3: 平方伪随机
xn+1≡xn2+1(mod m)x_{n+1}\equiv x_{n}^{2}+1\left(\mod m\right)xn+1≡xn2+1(modm)