当前位置:   article > 正文

matlab画瑞丽分布pdf,在matlab中看瑞利分布有此程序画瑞利分布的两个函数:其一:N=10000;x=randn(1,N);y=randn(1,N);r=sqrt(0.5*(x.^2+y.^...

瑞利分布matlab公式

7d14a2b81882cfe4494b096a84150b2a.png 优质解答

% by dynamic

% 2009-8-4 9:49:08

%

Matlab中提供了直接的函数,生成瑞利分布随机数raylrnd

下面我提供一个直接的函数吧

function x = RelayDist(x0,sigma,n)

x = zeros(n,1);

for i=1:n

r = MixMOD(x0,10,1);

k = 0;

while r(10) == 0

k = k + 1;

r(10) = power(2,k);

r = MixMOD(r(10),2,1);

end

y = -2*log(r(10));

x(i) = sigma*sqrt(y);

x0 = x(i);

end

function r = MixMOD(x0,n,type)

format long;

M1 = power(2,31);

M2 = power(2,35);

a1 = 314159269;

a2 = power(5,15);

c1 = 453806245;

c2 = 1;

r = zeros(n,1);

x = zeros(n+1,1);

x(1) = x0;

if type == 1

for i=2:n+1

y = a1*x(i-1)+c1;

x(i) = mod(y,M1);

r(i-1) = x(i)/M1;

end

else

for i=2:n+1

y = a2*x(i-1)+c2;

x(i) = mod(y,M2);

r(i-1) = x(i)/M2;

end

end

format short;

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/83859
推荐阅读
相关标签
  

闽ICP备14008679号