Fast moving average

version (2.29 KB) by Christian Kothe
A fast implementation of the moving average filter for long kernels.


Updated 19 Jan 2012

View License

In terms of behavior, this is an alternative to filter() for a moving-average kernel. The running time does not grow with filter length beyond N=500.

The code uses a variant of the cumsum-trick, although not the "garden variety" but in a way that does not run into numerical issues for long data arrays.

The function is suitable for incremental (online) processing.

Cite As

Christian Kothe (2022). Fast moving average (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2011b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Inspired: downsample_ts

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!