Solved – Generation of Normal Distributed Numbers (with Box-Muller method?)

distributionsnormal distributionquantilesrandom-generation

I want to generate several random, normal distributed numbers. At the moment I use the Box-Muller method.

I have a function that returns a single number, and for this I use the following formula:
enter image description here

But I ask myself if it's right to use only one number. Because actually the Box-Muller method generates two independent values.

But it's necessary for my function that it returns only one value. So it is mathematical right to reject the second value? Are there other methods that generate only one value?

Best Answer

Mathematically, $$Z=\sqrt{-2\log U_1}\,\cos(2\pi U_2)$$ is a normal $\mathcal{N}(0,1)$ random variable, whether or not you also compute $$Z^\prime=\sqrt{-2\log U_1}\,\sin(2\pi U_2)$$or any other transform of the pair $(U_1,U_2)$. Hence it is completely "right" or rather correct to forego the second spherical coordinate.

A one-to-one generator of the Normal $\mathcal{N}(0,1)$ distribution can be based on the inverse cdf principle: if $\Phi$ is the Normal $\mathcal{N}(0,1)$ cdf, then$$X=\Phi^{-1}(U)$$ is a normal $\mathcal{N}(0,1)$ random variable when $U$ is uniform. This however requires a "perfect" evaluation of the inverse cdf $\Phi^{-1}$.

For instance, here is a normal fit based on the simulation

x=qnorm(1e7)

which does not exhibit clear divergence from a normal fit:

enter image description here

Related Question