Commit fc3b0123 authored by Yannick Roehlly's avatar Yannick Roehlly

[weighted_param] Returns NaN when weights sum to zero

parent a4631056
......@@ -430,7 +430,10 @@ def weighted_param(param, weights):
"""
mean = np.average(param, weights=weights)
std = np.sqrt(np.average((param-mean)**2, weights=weights))
try:
mean = np.average(param, weights=weights)
std = np.sqrt(np.average((param-mean)**2, weights=weights))
except ZeroDivisionError:
mean, std = np.nan, np.nan
return (mean, std)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment