

def Update(self, ts, sample):
    'Update the EMA with a new sample\n    Args:\n      ts - The timestamp, in seconds.\n      sample - The sampled value.\n    Returns:\n      The current EMA after being updated with the sample.\n    '
    if (self._time == (- 1)):
        self._time = ts
        self.value = float(sample)
    else:
        delta = (ts - self._time)
        self._time = ts
        window = (0 if (self._window == 0) else math.exp(((- float(delta)) / self._window)))
        self.value = ((sample * (1 - window)) + (self.value * window))
    return self.value

dataset/ETHPy150Open steveniemitz/scales/scales/varz.py Ema.Update/original