# Fast Computation of Running Statistics for Time Series

Provides methods for fast computation of running sample statistics for time series. These include: (1) mean, (2) standard deviation, and (3) variance over a fixed-length window of time-series, (4) correlation, (5) covariance, and (6) Euclidean distance (L2 norm) between short-time pattern and time-series. Implemented methods utilize Convolution Theorem to compute convolutions via Fast Fourier Transform (FFT).

Package `runstats` provides methods for fast computation of running sample statistics for time series. The methods utilize Convolution Theorem to compute convolutions via Fast Fourier Transform (FFT). Implemented running statistics include:

1. mean,
2. standard deviation,
3. variance,
4. covariance,
5. correlation,
6. euclidean distance.

Package website is located here.

### Running statistics

To better explain the details of running statistics, package's function `runstats.demo(func.name)` allows to visualize how the output of each running statistics method is generated. To run the demo, use `func.name` being one of the methods' names:

1. `"RunningMean"`,
2. `"RunningSd"`,
3. `"RunningVar"`,
4. `"RunningCov"`,
5. `"RunningCor"`,
6. `"RunningL2Norm"`.

### Performance

We use `rbenchmark` to measure elapsed time of `RunningCov` execution, for different lengths of time-series `x` and fixed length of the shorter pattern `y`.

test replications elapsed relative user.self sys.self x_length pattern_length
runstats 10 0.003 1 0.003 0.000 1000 100
runstats 10 0.031 1 0.025 0.006 10000 100
runstats 10 0.385 1 0.328 0.056 100000 100
runstats 10 5.694 1 5.509 0.171 1000000 100
runstats 10 126.393 1 121.007 4.954 10000000 100
##### Compare with a conventional method

To compare `RunStats` performance with "conventional" loop-based way of computing running covariance in `R`, we use `rbenchmark` package to measure elapsed time of `RunStats::RunningCov` and running covariance implemented with `sapply` loop, for different lengths of time-series `x` and fixed length of the shorter time-series `y`.

Benchmark results

Platform information

# runstats 1.0.1

• Added a `NEWS.md` file to track changes to the package.

# Reference manual

install.packages("runstats")

1.1.0 by Marta Karas, a year ago

https://github.com/martakarass/runstats

Report a bug at https://github.com/martakarass/runstats/issues

Browse source code at https://github.com/cran/runstats

Authors: Marta Karas [aut, cre] , Jacek Urbanek [aut] , John Muschelli [ctb] , Lacey Etzkorn [ctb]

Documentation:   PDF Manual

Task views: Time Series Analysis

GPL-3 license

Imports fftwtools

Imported by arctools.

See at CRAN