Calculates the cumulative sum of a series.
CUMSUM(series, dim, "naflag")
series |
- |
A series or array, the input series. |
||||||
dim |
- |
Optional. An integer or string, the computation dimension.
|
||||||
"naflag" |
- |
Optional. A string, the NA handling method.
|
A series or table.
cumsum({20, 15, 30, 10, 25})
returns {20, 35, 65, 75, 100}.
W1: integ(gnorm(1000, 1))
W2: cumsum(W1)
sum(W1) == W2[end]
The last point of CUMSUM is the overall sum of the input data.
W1: {{1, 2, 3},
{4, 5, 6},
{7, 8, 9}}
W2: cumsum(w1)
W3: cumsum(w1, 1)
W4: cumsum(w1, 2)
W2 == {{ 1, 2, 3},
{ 5, 7, 9},
{12, 15, 18}}
W3 == {{ 1, 2, 3},
{ 5, 7, 9},
{12, 15, 18}}
W4 == {{1, 3, 6},
{4, 9, 15},
{7, 15, 24}}
Both W2 and W3 compute the cumulative sum along the columns.
W4 computes the cumulative sum along the rows.
W1: {{1, 2, 3},
{nan, 5, 6},
{7, 8, 9}}
W2: cumsum(w1)
W3: cumsum(w1, 1)
W4: cumsum(w1, 2)
W2 == {{ 1, 2, 3},
{nan, 7, 9},
{nan, 15, 18}}
W3 == {{ 1, 2, 3},
{nan, 7, 9},
{nan, 15, 18}}
W4 == {{ 1, 3, 6},
{nan, nan, nan},
{ 7, 15, 24}}
The NaN value is included in the computations by default.
W1: {{1, 2, 3},
{nan, 5, 6},
{7, 8, 9}}
W2: cumsum(w1, "omitnan")
W3: cumsum(w1, 1, "omitnan")
W4: cumsum(w1, 2, "omitnan")
W2 == {{1, 2, 3},
{1, 7, 9},
{8, 15, 18}}
W3 == {{1, 2, 3},
{1, 7, 9},
{8, 15, 18}}
W4 == {{1, 3, 6},
{0, 5, 11},
{7, 15, 24}}
Same as above except the NaN value is omitted from the computations.
The nth value of the output series is equal to the sum of the first n points of the input series:
or by the equivalent difference equation:
CUMSUM calculates the cumulative sum of a series.
CUMSUM differs from integration in that the DELTAX information is not incorporated into the calculation.
CUMSUM is produces the same results as PARTSUM.
See CUMAVG to compute the cumulative average.
See CUMPROD to calculate the cumulative product.