Skip to content

Sum

Running sum.

Attributes

  • sum (float)

    The running sum.

Examples

from river import stats

X = [-5, -3, -1, 1, 3, 5]
mean = stats.Sum()
for x in X:
    print(mean.update(x).get())
-5.0
-8.0
-9.0
-8.0
-5.0
0.0

from river import utils

X = [1, -4, 3, -2, 2, 1]
rolling_sum = utils.Rolling(stats.Sum(), window_size=2)
for x in X:
    print(rolling_sum.update(x).get())
1.0
-3.0
-1.0
1.0
0.0
3.0

Methods

get

Return the current value of the statistic.

revert
update

Update and return the called instance.

Parameters

  • x'numbers.Number'