

def abs_summation(sequence):
    'Approximate summation of a nonnegative convergent sequence.\n\n    The sequence is assumed to converge to zero quickly without\n    oscillating -- it is truncated at the first term whose magnitude\n    relative to the partial sum is bounded by the machine epsilon.\n    '
    s = sequence.next()
    for t in sequence:
        assert (0 <= t)
        s += t
        if ((t / s) <= EPSILON):
            return s

dataset/ETHPy150Open probcomp/bayeslite/src/math_util.py abs_summation/original