31 double precision,
intent(out),
dimension(:) :: y
32 double precision rmean, variance, sigma
41 rmean = sum(y(:))/nsize
49 variance = variance + (y(i)-rmean)**2
54 variance = variance/nsize
55 sigma = sqrt(variance)
65 SUBROUTINE nor_rno(Y, mean, sigma)
73 double precision,
intent(out),
dimension(:) :: y
74 double precision mean, sigma
76 double precision lmean, lvariance, lsigma
77 double precision x(2), w
80 integer,
save :: COUNTER = 0
85 fileunit = 20 + counter
91 do i = 1, ceiling(
real(nsize/2.0))
99 w = sqrt( (-2.0 * log( w ) ) / w )
100 y(2*i-1) = x(1) * w * sigma + mean
101 if(2*i.lt.nsize) y(2*i) = x(2) * w * sigma + mean
104 lmean = sum(y(:))/nsize
119 lvariance = lvariance + (y(i)-lmean)**2
124 lvariance = lvariance/nsize
125 lsigma = sqrt(lvariance)
136 SUBROUTINE init_random_seed
144 INTEGER :: isize,idate(8)
145 INTEGER,
ALLOCATABLE :: iseed(:)
148 CALL date_and_time(values=idate)
149 CALL random_seed(size=isize)
150 ALLOCATE( iseed(isize) )
151 CALL random_seed(get=iseed)
152 iseed = iseed * (idate(8)-500)
153 CALL random_seed(put=iseed)
157 END SUBROUTINE init_random_seed
subroutine, public nor_rno(Y, mean, sigma)
subroutine, public uni_rno(Y)