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
- 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.
- 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
| Variable | Typical range | Lowest result | Highest result | Swing () | Local step | Change in result |
|---|---|---|---|---|---|---|
| ω Angular frequency | 0 to 3.142 rad/sample | 0 | 2 | 2 | +10% | −26.1 % |
| M Delay | 1 to 64 samples | 3.215e-7 | 2 | 2 | +1 samples | −100 % |
Sweep of Angular frequency
| Angular frequency (rad/sample) | Gain |
|---|---|
| 0 | 0 |
| 0.3927 | 1.111 |
| 0.7854 | 1.848 |
| 1.178 | 1.962 |
| 1.571 | 1.414 |
| 1.963 | 0.3902 |
| 2.356 | 0.7654 |
| 2.749 | 1.663 |
| 3.142 | 2 |
Sweep one variable
Variables and how each one contributes
Gain
What the equation gives you. Everything else feeds it.
Delay
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
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
- Half-angle: Mω/2 = 3 × 1.571 / 2 = 2.3562 rad.
- Sine: sin(2.3562) = 0.70711.
- 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