1
0
mirror of https://github.com/TREX-CoE/qmc-lttc.git synced 2024-10-19 06:21:56 +02:00
qmc-lttc/qmc_stats.py

12 lines
293 B
Python
Raw Normal View History

2021-01-07 10:01:55 +01:00
from math import sqrt
def ave_error(arr):
M = len(arr)
2021-01-26 00:22:37 +01:00
assert(M>0)
if M == 1:
return (arr[0], 0.)
else:
average = sum(arr)/M
variance = 1./(M-1) * sum( [ (x - average)**2 for x in arr ] )
error = sqrt(variance/M)
return (average, error)