How to transform normally distributed random sequence N(0,1) to uniformly distributed U(0,1)? Everybody knows how to convert U(0,1) to N(0,1). However does anybody know an efficient algorithm solving the opposite task? I mean how to generate U(0,1) sequence from N(0,1) one?
Asking because a group of voice and speech researchers with whom I work are routinely trying to represent results of their measurements which they believe to be normally distributed using a linear 0 to 100 scale. As a result they are getting negative values outside of their linear scale obviously because they are dealing with random noise that can be roughly assumed to be normal and therefore this noise theoretically spans the whole real axis. Though I can imagine that I need to take a logarithm of the normal distribution, then multiply the negative quadratic term by -1 and then take a square root of it to get a linear function, a question is: does anybody know an efficient algorithm for doing that, I mean for generating high quality U(0,1) random numbers from N(0,1). I would highly appreciate any feedback on this!!
 A: Naively, this seems to just be a problem of remapping the probability densities. I do not understand the answer by vanna since that requires two variates.
Going from Gaussian to Uniform requires going from an infinite support $[-\infty,+\infty]$ to a finite support, like $[0,1]$.
I think that the simplest way to achieve this is along the lines of what stefan-hansen was suggesting:


*

*normalize the data to Gaussian(0,1) by subtracting the average and dividing by the standard deviation: $y = \frac{x - \hat\mu}{\hat\sigma}$, and

*transform the values using the CDF: $z=\frac{1}{2}Erfc(-\frac{y}{\sqrt{2}})$, where $Erfc$ is the complementary error function.


If $y$ is distributed with Gaussian(0,1), $z$ will be distributed as Uniform(0,1).
This requires having estimates of $\hat\mu$ and $\hat\sigma$ before proceeding with the transform, but that should not be a problem.
(I would post histograms illustrating the procedure, but I do not have enough points.)
A: According to Box-Muller method, if $(U_1,U_2)\sim \mathcal{U}([0,1])$ i.i.d. then
$$ Z_1 := \sqrt{-2\ln U_1} \cos(2\pi U_2) $$
$$ Z_2 := \sqrt{-2\ln U_1} \sin(2\pi U_2) $$
are i.i.d. $\mathcal{N}(0,1)$. You can go the opposte way and set
$$ U_1 := \exp\left(-\frac{1}{2}(Z_1^2+Z_2^2)\right) $$
$$ U_2 := \frac{1}{2\pi} \arccos \left( \frac{Z_1}{Z_1^2+Z_2^2} \right) $$
given i.i.d. normal random variables $(Z_1,Z_2)\sim \mathcal{N}(0,1)$. You will get i.i.d. uniforms on $[0,1]$.
The proof is straightforward by writing the cummulative distribution function of $U_1$ and $U_2$ and applying the appropriate change of variable. Indeed for $z \in [0,1]$,
\begin{eqnarray}
P(U_1\leq z) &=& P\left(\exp\left(-\frac{1}{2}(Z_1^2+Z_2^2)\right)<z\right) \\
& = & \frac{1}{2\pi} \int_{e^{-\frac{1}{2}(x^2+y^2)}<z} e^{-\frac{1}{2}x^2}e^{-\frac{1}{2} y^2}dxdy \\
& = & \frac{1}{2\pi} \int_0^{2\pi} \int_{\sqrt{-2\ln (z)}}^\infty e^{-\frac{1}{2}r^2} r dr d\theta \\
& = & [-e^{-\frac{1}{2}r^2}]_{\sqrt{-2\ln (z)}}^\infty \\
& = & z
\end{eqnarray}
It is clear also that $P(U_1 \leq z)=0$ when $z\leq0$ and $P(U_1 \leq z)=1$ when $z\geq1$. The same method will show that $U_2$ is uniform. Note that the $\arccos$ has to return values in $[0,2\pi]$.
Finally to return $n$ uniforms given $Z_1,...,Z_n$ i.i.d. $\mathcal{N}(0,1)$ just work by pair. $U_1,U_2$ generated with $Z_1,Z_2$, $U_3,U_4$ with $Z_3,Z_4$, etc. Pairwise independency of the $U_i$'s follows from the pairwise independency of the $Z_i$'s.
