# Transform a single random value to normally distributed one

Is there a (calculable) function that given a single, uniformly distributed random value 0 <= x < 1, can "transform" it to a normally distributed value with mean 0 and standard deviation 1?

If there's not an exact function, is there an approximation?

• Box-Muller transform is your friend. Mar 10 '17 at 7:52
• @ivan But BMT works with 2 random values. I want just 1 input. Mar 10 '17 at 7:53
• Then calculate the inverse error function. Though not elementary and not very practical, it surely is calculable via various series or something. Mar 10 '17 at 8:02
• You should state that $x$ is uniformly distributed.
– user65203
Mar 10 '17 at 11:36
• Why inverse in the title ?
– user65203
Mar 10 '17 at 11:41

If you are concerned by solving for $x$ equation $$\text{erf}(x)=a$$ you could be interested by this post where I proposed as an approximation $$\mathrm{erf}\!\left(x\right)\approx\sqrt{1-\exp\Big(-\frac 4 {\pi}\,\frac{1+\alpha\, x^2}{1+\beta\, x^2}\,x^2 \Big)}$$ where $$\alpha=\frac{10-\pi ^2}{5 (\pi -3) \pi }\qquad \text{and}\qquad \beta=\frac{120-60 \pi +7 \pi ^2}{15 (\pi -3) \pi }$$ which then reduces to solve $$\log(1-a^2)=-\frac 4 {\pi}\,\frac{1+\alpha \,x^2}{1+\beta\, x^2}\,x^2$$ which is a quadratic equation in $x^2$.

For illustration purposes, I give below a few values $$\left( \begin{array}{ccc} a & \text{erf}^{-1}(a) & \text{approx} \\ 0.05 & 0.044340 & 0.044340 \\ 0.10 & 0.088856 & 0.088856 \\ 0.15 & 0.133727 & 0.133727 \\ 0.20 & 0.179143 & 0.179143 \\ 0.25 & 0.225312 & 0.225312 \\ 0.30 & 0.272463 & 0.272463 \\ 0.35 & 0.320858 & 0.320858 \\ 0.40 & 0.370807 & 0.370807 \\ 0.45 & 0.422680 & 0.422681 \\ 0.50 & 0.476936 & 0.476937 \\ 0.55 & 0.534159 & 0.534161 \\ 0.60 & 0.595116 & 0.595120 \\ 0.65 & 0.660854 & 0.660861 \\ 0.70 & 0.732869 & 0.732883 \\ 0.75 & 0.813420 & 0.813449 \\ 0.80 & 0.906194 & 0.906253 \\ 0.85 & 1.017900 & 1.018030 \\ 0.90 & 1.163090 & 1.163390 \\ 0.95 & 1.385900 & 1.386820 \\ 0.96 & 1.452220 & 1.453450 \\ 0.97 & 1.534490 & 1.536190 \\ 0.98 & 1.644980 & 1.647550 \\ 0.99 & 1.821390 & 1.825990 \end{array} \right)$$

• Maybe you should tell what the error function is and what is the connection of the inverse to the given problem. I am not sure that the OP is versed in these topics...
– user65203
Mar 10 '17 at 11:38
• This is pretty good, but it produces only one side of the bell. Is there a tweak to produce a complete bell, ie as many negative results as positive ones? And @yves is correct, I am not versed in these topics. Mar 10 '17 at 15:18
• This doesn't seem to work. It produces non-normal dist. Have I got it right: sqrt(1-exp(-1.27323954474*x*x)*(1+0.0586276296*x*x)/(1+0.0886745239*x*x))) ? Mar 11 '17 at 2:52
• After testing using the code in my previous comment, the values produced are roughly "normalish", but the values are all within 0-1 like a half bell, but I anted a sigma of 1, not a max range of 1. Also the high probability point is at the 1 end, not at zero (although I can deal with the bell being "reversed", so that in itself isn't a problem, just an inconvenience of having to use 1 - f(x) instead) Mar 11 '17 at 9:28
• @Bohemian. Did you take into account the fact that $\text{erf}(-x)=-\text{erf}(x)$ ? Mar 11 '17 at 9:31

An easy approximation:

By the central limit theorem, take $n$ random samples, add them, subtract their mean ($\frac n2$) and divide by their standard deviation ($n/\sqrt{12}$) and you get a random variable which approximately follows a normal law. The larger $n$, the better the approximation (but also the cost).

• Exactly how do I take a single random value in the range 0 to 1 and using it produce a (obviously) single normally distributed value? Mar 10 '17 at 15:14