The Box-Muller transformation

Let N_1,N_2 be independent N(0,1) random variates. (N_1,N_2) defines a point in Cartesian coordinates. We transform to polar by

N_1 = R \cos \theta
N_2 = R \sin \theta

This transformation is one to one and has continuous derivatives. So we can derive the joint distribution f_{R,\theta}(r,\theta) by using

f_{R,\theta}(r,\theta) = f_{N_1,N_2}(n_1,n_2)|J^{-1}|

where J is the Jacobian of the transformation and

J^{-1}(r,\theta )= {\begin{bmatrix}{\dfrac {\partial n_1}{\partial r}}{\dfrac {\partial n_1}{\partial \theta }} \\ {\dfrac {\partial n_2}{\partial r}}{\dfrac {\partial n_2}{\partial \theta }} \end{bmatrix}}   = \begin{bmatrix} \cos \theta & -r\sin \theta \\ \sin \theta & r\cos \theta \end{bmatrix} 



|J^{-1}| = r \cos^2 \theta + r \sin^2 \theta = r


f_{R, \theta} (r, \theta) = r \frac{1}{2\pi} e^{- \frac{1}{2}(n_1^2+n_2^2)} = \boxed{\frac{r}{2 \pi}e^{-\frac{1}{2}(r^2)}}, 0 \leq \theta \leq 2 \pi, 0 \leq r \leq \infty

And we see \theta \sim unif[0,2\pi] (since f_{\Theta}(\theta) = \frac{1}{2\pi} ) and R^2 \sim \exp(1/2)

Hence, to simulate \Theta we simply take 2 \pi U_2 where

U_2 \sim unif[0,1]

and to simulate R we can take

-2\ln U_1 where U_1 \sim unif[0,1].


( to see why find the density of X=-\ln U, U \sim unif[0,1]).
So, Box and Muller simply inverted N_1= R \cos \theta, N_2= R \sin \theta and moved from (R,\Theta) to (N_1,N_2) by simulating \Theta from 2 \pi U_2 , and an independent R from \sqrt{- 2 \ln U_1}

Continue reading “The Box-Muller transformation”

Karl Popper: Conjectures and Refutations

(1) It is easy to obtain confirmations, or verifications, for nearly every theory-if we look for confirmations.

(2) Confirmations should count only if they are the result of risky predictions; that is to say, if, unenlightened by the theory in question, we should have expected an event which was incompatible with the theory–an event which would have refuted the theory.

(3) Every ‘good’ scientific theory is a prohibition: it forbids certain things to happen. The more a theory forbids, the better it is.

(4) A theory which is not refutable by any conceivable event is nonscientific. Irrefutability is not a virtue of a theory (as people often think) but a vice.

(5) Every genuine test of a theory is an attempt to falsify it, or to refute it. Testability is falsifiability; but there are degrees of testability: some theories are more testable, more exposed to refutation, than others; they take, as it were, greater risks.

(6) Confirming evidence should not count except when it is the result of a genuine test of the theory; and this means that it can be presented as a serious but unsuccessful attempt to falsify the theory. (I now speak in such cases of ‘corroborating evidence’.)

(7) Some genuinely testable theories, when found to be false, are still upheld by their admirers–for example by introducing ad hoc some auxiliary assumption, or by re-interpreting theory ad hoc in such a way that it escapes refutation. Such a procedure is always possible, it rescues the theory from refutation only at the price of destroying, or at least lowering, scientific status.


Excerpt from a lecture given by Karl Popper at Peterhouse, Cambridge, in Summer 1953, as part of a course on Developments and trends in contemporary British philosophy.