一.Box-Muller Transfrom

    对于给定一个能产生(0,1)之间的均匀分布的随机数产生器,可以利用Box-Muller transform来获得一个产生标准高斯分布随机数的随机数产生器。     Box-Muller transform可以描述如下:     假设U1和U2是两个独立的随机变量,并且其分布为(0,1)之间的均匀分布,可以得到

    Z1和Z2是两个互相独立的随机变量,并且这两个随机变量的分布为标准高斯分布

二.Matlab实验

代码
  %% clear clc; clear;   %% uniform distribution N = 1000000; U1 = rand(1, N); U2 = rand(1, N);     %% Get Gussion distribution using box-Muller transfrom Z1 = sqrt(-2 * log(U1)) .* cos(2 * pi * U2); Z2 = sqrt(-2 * log(U1)) .* sin(2 * pi * U2);       %% visualisztion of PDF subplot(2, 2, 1), hist(U1, 100), title( 'The PDF of U1' ); subplot(2, 2, 2), hist(U2, 100), title( 'The PDF of U2' ); subplot(2, 2, 3), hist(Z1, 100), title( 'The PDF of Z1' ); subplot(2, 2, 4), hist(Z2, 100), title( 'The PDF of Z2' );   

U1,U2,Z1和Z2的概率密度如下







参考文献 https://en.wikipedia/wiki/Box%E2%80%93Muller_transform




版权所有,欢迎转载,转载请注明出处,谢谢



更多推荐

通过均匀分布随机数产生器获得一个高斯分布随机数产生器