Your Equation

Library / Signal processing and digital filters / DSP-31

Signal processing and digital filters

Moving-average magnitude response

Magnitude response of an M-tap moving average with weights 1/M, normalised to one at DC, for 0 ≤ f ≤ fs/2.

Ref
DSP-31
Rev
v1
Field
Signal processing and digital filters
Result
G

An M-tap moving average with weights 1/M has the response sin(πMf/fs)/(M sin(πf/fs)), which equals sinc(Mf/fs)/sinc(f/fs) in the normalised form used here. It is one at DC, has nulls at multiples of fs/M, and has high sidelobes, so it removes noise but does not filter sharply.

Magnitude response of an M-tap moving average with weights 1/M, normalised to one at DC, for 0 ≤ f ≤ fs/2. The nulls fall at nonzero multiples of fs/M within the band, and the sidelobes are high.

Calculator

Solve for
taps
164
Hz
0500
Hz
2501,000,000
  • Gain in dB−2.277 dB
  • First null frequency, fs/M250 Hz
  • Noise variance reduction factor, 1/M0.25

What drives the result

Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.

Gain relative to DC () current value 0.7694
MNumber of tapsKey driver
3.96e-171
fFrequency
4.33e-171
fsSampling rate
0.09351
  • At 100 Hz the 4-point moving average passes 0.7694 of the signal amplitude (−2.28 dB).
  • The first null is at 250 Hz, and white noise power falls by the factor 0.25, which is the trade between noise reduction and bandwidth.
Chart data as tables

Ranked variables

VariableTypical rangeLowest resultHighest resultSwing ()Local stepChange in result
M Number of taps1 to 64 taps3.963e-1711+1 taps−15.9 %
f Frequency0 to 500 Hz4.33e-1711+10%−5.78 %
fs Sampling rate250 to 1,000,000 Hz0.093510.9065+10%+4.91 %

Sweep of Frequency

Frequency (Hz)Gain relative to DC
01
62.50.9061
1250.6533
187.50.3182
2504.33e-17
312.50.2126
3750.2706
437.50.1802
5006.123e-17

Sweep one variable

Gain relative to DC ()Hover, touch, or use the arrow keys on the chart
00.20.40.60.81 0100200300400500 Frequency (Hz) now 0.7694

Variables and how each one contributes

G

Gain relative to DC

Result ·

What the equation gives you. Everything else feeds it.

M

Number of taps

taps · typical 1 to 64

The number of taps (weights 1/M each). More taps lower the cutoff and narrow the main lobe, with nulls at fs/M. Raising it by 10 % (to 4.4) moves the result by +0 %, from 0.7694 to 0.7694.

f

Frequency

Hz · typical 0 to 500

The frequency, in Hz, up to fs/2. Higher frequencies are attenuated, with nulls at multiples of fs/M. Raising it by 10 % (to 110) moves the result by −5.78 %, from 0.7694 to 0.725.

fs

Sampling rate

Hz · typical 250 to 1,000,000

The sampling rate, in Hz. A higher rate makes a given frequency a smaller fraction of fs, so it passes better. Raising it by 10 % (to 1,100) moves the result by +4.91 %, from 0.7694 to 0.8072.

Worked example with the values above

  1. Numerator: sinc(Mf/fs) = sinc(0.4) = 0.75683.
  2. Denominator: sinc(f/fs) = sinc(0.1) = 0.98363.
  3. G = |0.75683 / 0.98363| = 0.76942.

Assumptions and limits

  • Equally spaced samples, and noise that is uncorrelated from sample to sample.
  • A signal that is smooth over the filter span, so a local quadratic fit describes it.

Common mistakes

  • Using these filters at the ends of a record, where the window is incomplete.
  • Forgetting that centred filters add a delay of half the window length in real-time use.
  • Using a moving average where the sinc sidelobes let high frequencies leak through.

Statistics and uncertainty

Smoothing reduces random error and adds bias, which cannot both be small. A Savitzky–Golay fit lowers the noise variance by the factor Σc² (here 0.49) but flattens any curvature of higher order than a quadratic.

Where it is used

  • Smoothing sensor signals and estimating velocity from position records.
  • Predicting the noise reduction and frequency response of simple FIR smoothers.

Maths you need

  • Moving average: the mean of the latest M samples
  • Least-squares fit: the polynomial that minimises squared error
  • Noise power gain: Σh² for an FIR filter

Related formulas

Practise this formula