Creating a distribution with specific mean and variance in FORTRAN 90


by sue132
Tags: distribution, fortran, normal
sue132
sue132 is offline
#1
Feb18-13, 02:44 AM
P: 14
Hi,

I'm trying to create a normal distribution with mean 0.5 and variance 0.05. I tried it initially with MATLAB, for which I used
newdist=0.5+(randn(1,1000)*sqrt(0.05));
Could you please help me in doing this in FORTRAN 90? Would generating a sequence using RANDOM_NUMBER and using the above equation give me similar results?

Thank you.

(P.S. : The LINUX OS on my system needs to be replaced, and I'm writing some more code before I can run them on another system. It would be great to have your help in the meanwhile, so I could check everything together. Thanks again)
Phys.Org News Partner Science news on Phys.org
Cougars' diverse diet helped them survive the Pleistocene mass extinction
Cyber risks can cause disruption on scale of 2008 crisis, study says
Mantis shrimp stronger than airplanes
DrClaude
DrClaude is offline
#2
Feb18-13, 03:40 AM
Sci Advisor
PF Gold
DrClaude's Avatar
P: 1,111
You can't do it directly with random_number, which has a uniform distribution. There are different ways to produce a normal distribution from a uniform distribution, such as the Box-Muller transform.
I like Serena
I like Serena is offline
#3
Feb18-13, 01:56 PM
HW Helper
I like Serena's Avatar
P: 6,189
Hi sue132!

Here's some C source code for nrandom that generates normally distributed random numbers (based on the Box-muller transform).

The algorithm is easy to port to any computer language.
It comes from Numerical Recipes in C, for which there is also a FORTRAN version.

sue132
sue132 is offline
#4
Feb18-13, 11:19 PM
P: 14

Creating a distribution with specific mean and variance in FORTRAN 90


Thank you for the replies


Register to reply

Related Discussions
Fortran: Creating a sequence with constraints Programming & Computer Science 9
Creating FORTRAN Libraries Programming & Computer Science 0
Fortran 90 creating an array of unknown size Programming & Computer Science 3
Fortran: creating array containing characters Programming & Computer Science 1
Variance of Sampling Distribution VS Sample Variance Calculus & Beyond Homework 0