|
1) 按照中心极限定理,对于独立同分布的随机变量之和逼近于正态分布。
这样就可以用rand()生成的随机数,有限次相加就可以逼近正态分布了。
加上平均值和偏差也就可以模拟服从高斯分布的随机数了。
2)由于上述需要多次相加,计算量比较大。由此有另外一种方法就是
将两个独立生成的服从均匀分布的随机数U1,U2(0,1之间)。进行如下转换
即服从两个独立的正态分布。
u,v为极坐标,s为平方和开根号(半径)
s与U1对应,与U2对应。
为啥经过这个变化就可以直接得到服从正态分布的数呢。
If u is uniformly distributed in the interval 0 ≤ u < 1,
then the point (cos(2πu), sin(2πu)) is uniformly distributed on the unit circumference x2 + y2 = 1,
and multiplying that point by an independent random variable ρ whose distribution is
will produce a point
whose coordinates are jointly distributed as two independent standard normal random variables.
此处的u即为上述的服从均匀分布的U2
而rho,正好是上述U1的chi-2距离。正好服从上述分布
那么就说明,产生的两个点z0,z1服从独立的正态分布。
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-27 11:45
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社