Box-Muller变换:学习笔记

算法说明

Box-Muller变换是通过服从均匀分布的随机变量,来构建服从高斯分布的随机变量的一种方法。具体的描述为:选取两个服从 [ 0 , 1 ] [0,1] [0,1]上均匀分布的随机变 U 1 U_1 U1 U 2 U_2 U2,使得 X X X Y Y Y满足高斯分布
X = σ cos ⁡ ( 2 π U 1 ) − 2 ln ⁡ U 2 + μ . , Y = σ sin ⁡ ( 2 π U 1 ) − 2 ln ⁡ U 2 + μ . X = \sigma \cos (2\pi {U_1})\sqrt { - 2\ln {U_2}} + \mu., \quad Y = \sigma \sin (2\pi {U_1})\sqrt { - 2\ln {U_2}} + \mu. X=σcos(2πU1)2lnU2 +μ.,Y=σsin(2πU1)2lnU2 +μ.
那么, X X X Y Y Y~ N ( μ , σ 2 ) N(\mu , \sigma^2) N(μ,σ2)

推导证明

P r o o f : Proof: Proof: Suppose X X X and Y Y Y satisfy N ( μ , σ 2 ) N(\mu, \sigma^2) N(μ,σ2), and they are i . i . d . i.i.d. i.i.d., the pdf is p ( X ) = 1 2 π σ e − ( X − μ ) 2 2 σ 2 , p ( Y ) = 1 2 π σ e − ( Y − μ ) 2 2 σ 2 . p(X)=\frac{1}{\sqrt{2\pi} \sigma}e^{-\frac{(X-\mu)^2}{2\sigma^2}}, \quad p(Y)=\frac{1}{\sqrt{2\pi} \sigma}e^{-\frac{(Y-\mu)^2}{2\sigma^2}}. p(X)=2π σ1e2σ2(Xμ)2,p(Y)=2π σ1e2σ2(Yμ)2.
then we have
P ( Z ) = P ( X Y ) = P ( X ) P ( Y ) = 1 2 π σ 2 e − ( X − μ ) 2 + ( Y − μ ) 2 2 σ 2 . P(Z)=P(XY)=P(X)P(Y)=\frac{1}{2\pi \sigma^2}e^{-\frac{(X-\mu)^2+(Y-\mu)^2}{2\sigma^2}}. P(Z)=P(XY)=P(X)P(Y)=2πσ21e2σ2(Xμ)2+(Yμ)2.
Do coordinate transformation, then
X = R c o s ( θ ) + μ , Y = R s i n ( θ ) + μ . X=Rcos(\theta)+\mu, \quad Y=Rsin(\theta)+\mu. X=Rcos(θ)+μ,Y=Rsin(θ)+μ.
the sum of pdf of Z Z Z can be written as
1 = ∫ − ∞ ∞ ∫ − ∞ ∞ 1 2 π σ 2 e − ( X − μ ) 2 + ( Y − μ ) 2 2 σ 2 d X d Y = ∫ 0 2 π ∫ 0 ∞ 1 2 π σ 2 e − R 2 2 σ 2 R d R d θ . 1=\int\limits_{ - \infty }^\infty {\int\limits_{ - \infty }^\infty {\frac{1}{{2\pi {\sigma ^2}}}{e^{ - \frac{{{{(X - \mu )}^2} + {{(Y - \mu )}^2}}}{{2{\sigma ^2}}}}}dXdY} } =\int\limits_0^{2\pi } {\int\limits_0^\infty {\frac{1}{{2\pi {\sigma ^2}}}{e^{ - \frac{{{R^2}}}{{2{\sigma ^2}}}}}RdRd\theta } } . 1=2πσ21e2σ2(Xμ)2+(Yμ)2dXdY=02π02πσ21e2σ2R2RdRdθ.
This leads to the distribution functions of R R R and θ θ θ are
P ( R ≤ r ) = ∫ 0 2 π d θ ∫ 0 r 1 2 π σ 2 e − R 2 2 σ 2 R d R = 1 − e − r 2 2 σ 2 , P ( θ ≤ ϕ ) = = ∫ 0 ϕ d θ ∫ 0 ∞ 1 2 π σ 2 e − R 2 2 σ 2 R d R = ϕ 2 π . P(R\leq r)=\int\limits_0^{2\pi } d\theta {\int\limits_0^r {\frac{1}{{2\pi {\sigma ^2}}}{e^{ - \frac{{{R^2}}}{{2{\sigma ^2}}}}}RdR } } =1-e^{-\frac{r^2}{2\sigma^2}}, \quad P(\theta \leq \phi)==\int\limits_0^{\phi } d\theta{\int\limits_0^\infty {\frac{1}{{2\pi {\sigma ^2}}}{e^{ - \frac{{{R^2}}}{{2{\sigma ^2}}}}}RdR } }=\frac{\phi}{2\pi}. P(Rr)=02πdθ0r2πσ21e2σ2R2RdR=1e2σ2r2,P(θϕ)==0ϕdθ02πσ21e2σ2R2RdR=2πϕ.
It is obvious that θ \theta θ satisfies a uniform distribution on [ 0 , 2 π ] [0, 2\pi] [0,2π]. Let
F R ( r ) = 1 − e − r 2 2 σ 2 , F_R(r)=1-e^{-\frac{r^2}{2\sigma^2}}, FR(r)=1e2σ2r2,
then its inverse function is
R = F R − 1 ( z ) = σ − 2 l n ( 1 − z ) . R=F_R^{-1}(z)=\sigma\sqrt{-2ln(1-z)}. R=FR1(z)=σ2ln(1z) .
When z z z satisfies the uniform distribution on [ 0 , 1 ] [0,1] [0,1], the distribution function of R is F R ( r ) F_R(r) FR(r). So we can choose U 1 U_1 U1 and U 2 U_2 U2 which satisfy the uniform distribution, let
θ = 2 π U 1 , R = σ − 2 l n U 2 . \theta = 2\pi U_1,\quad R=\sigma\sqrt{-2lnU_2}. θ=2πU1,R=σ2lnU2 .
Bringing them to X X X and Y Y Y, then we can get that the initial X X X or Y Y Y satisfies the Gaussian distribution.

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Haleine

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值