DSP

Running Average

A filter that computes the mean of the most recent N samples, smoothing data by attenuating high-frequency variations.

Detailed Explanation

The running (moving) average maintains a window of N samples. Each new sample shifts the window, adding the new value and dropping the oldest. The average is the sum divided by N. When N is a power of 2, division becomes a simple bit shift.

Efficient implementation uses an accumulator: add new sample, subtract oldest (stored in a circular buffer). This requires O(1) operations per sample rather than O(N) for naive summation.