Computes running sample standard deviation of a time-series x
in a fixed length window.
RunningSd(x, W, circular = FALSE)
x | A numeric vector. |
---|---|
W | A numeric scalar; length of |
circular | Logical; whether running sample standard deviation is computed assuming
circular nature of |
A numeric vector.
The length of output vector equals the length of x
vector.
Parameter circular
determines whether x
time-series is assumed to have a circular nature.
Assume \(l_x\) is the length of time-series x
, W
is a fixed length of x
time-series window.
If circular
equals TRUE
then
first element of the output time-series corresponds to sample standard deviation of x[1:W]
,
last element of the output time-series corresponds to sample standard deviation of c(x[l_x], x[1:(W - 1)])
.
If circular
equals FALSE
then
first element of the output time-series corresponds to sample standard deviation of x[1:W]
,
the \(l_x - W + 1\)-th element of the output time-series corresponds to sample standard deviation of x[(l_x - W + 1):l_x]
,
last W-1
elements of the output time-series are filled with NA
.
See runstats.demo(func.name = "RunningSd")
for a detailed presentation.
#> [1] 0.8748456 1.2293180 1.3279382 1.1891498 0.5824692 0.7579783 1.1330298 #> [8] 0.6353522 NA NARunningSd(x, 3, circular = FALSE)#> [1] 0.8748456 1.2293180 1.3279382 1.1891498 0.5824692 0.7579783 1.1330298 #> [8] 0.6353522 NA NA