I'm struggling to understand a line of FORTRAN code and was hoping someone on here would be able to help me out. These lines of code are meant to generate a flat distribution - I understand that GRNDM(RDUMMY,1) is using FORTRAN's random number generator creating a vector called RDUMMY with an array with length of 1, so that only one random number is generated giving a flat distribution. However I don't understand the function of the second line RND = (RDUMMY-0.5)*SIGMA+XMEAN, why would this be needed to give a flat distribution?

enter image description here


1 Answer 1


You are omitting to mention what GRNDM actually does (and that turns out to be not so obvious to find on the internet): It returns random numbers in the interval $[0,1]$, equally distributed. The formula in the second line then produces random numbers in the interval $[\mu-\frac\sigma 2,\mu+\frac\sigma 2]$.

Neither of these are of course "flat" distributions in the sense of having the same probability over the entire range of numbers. Rather, they are flat only in a certain interval (either $[0,1]$ or $[\mu-\frac\sigma 2,\mu+\frac\sigma 2]$) of the real number line.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.