Calculates the moving block average of a series given a duration.
XBLOCKAVG(series, xdur, "naflag")
series |
- |
A series or table |
||||||
xdur |
- |
A real, the X duration used to compute the integer number of samples for the non-overlapping moving interval. |
||||||
"naflag" |
- |
Optional. A string, the NA handling method.
|
A series or table.
W1: {1, 2, 4, 7, 9, 11};setdeltax(1/100)
W2: blockavg(w1, 3)
W3: xblockavg(w1, 0.02)
W1 contains the input data with a sample rate of 100 Hz.
W2 computes a 3 point moving block average.
W3 computes the same moving block average except the block size is specified in terms of seconds. Since a 0.02 interval equates to 3 samples, both functions return the series {2.333, 9}.
W1: integ(gnorm(10000, 1/10000)) * 1000
W2: blockavg(w1, 51)
W3: xblockavg(w1, 0.005)
W4: W2 - W3
W1 synthesizes 10000 samples of data with a sample rate of 10kHz.
W2 computes a 51 point block average.
W3 computes a moving block average with an interval of 0.005 seconds. Since a 0.005 interval equates to 51 samples, the two block averages are identical.
W1: {1, 2, 3, 4, 5, nan, 7, 8, nan, 10, 11, 12};setdeltax(1/100)
W2: xblockavg(W1, 0.02)
W3: xblockavg(W1, 0.02, "includenan")
W2 == {2, 4.5, 7.5, 11}
W3 == {2, nan, nan, 11}
W2 ignores all NA values by removing the NaN from the segment and adjusting the segment size.
W3 includes NaNs and produces an NaN if the segment includes an NaN.
XBLOCKAVG computes a moving average with non-overlapping blocks of duration xdur.
The block duration xdur is converted to the integer block interval N with:
N = xdur / deltax(s) + 1
where xdur >= deltax(s)
NaN values are ignored by default. Set naflag to "includenan" to process NaN values.
See BLOCKAVG for an N-point moving block average.