How do block event counts become running totals?
cumsum returns a prefix sum at each position, accumulating every increment seen so far.
numpy.cumsum in practice
Blocks with two, zero and three events give totals of two, two and five. Add an opening balance if collection began in the middle of the history.
import numpy as np
np.cumsum([2,0,3])Result [2, 2, 5]
中文
每个区块产生事件后,累计总量如何变化?
cumsum 把截至当前位置的全部增量相加,返回与输入序列对应的前缀和。
numpy.cumsum 算例
连续三个区块有 2、0、3 条事件,累计曲线是 2、2、5。数据若从中途采集,完整历史总量还要加起始余额。
import numpy as np
np.cumsum([2,0,3])结果 [2, 2, 5]