06 / 15 · 60–90 min
Listen to frequencies.
What does a filter preserve and what does it remove?
Check my intuition
01 · Predict
Before changing the settings.
A 6 Hz sinusoid is sampled at 8 Hz. Which positive frequency between 0 and 4 Hz has the same samples up to sign or phase?
A hint
Compare 6 Hz with 8 − 6 Hz.
02 · Experiment and compare
Put the model to the test.
Keep the useful frequency at 5 Hz. Set the cutoff below 5, between 5 and 17, and above 17 Hz. Then try interference at 59 Hz: its alias overlaps the useful signal.
64 samples over one second. Dashed: useful signal; thin: measurement; thick: low-pass output.
- Raw RMSE
- 0.50
- Filtered RMSE
- 0.07
- Aliased frequency
- 17.00 Hz
Read values as a table
| t (s) | Useful signal | Measurement | Filtered |
|---|---|---|---|
| 0.00 | 0.00 | -0.10 | -0.10 |
| 0.02 | 0.47 | 1.14 | 0.33 |
| 0.03 | 0.83 | 0.51 | 0.70 |
| 0.05 | 1.00 | 0.21 | 0.93 |
| 0.06 | 0.92 | 1.14 | 0.92 |
| 0.08 | 0.63 | 1.37 | 0.65 |
| 0.09 | 0.20 | -0.22 | 0.16 |
| 0.11 | -0.29 | -1.01 | -0.40 |
| 0.13 | -0.71 | -0.28 | -0.87 |
| 0.14 | -0.96 | -0.84 | -1.10 |
| 0.16 | -0.98 | -1.51 | -1.03 |
| 0.17 | -0.77 | -1.00 | -0.72 |
| 0.19 | -0.38 | 0.41 | -0.25 |
| 0.20 | 0.10 | 0.34 | 0.24 |
| 0.22 | 0.56 | -0.02 | 0.66 |
| 0.23 | 0.88 | 0.92 | 0.94 |
| 0.25 | 1.00 | 1.74 | 1.03 |
| 0.27 | 0.88 | 0.67 | 0.90 |
| 0.28 | 0.56 | 0.11 | 0.56 |
| 0.30 | 0.10 | 0.21 | 0.09 |
| 0.31 | -0.38 | 0.16 | -0.41 |
| 0.33 | -0.77 | -1.16 | -0.81 |
| 0.34 | -0.98 | -1.51 | -1.01 |
| 0.36 | -0.96 | -0.48 | -0.97 |
| 0.38 | -0.71 | -0.25 | -0.72 |
| 0.39 | -0.29 | -0.95 | -0.32 |
| 0.41 | 0.20 | -0.22 | 0.15 |
| 0.42 | 0.63 | 1.28 | 0.60 |
| 0.44 | 0.92 | 1.16 | 0.93 |
| 0.45 | 1.00 | 0.35 | 1.05 |
| 0.47 | 0.83 | 0.90 | 0.91 |
| 0.48 | 0.47 | 1.03 | 0.52 |
| 0.50 | 0.00 | 0.08 | -8.65E-3 |
| 0.52 | -0.47 | -1.21 | -0.52 |
| 0.53 | -0.83 | -0.70 | -0.86 |
| 0.55 | -1.00 | -0.29 | -0.95 |
| 0.56 | -0.92 | -1.14 | -0.81 |
| 0.58 | -0.63 | -1.05 | -0.50 |
| 0.59 | -0.20 | 0.29 | -0.12 |
| 0.61 | 0.29 | 0.72 | 0.26 |
| 0.63 | 0.71 | 0.09 | 0.60 |
| 0.64 | 0.96 | 0.49 | 0.83 |
| 0.66 | 0.98 | 1.41 | 0.89 |
| 0.67 | 0.77 | 1.08 | 0.74 |
| 0.69 | 0.38 | -0.26 | 0.39 |
| 0.70 | -0.10 | -0.43 | -0.10 |
| 0.72 | -0.56 | 0.26 | -0.57 |
| 0.73 | -0.88 | -0.85 | -0.91 |
| 0.75 | -1.00 | -1.64 | -1.02 |
| 0.77 | -0.88 | -1.03 | -0.89 |
| 0.78 | -0.56 | 0.17 | -0.57 |
| 0.80 | -0.10 | -0.29 | -0.15 |
| 0.81 | 0.38 | -0.29 | 0.30 |
| 0.83 | 0.77 | 0.96 | 0.68 |
| 0.84 | 0.98 | 1.46 | 0.93 |
| 0.86 | 0.96 | 0.55 | 0.97 |
| 0.88 | 0.71 | 0.29 | 0.76 |
| 0.89 | 0.29 | 0.87 | 0.35 |
| 0.91 | -0.20 | 0.29 | -0.16 |
| 0.92 | -0.63 | -1.29 | -0.62 |
| 0.94 | -0.92 | -1.22 | -0.92 |
| 0.95 | -1.00 | -0.26 | -0.98 |
| 0.97 | -0.83 | -0.68 | -0.83 |
| 0.98 | -0.47 | -1.27 | -0.51 |
Understand the calculations
03 · Connect the diagram to calculations
The numbers behind motion.
We measure 64 points over one second at 64 Hz. The discrete transform decomposes samples into complex components. The filter keeps frequencies up to the cutoff and their conjugates, then applies the inverse transform. It cannot distinguish causes with the same sampled frequencies. An ideal filter can also create ringing on other signals.
X[k] = Σₙ x[n] exp(−i 2πkn/N)
x[n] = (1/N) Σₖ X[k] exp(i 2πkn/N)
N = 64 ; f_sampling = 64 Hz ; f_Nyquist = 32 HzA few lines to reconstruct
keep = min(k, N-k) <= cutoff
filtered_spectrum[k] = spectrum[k] if keep else 0jThe notebook provides one function per laboratory, hand-calculated examples and tests. Exercises isolate components; these pages run the complete simulations.
Keep an observation
04 · Record
What changed?
Compare two settings. Record the effect, your explanation and a case where the model might fail. Saving keeps the current settings and seed, not a certification of competence.
atomsh / lab