Skip to content
All library documents

Box–Muller Gaussian Sampling and the Jacobian Change of Variables

Article Quant Q&A · Author: A. B

Summary

The document explains why the Box–Muller transformation uses a Jacobian when converting two independent uniform random variables into a pair of Gaussian variables. It first describes the radius and angle variables: the radius has a Rayleigh distribution, the angle is uniform, and they are independent. Applying the polar-coordinate transformation changes the joint density, with the absolute determinant accounting for how areas are stretched or compressed. The resulting joint density factors into two standard normal densities, establishing independence.

A second answer works backward from the transformed variables to the uniforms and computes a Jacobian directly. The central lesson is that independence of the inputs lets their densities multiply, while the determinant is still needed to express that density in the new coordinates. The responses are informal and contain some inconsistent variable labels and apparent algebraic errors in the final density expression, so the derivation should be checked against a standard Box–Muller proof.

Key ideas

  • Independent uniform inputs have a joint density equal to the product of their individual densities.
  • The Box–Muller construction can be expressed as a transformation from radius and angle to Cartesian coordinates.
  • A Jacobian determinant adjusts a density for the area change under a nonlinear coordinate transformation.
  • The transformed joint density factors into standard normal marginal densities, showing independence.

Tags

Full text
# Box-Muller Method Proof


# Box-Muller Method Proof












Here we want to show that the Box-Muller method generates a pair of independent standard Gaussian random variables. But I don't understand why we use the determinant? For me when you have two independent variables the joint density function is only the product of the two density function. Someone can explain me the meaning of the determinant here? Please.

## Answer by user16651 (score 2, accepted)

https://quant.stackexchange.com/a/29874

Let $Z=\sqrt{-2\ln(X_1)}$, We have

\begin{align} \mathbb{P}\left[Z \leq z\right] = \mathbb{P}\left[-2 \ln(X_1) \leq z^2\right] = \mathbb{P}\left[\ln(X_1) \geq -\frac{z^2}{2}\right] = 1 - \mathbb{P}\biggl[X_1 < \exp\left(-\frac{z^2}{2}\right)\biggr]\, \end{align} $X_1$ is uniformly defined on $[0, 1]$, therefore $$\mathbb{P}[Z\leq z] = 1 - \int_0^{\exp(-z^2/2)} \, dt = 1 - \exp\left(-\frac{z^2}{2}\right).$$ Indeed $$f_Z(z)=\begin{cases} \exp\left(-\frac{z^2}{2}\right),\quad z>0\\ 0\qquad\qquad,\quad \text{o.w} \end{cases}$$ let $W=2\pi X_2$. Hence $X_2$ is uniformly distributed on $[0,1]$, so $$f_W(w)=\begin{cases} \frac{1}{2\pi},\quad 0< w\le 2\pi\\ 0\,\,\,\,, \quad\text{o.w} \end{cases}$$ Since $X_1$ and $X_2$ are independent, $Z$ and $W$ should be independent. We have $$f_{Z,W}(z,w)=f_{Z}(z)f_{W}(w)= \begin{cases} \frac{1}{2\pi}\exp\left(-\frac{z^2}{2}\right),\quad z>0\quad \text{and}\quad 0< w\le 2\pi\\ 0\qquad\qquad\quad\,,\quad \text{o.w} \end{cases}$$ Define function $q:(0,\infty)\times(0,2\pi]\to \mathbb{R}^2$ such that $q(z,w)=(z\cos(w),z\sin(w))$ thus $$\mathbb{P}_{Y_1,Y_2}=\mathbb{P}_{Z,W}\circ q^{-1}$$ in other words $$q_{Y_1,Y_2}(y_1,y_2)=\frac{f_{Z, W}(q^{-1}(y_1, y_2))}{|\det(q'(q^{-1}(y_1, y_2)))|}$$ we can show easily $$z=\sqrt{y_1^2+y_2^2}$$ then $$q_{Y_1,Y_2}(y_1,y_2) = \frac{1}{2 \pi} \exp\left(-\frac{y_1^2 + y_2^2}{2}\right)$$

## Answer by Vu Nguyen (score 2)

https://quant.stackexchange.com/a/48799

It can be seen that $Y_1^2+Y_2^2=-2\log{X_2}$ and that $Y_2 \over Y_1$ $=\tan(2\pi X_1)$.

Therefore $X_1={1 \over{2 \pi}}{\arctan{Y_2 \over Y_1}}$ and $X_2=\exp{-(Y_1^2+Y_2^2) \over 2}$.

Taking differential to get $dX_1= {1 \over{2\pi}}{{-Y_2dY_1+Y_1dY_2} \over{Y_1^2+Y_2^2}}$.

Similarly, $ dX_2= {\exp {-{Y_1^2+Y_2^2} \over 2}(Y_1 dY_1 + Y_2dY_2 )}$.

Hence Jacobian $\mathbb J$$({{X_1,X_2} \over {Y_1,Y_2}})$ =$1\over {2 \pi}$ $\exp{-(Y_1^2+Y_2^2) \over 2}$.

For PDFs, as $f_{X_1,X_2}(x_1,x_2)$ $\mathbb J$$({{X_1,X_2} \over {Y_1,Y_2}}) =$ $f_{Y_1,Y_2}(y_1,y_2)$,

it gives $ f_{Y_1,Y_2}(y_1,y_2)=$ $\sqrt{1 \over{2 \pi}}$ $\exp{-y_1^2 \over 2}$ $\sqrt{1 \over{2 \pi}}$ $\exp{-y_1^2 \over 2}$

showing that $Y_1,Y_2$ are independent Gaussian random variables.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.