GestureSynth.me

Music calculator

Moving Average Filter Calculator

Filter an editable sample sequence with a moving average. Read each complete-window output, group delay and the first frequency null.

moving average filter calculator

Moving Average Filter Calculator guide

Enter a short sequence in time order and choose a window length. Each row shows the index of the newest sample in a complete window and the arithmetic mean of that window. Spaces or commas separate signed decimal samples.

Play the instrument ↑
Default result
4 filtered samples

Calculation and units

For N taps, y[k] is the sum of x[k] through x[k − N + 1] divided by N. A length-L input gives L − N + 1 complete outputs. Symmetric coefficients give a group delay of (N − 1)/2 samples away from response zeros.

Worked examples

Select a named case in the Worked example control to load these values. You can then edit any input to compare the result.

Step and release

Input samples = 0 0 1 1 1 0 · Window length (samples) = 3 · Sample rate (Hz) = 48000.

4 filtered samples. Group delay 1 samples (0.020833 ms). First null at 16000 Hz. Complete-window means: 0.3333333, 0.6666667, 1, 0.6666667.

Read each average against its ending index. The first two positions have too few preceding samples for this window.

Linear ramp

Input samples = 1 2 3 4 5 · Window length (samples) = 3 · Sample rate (Hz) = 1000.

3 filtered samples. Group delay 1 samples (1 ms). First null at 333.33333 Hz. Complete-window means: 2, 3, 4.

A three-sample window centers the local mean on the middle value of a linear ramp.

Alternating signal

Input samples = 1 -1 1 -1 1 -1 · Window length (samples) = 2 · Sample rate (Hz) = 48000.

5 filtered samples. Group delay 0.5 samples (0.010417 ms). First null at 24000 Hz. Complete-window means: 0, 0, 0, 0, 0.

A two-sample average cancels alternating samples exactly because the input sits at the first frequency null.

Identity filter

Input samples = 1 -2 3 · Window length (samples) = 1 · Sample rate (Hz) = 48000.

3 filtered samples. Group delay 0 samples (0 ms). A one-sample window passes every input unchanged. Complete-window means: 1, -2, 3.

A single tap has zero delay and passes every sample unchanged, including its sign.

Full-record average

Input samples = 2 4 6 8 · Window length (samples) = 4 · Sample rate (Hz) = 1000.

1 filtered samples. Group delay 1.5 samples (1.5 ms). First null at 250 Hz. Complete-window means: 5.

Only one window fits. Its output is the arithmetic mean of the complete record.

Isolated impulse

Input samples = 0 0 1 0 0 0 · Window length (samples) = 3 · Sample rate (Hz) = 1000.

4 filtered samples. Group delay 1 samples (1 ms). First null at 333.33333 Hz. Complete-window means: 0.3333333, 0.3333333, 0.3333333, 0.

The one nonzero sample contributes one third to each complete window containing the impulse.

Interpreting the result

Try an impulse, a ramp and an alternating sequence. The impulse spreads across adjacent windows. On a ramp the average follows the center of the window, while alternating signs can cancel completely for an even tap count.

For a short numerical check, enter a ramp such as two, four, six and eight with two taps. The complete window means are three, five and seven. Their ending sample indices are one, two and three. If a plotting program places those three points at indices zero, one and two, the plotted curve appears one sample early relative to the right-aligned output convention. Keep the index column when transferring results to a spreadsheet or comparing with a streaming filter.

Measurement and model limits

No samples are invented before the first input or after the last. Applications using zero padding or partial windows produce different edge values. The boxcar response has sidelobes and is a poor substitute for a sharply specified stopband.

Answers before you play

Common questions

Why is my output shorter than my input?

Only full windows are reported. The first output is aligned with input index N − 1, counting from zero.

What does an even window do to delay?

It produces a half-integer group delay. A two-tap mean has a delay of half a sample.

Where does the first frequency null occur?

For N greater than one, the first positive null lies at Fs/N. A one-tap average passes its input unchanged.

Can I paste negative or fractional samples?

Yes. Up to 256 finite samples are supported, including signed decimals and scientific notation. The tool reports each complete-window mean.