Using Linear congruential to generate 10,000 uniform random variables
4 次查看(过去 30 天)
显示 更早的评论
I want to generate uniform random variables between 0 and 1 by using X(n+1)=(1664525*X(n)+1013904223) mod^32, but i couldn't.
Please help...
this is my code:
clear all; clc;
a=1664525; c=1013904223; m=2^32;
for n=1:10000
X(n)=mod((a*X(n)+c), m);
end
disp(X);
0 个评论
采纳的回答
Alan Stevens
2020-11-27
You need an intial value for X(1); and you need to set
for n=2:10000
X(n+1)=mod((a*X(n)+c), m);
end
7 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!