def test_cv_update_batch(): cv1 = ContinuousValue() cv2 = ContinuousValue() nums = [random() for i in range(10)] for n in nums: cv1.update(n) cv2.update_batch(nums) assert cv1.unbiased_mean() == cv2.unbiased_mean() assert cv1.biased_std() == cv2.biased_std()
def test_cv_unbiased_mean(): nums = [random() for i in range(10)] cv = ContinuousValue() for n in nums: cv.update(n) assert cv.unbiased_mean() - sum(nums)/len(nums) <= 1e-6