Skip to content
Tutorials Center
My learning

Topics

Lesson 38 of 38 ยท Projects and Practice

DSP Practice Problems with Solutions

Twelve worked practice problems on IIR filters, spectral analysis, multirate processing and adaptive filters, each with a numeric check you can run and modify in Python.

The best way to own a technique is to use it on questions you have not seen. Below are twelve problems in four groups: IIR filters, spectral analysis, multirate processing and adaptive filtering. Try each one on paper or in your head first, then run the code, which computes the answer and confirms the reasoning. Change the numbers and predict the new result before you re-run.

Group 1: IIR filters

Problem 1. The filter y[n] = 0.2 x[n] + 0.8 y[n-1] is applied to a unit step. What is the final (steady-state) output, and after how many samples does the output reach 95% of it?

Problem 2. A second-order filter has denominator 1 - 1.5 z^-1 + 0.9 z^-2. Is it stable, and at what angle (frequency) do its poles sit for fs = 8 kHz?

Problem 3. What minimum order of Butterworth low-pass meets: passband edge 2 kHz, stopband edge 3 kHz, at most 1 dB loss in the passband, at least 50 dB in the stopband, with fs = 16 kHz? How does elliptic compare?

Python Solutions to problems 1 to 3

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

You can verify Problem 1 by hand: the DC gain of H(z) = 0.2 / (1 - 0.8 z^-1) at z = 1 is 0.2 / 0.2 = 1, and the step response is 1 - 0.8^(n+1). Problem 2 has radius sqrt(0.9) = 0.949, inside the unit circle, so the filter is stable; the pole angle follows from cos(theta) = 1.5 / (2 * 0.949). See IIR recursion and filter families.

Group 2: spectral analysis

Problem 4. A signal is sampled at 10 kHz and you record 2000 samples. What is the bin spacing? How long would a record need to be to separate two tones 20 Hz apart with a Hann window (resolution about 2 fs / N)?

Problem 5. A 1 kHz tone has amplitude 2 and the recording is windowed with a Hann window. What is the peak height in a normalized FFT (divided by N/2) before you correct for the window's coherent gain, and after?

Problem 6. White noise of variance 4 is sampled at 2 kHz. What is its one-sided power spectral density in V^2/Hz? Check with Welch.

Python Solutions to problems 4 to 6

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

For Problem 5 the unwindowed peak is 2; the Hann window has coherent gain 0.5, so the raw reading is 1.0 and dividing by 0.5 restores 2. For Problem 6 the total power 4 is spread uniformly over 0 to fs/2 = 1000 Hz, so the one-sided density is 4 / 1000 = 0.004 V^2/Hz. See windows and Welch.

Group 3: multirate processing

Problem 7. A signal sampled at 48 kHz contains a tone at 21 kHz. You decimate by 4 without an anti-alias filter. At which frequency does the tone appear?

Problem 8. Resample from 32 kHz to 44.1 kHz. What are the up and down factors in lowest terms?

Problem 9. A CIC decimator uses R = 32 and N = 4 stages with 12-bit input. How many bits must the registers hold to avoid overflow errors in the result? (Hint: N * log2(R) + input bits.)

Python Solutions to problems 7 to 9

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Problem 7: the new Nyquist is 6 kHz, so 21 kHz folds to |21 - 2 * 12| = 3 kHz. Problem 8 gives 441/320. Problem 9 needs 4 * 5 + 12 = 32 bits. Go back to decimation and CIC filters if any step is unclear.

Group 4: adaptive filters and applications

Problem 10. The input to an LMS filter has variance 0.5 and the filter has 8 taps. What is the upper bound on mu that the rule mu < 2 / (L sigma^2) gives? What would you choose in practice?

Problem 11. An autocorrelation pitch detector finds its strongest peak at lag 80 samples with fs = 16 kHz. What pitch is that? What is the pitch error if the true lag was 80.5?

Problem 12. A 440 Hz tone is passed through an AM modulator (1 + 0.4 m(t)) cos(2 pi 5000 t) with m(t) = cos(2 pi 440 t). Which frequencies and amplitudes appear in the spectrum?

Python Solutions to problems 10 to 12

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Problem 10 gives 2 / (8 * 0.5) = 0.5; because the bound is a rough ceiling for stability and decent noise performance, a tenth of it (0.05) is a sensible start. Problem 11: 200 Hz, and 198.8 Hz for the true lag, an error of 1.24 Hz; interpolating the autocorrelation removes it (see pitch detection). Problem 12: a carrier at 5000 Hz with amplitude 1 and sidebands at 4560 and 5440 Hz with amplitude 0.4 / 2 = 0.2.

How to keep practicing

  • Predict before you run. Write the expected number and why, then compare.
  • Break the rules. Use a window with too few samples, a notch with a low Q, a step size above the bound, and see how each failure looks.
  • Change the application. Take the ECG filter chain to a different signal, or the Goertzel detector to another set of tones.
  • Link topics. An equalizer from biquads uses the same filter math as the anti-alias filter of a decimator.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A tone at 21 kHz in a 48 kHz recording is decimated by 4 without filtering. Where does it appear?

    The new rate is 12 kHz; 21 kHz folds to |21 - 24| = 3 kHz.
  2. 2. For white noise of variance 4 sampled at 2 kHz, the one-sided PSD is

    Total power 4 spread over 0 to 1000 Hz gives 0.004 V^2/Hz.
  3. 3. Why is the Hann-windowed peak of a unit-amplitude tone about 0.5 before correction?

    The tapered window lowers the mean amplitude of the block to about half, so the peak is scaled by that coherent gain.
  4. 4. What is the best first check when an IIR filter output blows up?

    Instability comes from poles on or outside the unit circle; checking them, and switching to second-order sections, is the standard first step.

Summary

  • Practicing with verifiable numbers builds intuition faster than reading.
  • Core relations: DC gain from H(1), pole radius for stability, fs/N for bin spacing, folding for aliasing, R^N CIC gain, 2/(L sigma^2) for the LMS bound.
  • Always compute the answer in code after reasoning on paper.
  • Return to the track overview to pick the next topic to deepen.

Next: Back to the course overview- heading: "How to practice" cards: - icon: "๐Ÿ”ฎ" title: "Predict" text: "Write the answer first" - icon: "โ–ถ๏ธ" title: "Run" text: "Confirm with code" - icon: "๐Ÿ”ง" title: "Vary" text: "Change numbers and re-predict" note: "Break the rules on purpose."