線性同餘方法

来自testwiki
跳转到导航 跳转到搜索

Template:No footnotes 線性同餘方法(LCG)是個產生偽隨機數的方法。

它是根據以下的遞迴關係式

Nj+1(A×Nj+B)(modM)

其中A,B,M是產生器設定的常數。

LCG的週期最大為M,但大部分情況都會少於M。要令LCG達到最大週期,應符合以下條件:

  1. B,M互質
  2. M的所有質因數都能整除A1
  3. M是4的倍數A1也是;
  4. A,B,N0都比M小;
  5. A,B是正整數。

随机性

因为通过线性同余方法构建的伪随机数生成器的内部状态可以轻易地由其输出演算得知,所以此种伪随机数生成器属于统计学伪随机数生成器。

设计密码学的应用必须至少使用密码学安全伪随机数生成器,故需要避免由线性同余方法获得的随机数在密码学中的应用。

參見

參考文獻

Template:Refbegin

  • Template:Cite journal
  • D. E. Knuth. The Art of Computer Programming, Volume 2: Seminumerical Algorithms, Third Edition. Addison-Wesley, 1997. ISBN 0-201-89684-2. Section 3.2.1: The Linear Congruential Method, pp. 10–26.
  • Template:Cite journal
  • Template:Citation
  • Gentle, James E., (2003). Random Number Generation and Monte Carlo Methods, 2nd edition, Springer, ISBN 0-387-00178-6.
  • Template:Cite journal (in this paper, efficient algorithms are given for inferring sequences produced by certain pseudo-random number generators).

Template:Refend

外部連結