normal distribution, lognormal distribution,正态随机数的生成

normal distribution,正态分布,又称高斯分布,其PDF是一个钟形区线。

lognormal distribution为对数正态分布


对数正态分布对数正态分布的任意随机变量概率分布。如果 X 是正态分布的随机变量,则 exp(X) 为对数分布;同样,如果 Y 是对数正态分布,则 ln(Y) 为正态分布。


参见: http://zh.wikipedia.org/wiki/%E5%AF%B9%E6%95%B0%E6%AD%A3%E6%80%81%E5%88%86%E5%B8%83


Matlab中对数对数分布的函数为lognpdf,用法示例如下:

Example

Suppose the income of a family of four in the United States follows a lognormal distribution with µ =log(20,000) and σ2 = 1.0. Plot the income density.

x = (10:1000:125010)';
y = lognpdf(x,log(20000),1.0);
plot(x,y)
set(gca,'xtick',[0 30000 60000 90000 120000])
set(gca,'xticklabel',{'0','$30,000','$60,000',...
                             '$90,000','$120,000'})

生成正态分布随机变量(来自维基百科)

在计算机模拟中,经常需要生成正态分布的数值。最基本的一个方法是使用标准的正态累积分布函数的反函数。除此之外还有其他更加高效的方法,Box-Muller变换就是其中之一。另一个更加快捷的方法是ziggurat算法。下面将介绍这两种方法。一个简单可行的并且容易编程的方法是:求12个在(0,1)上均匀分布的和,然后减6(12的一半)。这种方法可以用在很多应用中。这12个数的和是Irwin-Hall分布;选择一个方差12。这个随即推导的结果限制在(-6,6)之间,并且密度为12,是用11次多项式估计正态分布。

% Generating Gaussian Variates with zero mean and
% standard deviation sigma
% Date: 2012-10-13 from MATLAB BBS
sgma = 3.8;     % sigm = standard deviation
pi=3.14;
N=1000;         % the number of random variables


%method 1
% The method I used is the standard transformation technqiue to 
% generate Rayleigh RV from uniform RV. 
% This approach also has physical significance as well. 
% It's well-known in wireless communication theory 
% that a complex Gaussian fading process has Rayleigh-distributed
% envelope and (independent) uniform phase.
gsrv = zeros(1, N);              %alloc 1XN size.
for i=1:N
  u=rand;
  z=sgma*(sqrt(2*log(1/(1-u))));  % z is Rayleigh-distributed. 
  
  u=rand;                        % make z & u independent
  gsrv(i)=z*cos(2*pi*u);
end;
plot(1:N, gsrv);


%methods 2 -  Box-Muller method 
figure;
for i=1:N
   u1 = rand(N,1);
   u2 = rand(N,1);
   z = sqrt(-2*log(u1));
   gsrv = z.*cos(2*pi*u2)*sgma;
end;
plot(1:N, gsrv);


  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值