> For the complete documentation index, see [llms.txt](https://chenyangwang.gitbook.io/mathematical-base-for-information-safety/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chenyangwang.gitbook.io/mathematical-base-for-information-safety/su-xing-jian-yan/sui-ji-shu-sheng-cheng.md).

# 随机数生成

> * **METHOD1: 线性同余法**
>   * 选取种子$$x\_0$$
>   * 选取$$m,a,c$$，使得$$2\leq a\<m,0\leq c\<m,0\leq x\_0\leq m$$
>   * $$x\_{n+1}\equiv a\cdot x\_n+c\left(\mod m\right)$$
> * **METHOD2: 纯乘法同余法**
>   * 选取素数$$m$$（通常为梅森素数$$M\_{31}=2^{31}-1$$），$$a$$取其原根，最大周期长度为$$m-1$$
>   * $$x\_{n+1}\equiv a\cdot x\_n\left(\mod m\right)$$
> * **METHOD3: 平方伪随机**
>   * $$x\_{n+1}\equiv x\_{n}^{2}+1\left(\mod m\right)$$
