刚接触matlab 卖弄一下吧 编了个小程序 主要是在做蒙特卡洛模拟的时候需要产生很多正态分布的随机数 所以做了一个小程序
function n=NORM(m)
%to generate m numbers that fit normal distribution
%i use the method based on central limited therom
n=zeros(m,1);
%to generate a vector to store the m numbers
for k=1:m
x=rand(6);
%to generate 6 numbers that fit u(0,1)
y=rand(6)
%to generate 6 numbers that fit u(0,1)
sigx=x(1);
%to give a start that compute sigax
sigy=y(1);
%to give a start that copute sigay
for i=2:6
sigx=sigx+x(i);
%to compute the sigax
sigy=sigy+y(i);
%to compute the sigay
end
n(k)=sigx-sigy;
%to get a number that fits normal distribution
end


雷达卡






京公网安备 11010802022788号







