Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Creating a distribution with specific mean and variance in FORTRAN 90

  1. Feb 18, 2013 #1
    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
    Code (Text):
    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)
     
  2. jcsd
  3. Feb 18, 2013 #2

    DrClaude

    User Avatar

    Staff: Mentor

    Re: Creating a distribution with specific mean and variance in FORTRAN

    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.
     
  4. Feb 18, 2013 #3

    I like Serena

    User Avatar
    Homework Helper

    Re: Creating a distribution with specific mean and variance in FORTRAN

    Hi sue132! :smile:

    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.
     
  5. Feb 18, 2013 #4
    Re: Creating a distribution with specific mean and variance in FORTRAN

    Thank you for the replies
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Creating a distribution with specific mean and variance in FORTRAN 90
  1. Fortran 90 (Replies: 7)

  2. Fortran 90 (Replies: 1)

  3. Fortran 90 (Replies: 1)

Loading...