program randgau c c -- program to test gaussian random number generator c -- function rnd and subroutine meanst are required c -- figure 2.8 c integer out, length, i, j real x(100), mean, std, dmean, dstd c out = 6 max = 100 length = 50 dmean = 10.0 dstd = 0.5 dummy = rand(1.0) write(out, 101) do 20 i = 1, 20 do 10 j = 1, length x(j) = randg(dmean, dstd) 10 continue call meanst(x, length, mean, std) write(out, 102) mean, std 20 continue write(out, 103) 99 stop 101 format(' generation of gaussian random numbers'/, * ' mean std dev'/ * ' (10) (0.5)'/ * ' ==================') 102 format(1x, 2f10.4) 103 format(/) end function randg(mean, sigma) c c -- generate gaussian random numbers with c -- requested mean and standard deviation c -- function ran is required c integer i real sum, mean, sigma c sum = 0.0 do 10 i = 1, 12 sum = sum + rand(0.0) 10 continue randg = (sum - 6) * sigma + mean return end