Calculates the centered moving variance of a series.
MOVVAR(series, N, dof, "naflag", "edgeflag")
series |
- |
A series or array, the input series |
||||||
N |
- |
An integer, the number of points to compute the variance as the series is processed. |
||||||
dof |
- |
Optional. An integer, the degrees of freedom normalization mode.
|
||||||
"naflag" |
- |
Optional. A string, the NA handling method.
|
||||||
"edgeflag" |
- |
Optional. A string, the edge processing flag.
|
A series or table.
W1: {4, 3, 2, 1, 2, 3, 4}
W2: movvar(w1, 3)
W3: movvariance(w1, 3)
W2 == {0.5, 1, 1, 0.3333, 1, 1, 0.5}
W3 == {0, 0.5, 1, 1, 0.3333, 1, 1, 0.5, 0}
W2 computes a 3-point centered moving sample variance where the result at point N is the sample variance of points N-1, N and N+1. The computation starts at sample 2.
W3 computes a 3-point non-centered moving sample variance.
W1: {4, 3, 2, 1, 2, 3, 4}
W2: movvar(w1, 3, 1)
W3: movvariance(w1, 3, 1, 1)
W2 == {0.25, 0.6667, 0.6667, 0.2222, 0.6667, 0.6667, 0.25}
W2 == {nan, 0.25, 0.6667, 0.6667, 0.2222, 0.6667, 0.6667, 0.25, nan}
Same as above except the population variance is computed.
W1: {4, 3, 2, nan, 2, 3, 4}
W2: movvar(w1, 3)
W3: movvar(w1, 3, "omitnan")
W2 == {0.5, 1, nan, nan, nan, 1, 0.5}
W3 == {0.5, 1, 0.5, 0, 0.5, 1, 0.5}
W2 retains NaN values and returns NaN if any NaN is present in the segment.
W3 excludes all NaN values by removing them from the segment and adjusting the segment size and associated dof down.
W1: {4, 3, 2, nan, 2, 3, 4}
W2: movvar(w1, 3, 1)
W3: movvar(w1, 3, 1, "omitnan")
W2 == {0.25, 0.6667, nan, nan, nan, 0.6667, 0.25}
W3 == {0.25, 0.6667, 0.25, 0, 0.25, 0.6667, 0.25}
Same as above except the population variance is computed.
W1: {4, 3, 2, 1, 2, 3, 4}
W2: movvar(w1, 3, "discard")
W3: movvar(w1, 3, 1, "discard")
W2 == {1, 1, 0.3333, 1, 1}
W3 == {0.6667, 0.6667, 0.2222, 0.6667, 0.6667}
W2 and W3 compute a 3-point moving variance for all overlapping segments that contain exactly 3 samples. Shorter segments at the start and end edges are discarded.
W2 computes the sample variance and W3 computes population variance.
W1: {4, 3, 2, 1, 2, 3, 4}
W2: movvar(w1, 3)
W3: movvar(w1, 3, "shrink")
W2 == {0.5, 1, 1, 0.3333, 1, 1, 0.5}
W3 == {0.5, 1, 1, 0.3333, 1, 1, 0.5}
Since the default for edgeflag is "shrink", the results are identical.
MOVVAR computes the centered moving variance. For each section of length
N, the sample variance (
where the arithmetic mean is defined as:
The population variance
NaN values are included by default. Set naflag to "omitnan" to ignore NaN values.
See MOVVARIANCE to compute the non-centered moving variance.
See XMOVVAR to compute the centered moving variance using an X duration.