# RunningVar: Fast Running Variance Computation In runstats: Fast Computation of Running Statistics for Time Series

## Description

Computes running sample variance of a time-series `x` in a fixed length window.

## Usage

 `1` ```RunningVar(x, W, circular = FALSE) ```

## Arguments

 `x` A numeric vector. `W` A numeric scalar; length of `x` window over which sample variance is computed. `circular` Logical; whether running sample variance is computed assuming circular nature of `x` time-series (see Details).

## Details

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 variance of `x[1:W]`,

• last element of the output time-series corresponds to sample variance of `c(x[l_x], x[1:(W - 1)])`.

If `circular` equals `FALSE` then

• first element of the output time-series corresponds to sample variance of `x[1:W]`,

• the l_x - W + 1-th element of the output time-series corresponds to sample variance 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 = "RunningVar")` for a detailed presentation.

## Value

A numeric vector.

## Examples

 ```1 2 3``` ```x <- rnorm(10) RunningVar(x, W = 3, circular = FALSE) RunningVar(x, W = 3, circular = TRUE) ```

runstats documentation built on Jan. 11, 2020, 9:17 a.m.