1
0
mirror of https://github.com/TREX-CoE/qmc-lttc.git synced 2024-10-10 10:01:57 +02:00
qmc-lttc/qmc_stats.f90
2021-01-07 10:01:55 +01:00

16 lines
412 B
Fortran

subroutine ave_error(x,n,ave,err)
implicit none
integer, intent(in) :: n
double precision, intent(in) :: x(n)
double precision, intent(out) :: ave, err
double precision :: variance
if (n == 1) then
ave = x(1)
err = 0.d0
else
ave = sum(x(:)) / dble(n)
variance = sum( (x(:) - ave)**2 ) / dble(n-1)
err = dsqrt(variance/dble(n))
endif
end subroutine ave_error