Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我写了这段代码:
for i=1:m-1 x(i+1)=mod(a*x(i)+c,m) x(i)=x(i+1) end
但我不知道如何将 lcg 编写为生成随机数的函数。
LCG 是一种线性同余生成器,它是最古老和最著名的伪随机数生成器算法之一。生成器由递归关系定义:
Xn+1 =(aXn + c) mod m
,我想为这种关系写一个函数。