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);