# Normal distribution starting with a uniformed distribution

Tags:
1. Mar 21, 2015

### Jamil

Hi comunity! I need to make a code o a normal distribution of velocities, starting whit a random secuence uniformly distributed between [0,1]. I am using FNT95, with Plato. I want to obtain a ''for'' bucle with I=1,N for the velocities.
It is importan for the distribution to have sigma defined.
The code is:

Code (Fortran):
PARAMETER (N=125)
INTEGER (SELECTED_INT_KIND(4)) I !Átomo I-ésimo
REAL, DIMENSION(1:N):: VX(N), VY(N), VZ(N)

DO 200 I=1,N
VX(I)=?¿
VY(I)=?¿
VZ(I)=?¿
ENDDO
Could anyone help me?? Thank you!!!

2. Mar 21, 2015

### wabbit

The simplest way to generate a normally distributed variable from uniform ones is probably to use two independent variables U, V, both uniformly distributed on [0,1].

If you want $X\sim \mathcal{N}(\mu_X,\sigma_X)$ ,

Set $X=\mu_X+\sigma_X \sqrt{-2 \ln(2\pi U)}\cos(2\pi V)$

You actually obtain a pair of independent normal variables this way, the second one being :

$Y=\mu_Y+\sigma_Y \sqrt{-2 \ln(2\pi U)}\sin(2\pi V)$

The reason behind this comes from looking at the bivariate normal distribution in polar coordinates.

Last edited: Mar 21, 2015
3. Mar 21, 2015

### Jamil

thank you! I have seen this algorithm before, but with sigma=1. It is very useful to my proyect!! Thans again!!!