>
section 10 of 113 min read

10. Things to Try

These exercises are short and high-leverage. Do at least three.

  1. FFT a sine. Generate a 1-second 100 Hz sine at 1 kHz sample rate. FFT it. Plot magnitude. You should see one peak at 100 Hz (and its mirror near -100 Hz / 900 Hz). Now multiply two sines (100 Hz and 110 Hz) and FFT; you should see two peaks. Also try a sum.

  2. Aliasing demo. Sample a 9 Hz sine at 10 Hz. Plot. Connect the dots. You see a 1 Hz wave: the alias. Now try at 20 Hz and confirm Nyquist.

  3. FIR window method. Use scipy signal.firwin(101, 0.2, window='hamming') to design a 101-tap lowpass at 0.2π0.2\pi cutoff with Hamming window. Plot the frequency response with signal.freqz. Re-design with 'rectangular', 'blackman', 'kaiser' and overlay magnitudes; you will see the side-lobe vs. transition tradeoff plainly.

  4. IIR design. Design a 6th-order Butterworth lowpass at fc=1f_c = 1 kHz, fs=8f_s = 8 kHz: signal.butter(6, 1000/4000, output='sos'). Plot magnitude. Now do Chebyshev-I and elliptic at the same order; compare ripple, stopband attenuation, transition steepness.

  5. Overlap-save. Implement OLS in 30 lines of Python. Test it against scipy.signal.lfilter for a long random input and a 65-tap FIR. Check that they produce the same output (within rounding).

  6. Polyphase resampling. Resample a 44.1 kHz audio file to 48 kHz using signal.resample_poly. Listen for artifacts. Then try a poor-quality method (linear interpolation with numpy.interp) and listen to the difference.

  7. Build a real-time low-pass on Arduino or Pi Pico. Read the ADC at 1 kHz, run a 5-tap FIR low-pass, write to DAC. Apply a noisy DC voltage and watch the smoothing on a scope.

  8. DPA toy. Generate fake "power traces" as the Hamming weight of an AES SubBytes output plus Gaussian noise (in numpy). For 1000 random plaintexts, simulate. Then for each candidate key byte (0–255), correlate the predicted Hamming weight against the simulated trace. The right key shows the highest correlation. This is DPA in 30 lines and the bridge to Chapter 24.

  9. FFT from scratch. Write the recursive FFT from Section 2.11. Compare to numpy.fft.fft. Verify they agree.

  10. Window function spectra. Plot the magnitude spectra of rectangular, Hann, Hamming, Blackman, and Kaiser (β=8\beta = 8) windows of length 64 (zero-padded to 4096 for resolution). Notice main-lobe width and side-lobe levels.

When the above feel intuitive, you have the chapter under your belt and are ready to use DSP in the rest of the curriculum: communications (Chapter 7), control systems (Chapter 8), and especially side-channel hardware security (Chapter 24).