[Math] Converting a uniform distribution variable to a normal distribution one

normal distributionprobability distributionsstatisticsuniform distribution

I have a random number generator capable of outputting values in the range $(0, 1)$ in a uniform distribution with the peak centered at $0.5$. For my uses, though, I need a value that is normally distributed, even though its accuracy is not super critical.

After a bit of research on the net, I found several methods, such as Inverse Transform Sampling and Probability Integral Transform, but both methods are way too advanced for my extremely limited knowledge in statistics and I do not really understand them.

The other methods I found were the Box-Muller transform and the Ziggurat algorithm, but they seem overkill for my purposes.

Since I was not satisfied with my findings, I proceeded to analyze the data at my disposal, that is: a uniformly distributed variable. I guessed that I could feed this parameter into some kind of function to skew its value, for example I could use a function defined in the interval $(0, 1)$ with a fast ascension to $0.5$, a "plateau" and then another ascension to $1$, something like a rotated Sigmoid function: $$y=\frac{1}{1+e^{-t}}$$

Its inverse function is $y = -ln(\frac{1-x}{x})$, but its asymptotes are of no use for me. This is the final function I have come up with: $$y = -\frac{1}{c}ln\left(\frac{1-\left(\frac{x}{a} + b\right)}{\frac{x}{a} + b}\right) + 0.5$$

With values of about $a = 1.015$, $b = 0.01$ and $c = 10$ I am able to get pretty close to hitting $y=0$ at $x=0$ and $y=1$ at $x=1$:
Plot of my function
It still has some quirks, for example it drops below 0 for small values of x and does not reach $1$ even for $x = 1$, but I think that I can tweak the parameters to solve that. But my initial doubt still remains: if my variable $x$ has a value in $(0, 1)$ in uniform distribution, will $f(x)$ have a (approximately) normal distribution centered around $0.5$?

Best Answer

You can easily use the Box-Muller transform to generate the samples you want: just use two samples at a time. Letting $(U, V)$ be a pair of samples drawn from your generator, the Box-Muller transform gives you a pair of i.i.d. variables

$$ X = \sqrt{-2 \ln U} \cos (2 \pi V) \\ Y = \sqrt{-2 \ln U} \sin (2 \pi V) $$

If you want a pair $X_i, Y_i \sim \mathcal{N}(0.5, \sigma = 1)$, just take

$$ X_i = X + 0.5, Y_i = Y + 0.5 $$

Related Question