Fortran Creating a distribution with specific mean and variance in FORTRAN 90

AI Thread Summary
To create a normal distribution with a mean of 0.5 and a variance of 0.05 in FORTRAN 90, using the RANDOM_NUMBER function directly is not suitable, as it generates uniform distributions. Instead, methods like the Box-Muller transform can be employed to convert uniform random numbers into normally distributed ones. A suggested resource includes C source code for generating normally distributed random numbers, which can be adapted for FORTRAN. This approach is based on established algorithms found in "Numerical Recipes," which also offers a FORTRAN version. The discussion emphasizes the need for a proper transformation technique to achieve the desired normal distribution.
sue132
Messages
14
Reaction score
0
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:
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)
 
Technology news on Phys.org


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.
 
Hi sue132! :smile:

http://www.ohio.edu/people/just/Escalate/source/random.ccsome 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.
 


Thank you for the replies
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Replies
3
Views
4K
Replies
8
Views
3K
Replies
2
Views
21K
Replies
7
Views
6K
Replies
5
Views
10K
Replies
8
Views
4K
Replies
9
Views
3K
Back
Top