mirror of
https://github.com/TREX-CoE/qmc-lttc.git
synced 2024-10-30 10:48:36 +01:00
18 lines
334 B
Python
18 lines
334 B
Python
#!/usr/bin/env python3
|
|
|
|
from math import sqrt
|
|
def ave_error(arr):
|
|
M = len(arr)
|
|
assert(M>0)
|
|
|
|
if M == 1:
|
|
average = arr[0]
|
|
error = 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)
|