0
$\begingroup$

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?

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

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)$$

$\endgroup$
6
  • $\begingroup$ 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... $\endgroup$
    – user65203
    Mar 10 '17 at 11:38
  • $\begingroup$ 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. $\endgroup$
    – Bohemian
    Mar 10 '17 at 15:18
  • $\begingroup$ 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))) ? $\endgroup$
    – Bohemian
    Mar 11 '17 at 2:52
  • $\begingroup$ 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) $\endgroup$
    – Bohemian
    Mar 11 '17 at 9:28
  • $\begingroup$ @Bohemian. Did you take into account the fact that $\text{erf}(-x)=-\text{erf}(x)$ ? $\endgroup$ Mar 11 '17 at 9:31
0
$\begingroup$

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).

$\endgroup$
1
  • $\begingroup$ 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? $\endgroup$
    – Bohemian
    Mar 10 '17 at 15:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.