Your Equation

Library / Signal processing and digital filters / DSP-33

Signal processing and digital filters

Comb difference-filter magnitude

Magnitude response of the difference filter y[n] = x[n] − x[n − M] with integer delay M and angular frequency ω in rad/sample.

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

The difference filter y[n] = x[n] − x[n − M] has the response 1 − e^(−iMω), whose magnitude is 2|sin(Mω/2)|. It is zero at DC and at every multiple of 2π/M, and reaches 2 halfway between. It removes a constant offset and any component that repeats every M samples.

Magnitude response of the difference filter y[n] = x[n] − x[n − M] with integer delay M and angular frequency ω in rad/sample. It has a series of nulls (including DC) and peaks of gain 2.

Calculator

Solve for
samples
164
rad/sample
03.142
  • First nonzero null, 2π/M2.094 rad/sample
  • Number of nulls from 0 to π, including DC2
  • Gain in dB3.01 dB

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 () current value 1.414
ωAngular frequencyKey driver
02
MDelay
3.22e-72
  • At 1.571 rad/sample the delay-and-subtract filter has a gain of 1.414, out of a maximum of 2.
  • Nulls fall at multiples of 2.094 rad/sample, so it removes DC and any pattern that repeats every 3 samples.
Chart data as tables

Ranked variables

VariableTypical rangeLowest resultHighest resultSwing ()Local stepChange in result
ω Angular frequency0 to 3.142 rad/sample022+10%−26.1 %
M Delay1 to 64 samples3.215e-722+1 samples−100 %

Sweep of Angular frequency

Angular frequency (rad/sample)Gain
00
0.39271.111
0.78541.848
1.1781.962
1.5711.414
1.9630.3902
2.3560.7654
2.7491.663
3.1422

Sweep one variable

Gain ()Hover, touch, or use the arrow keys on the chart
00.511.52 00.511.522.53 Angular frequency (rad/sample) now 1.414

Variables and how each one contributes

G

Gain

Result ·

What the equation gives you. Everything else feeds it.

M

Delay

samples · typical 1 to 64

The delay, in samples. A larger delay packs more nulls into the band. Raising it by 10 % (to 3.3) moves the result by +0 %, from 1.414 to 1.414.

ω

Angular frequency

rad/sample · typical 0 to 3.142

The angular frequency, in rad/sample. Moves along the response between nulls and peaks of 2. Raising it by 10 % (to 1.728) moves the result by −26.1 %, from 1.414 to 1.045.

Worked example with the values above

  1. Half-angle: Mω/2 = 3 × 1.571 / 2 = 2.3562 rad.
  2. Sine: sin(2.3562) = 0.70711.
  3. G = 2 × |0.70711| = 1.4142.

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