AverageLearner math domain error
def f(salt):
return {0: 0.17210054184489873, 1: 0.17210054169556288}[salt]
learner = adaptive.AverageLearner(f, atol=0.01)
r = adaptive.runner.simple(learner, goal=lambda l: l.loss() < 1)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-52-5661bc7ff0a6> in <module>()
4 learner = adaptive.AverageLearner(f, atol=0.01)
5
----> 6 r = adaptive.runner.simple(learner, goal=lambda l: l.loss() < 1)
/gscratch/home/t-banijh/adaptive/adaptive/runner.py in simple(learner, goal)
441 learner as its sole argument, and return True if we should stop.
442 """
--> 443 while not goal(learner):
444 xs, _ = learner.ask(1)
445 for x in xs:
<ipython-input-52-5661bc7ff0a6> in <lambda>(l)
4 learner = adaptive.AverageLearner(f, atol=0.01)
5
----> 6 r = adaptive.runner.simple(learner, goal=lambda l: l.loss() < 1)
/gscratch/home/t-banijh/adaptive/adaptive/learner/average_learner.py in loss(self, real, n)
81 if n < 2:
82 return np.inf
---> 83 standard_error = self.std / sqrt(n)
84 return max(standard_error / self.atol,
85 standard_error / abs(self.mean) / self.rtol)
/gscratch/home/t-banijh/adaptive/adaptive/learner/average_learner.py in std(self)
72 if n < 2:
73 return np.inf
---> 74 return sqrt((self.sum_f_sq - n * self.mean**2) / (n - 1))
75
76 def loss(self, real=True, *, n=None):
ValueError: math domain error