avm99963 | 9622dc7 | 2022-04-29 15:44:05 +0200 | [diff] [blame] | 1 | program p1e1 |
2 | implicit none | ||||
3 | integer*4 :: SEED, i, NRAND | ||||
4 | real*8 :: x, sum1, sum2, sigma, genrand_real2 | ||||
5 | |||||
6 | SEED = 23456 | ||||
7 | NRAND = 50000 | ||||
8 | |||||
9 | call init_genrand(SEED) | ||||
10 | |||||
11 | sum1 = 0.0d0 | ||||
12 | sum2 = 0.0d0 | ||||
13 | |||||
14 | do i = 1, NRAND | ||||
15 | x = genrand_real2() | ||||
16 | write (*, *) i, x | ||||
17 | sum1 = sum1 + x | ||||
18 | sum2 = sum2 + x*x | ||||
19 | enddo | ||||
20 | |||||
21 | sum1 = sum1/real(NRAND) | ||||
22 | sum2 = sum2/real(NRAND) | ||||
23 | sigma = dsqrt(sum2 - sum1*sum1) | ||||
24 | |||||
25 | write (*, *) sum1, sigma | ||||
26 | endprogram p1e1 |