program p1e1 | |
implicit none | |
integer*4 :: SEED, i, NRAND | |
real*8 :: x, sum1, sum2, sigma, genrand_real2 | |
SEED = 23456 | |
NRAND = 50000 | |
call init_genrand(SEED) | |
sum1 = 0.0d0 | |
sum2 = 0.0d0 | |
do i = 1, NRAND | |
x = genrand_real2() | |
write (*, *) i, x | |
sum1 = sum1 + x | |
sum2 = sum2 + x*x | |
enddo | |
sum1 = sum1/real(NRAND) | |
sum2 = sum2/real(NRAND) | |
sigma = dsqrt(sum2 - sum1*sum1) | |
write (*, *) sum1, sigma | |
endprogram p1e1 |