Name
accumulate
Synopsis
u.accumulate(a,axis=0)Returns an array r with the same shape and
type code as a. Each element of
r is the accumulation of elements of
a along the given
axis with the function or operator
underlying u. For example:
print add.accumulate(range(10)) # prints: [0 1 3 6 10 15 21 28 36 45]
Since add’s underlying operator
is +, and a is sequence
0,1,2,...,9, r is
0,0+1,0+1+2,...,0+1+...+8+9. In other words,
r
[0] is
a
[0],
r
[1] is
r
[0]
+
a
[1],
r
[2] is
r
[1]
+
a
[2], and so on (i.e.,
each
r
[
i
]
is
r
[
i
-1]
+
a
[
i
]).
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access