Skip to content
Snippets Groups Projects
Commit 67a52713 authored by Bas Nijholt's avatar Bas Nijholt
Browse files

fix the math domain error that occured when all numbers are equal

This closes #62.
parent 197b56fe
No related branches found
No related tags found
No related merge requests found
Pipeline #12716 passed
......@@ -89,7 +89,11 @@ class AverageLearner(BaseLearner):
n = self.npoints
if n < 2:
return np.inf
return sqrt((self.sum_f_sq - n * self.mean**2) / (n - 1))
numerator = self.sum_f_sq - n * self.mean**2
if numerator < 0:
# in this case the numerator ~ -1e-15
return 0
return sqrt(numerator / (n - 1))
@cache_latest
def loss(self, real=True, *, n=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment