Normal distribution starting with a uniformed distribution

AI Thread Summary
The discussion focuses on generating a normal distribution of velocities from a uniformly distributed sequence between [0,1] using FNT95 with Plato. The user seeks assistance in coding a loop to populate velocity arrays VX, VY, and VZ for N=125 while ensuring the standard deviation (sigma) is defined. A suggested method involves using two independent uniform variables, U and V, to derive normally distributed variables X and Y. The formula provided allows for the generation of normally distributed values with specified mean (mu) and standard deviation (sigma), leveraging the properties of the bivariate normal distribution in polar coordinates. The user expresses appreciation for the algorithm, noting its utility for their project.
Jamil
Messages
8
Reaction score
0
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:

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! :nb)
 
Technology news on Phys.org
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:
  • Like
Likes jim mcnamara
thank you! I have seen this algorithm before, but with sigma=1. It is very useful to my proyect! Thans again! :smile:
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...

Similar threads

Replies
12
Views
2K
Replies
5
Views
2K
Replies
8
Views
4K
Replies
6
Views
2K
Replies
4
Views
2K
Replies
7
Views
4K
Replies
4
Views
3K
Replies
6
Views
2K
Replies
3
Views
2K
Back
Top