Calculates the cumulative average of a series.
CUMAVG(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.
cumavg({20, 15, 30, 10, 25})
returns {20, 17.5, 21.6667, 18.75, 20}.
W1: gnorm(1000, 1)
W2: gline(length(w1), deltax(w1), 1/1000, 0)
W3: W1 + W2
W4: cumavg(W3)

W3 contains the sum of 1000 random samples and a linear trend.
W4 shows the linear trend developing as more samples of the data are averaged.
W1: integ(gnorm(1000, 1))
W2: cumavg(W1)
mean(W1) == W2[end]
The last point of CUMAVG is the overall average of the input data.
W1: {{1, 2, 3},
{4, 5, 6},
{7, 8, 9}}
W2: cumavg(w1)
W3: cumavg(w1, 1)
W4: cumavg(w1, 2)
W2 == {{1.0, 2.0, 3.0},
{2.5, 3.5, 4.5},
{4.0, 5.0, 6.0}}
W3 == {{1.0, 2.0, 3.0},
{2.5, 3.5, 4.5},
{4.0, 5.0, 6.0}}
W4 == {{1.0, 1.5, 2.0},
{4.0, 4.5, 5.0},
{7.0, 7.5, 8.0}}
Both W2 and W3 compute the cumulative average along the columns.
W4 computes the cumulative average along the rows.
W1: {{1, 2, 3},
{nan, 5, 6},
{7, 8, 9}}
W2: cumavg(w1)
W3: cumavg(w1, 1)
W4: cumavg(w1, 2)
W2 == {{1.0, 2.0, 3.0},
{nan, 3.5, 4.5},
{nan, 5.0, 6.0}}
W3 == {{1.0, 2.0, 3.0},
{nan, 3.5, 4.5},
{nan, 5.0, 6.0}}
W4 == {{1.0, 1.5, 2.0},
{nan, nan, nan},
{7.0, 7.5, 8.0}}
The NaN value is included in the computations by default.
W1: {{1, 2, 3},
{nan, 5, 6},
{7, 8, 9}}
W2: cumavg(w1, "omitnan")
W3: cumavg(w1, 1, "omitnan")
W4: cumavg(w1, 2, "omitnan")
W2 == {{1.0, 2.0, 3.0},
{0.5, 3.5, 4.5},
{2.667, 5.0, 6.0}}
W3 == {{1.0, 2.0, 3.0},
{0.5, 3.5, 4.5},
{2.667, 5.0, 6.0}}
W4 == {{1.0, 1.5, 2.0},
{0.0, 2.5, 3.667},
{7.0, 7.5, 8.0}}
Same as above except the NaN value is omitted from the computations.
The nth value of the output series is equal to the mean of the first n points of the input series:
See CUMSUM to compute the cumulative sum.