Process a noisy sensor signal
Sample a fictional noisy signal, expose aliasing, compare two filters, inspect a DFT and apply hysteresis.

Signal Sage: I want you to preserve the raw trace before judging any filtered result.
Predict the reading, then compare it with the measurement.
Python 3 in your browser (JupyterLite)
Python · no installSample a fictional noisy signal, expose aliasing, compare two filters, inspect a DFT and apply hysteresis.
Open the notebook in your browser and run each Python cell; no install or account is needed.
Three ways to run: use JupyterLite here with no install; run main.py locally from the downloadable lab folder; or open the same notebook in Google Colab.
Steps
Step 1
- Do
- Define the synthetic one-second signal and noise seed.
- You will see
- The trace states the 1 Hz signal, 9 Hz interference, 20 Hz sampling and noise bound.
- Why it matters
- A reproducible fixture makes every later transformation inspectable.

Step 1 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 2
- Do
- Sample at 20 Hz and 8 Hz and compare the strongest DFT bin.
- You will see
- The 8 Hz row reports the 9 Hz component aliasing to 1 Hz.
- Why it matters
- Sampling below twice the highest component can create a false low-frequency signal.

Step 2 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 3
- Do
- Print the beginning of the seeded raw trace.
- You will see
- Seven timestamped values are shown and the full 20-value trace is retained.
- Why it matters
- Keeping raw evidence allows filters and thresholds to be audited later.

Step 3 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 4
- Do
- Compare a moving average with an exponential filter.
- You will see
- Six rows place each raw value beside both causal filter outputs.
- Why it matters
- The filters trade finite-window smoothing against decaying memory.

Step 4 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 5
- Do
- Calculate the strongest bins with a standard-library DFT.
- You will see
- The table prints frequency-bin magnitudes and the one-hertz resolution.
- Why it matters
- Frequency evidence helps distinguish the wanted trend from interference.

Step 5 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 6
- Do
- Apply high and low hysteresis thresholds.
- You will see
- Only state transitions are printed beside their filtered values.
- Why it matters
- Separate enter and leave thresholds prevent chatter near one boundary.

Step 6 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab) Step 7
- Do
- Validate reproducibility and state the model limits.
- You will see
- The final step passes seed and raw-trace checks while naming DFT and sensor limits.
- Why it matters
- Synthetic evidence supports the algorithm, not an unmeasured physical sensor.

Step 7 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
Chapter checks
These questions refer to the chapter’s examples. Use the return links to review their answers.
What does one LSB, the least significant bit, represent for an ADC?
Return to the chapter’s knowledge checkReadings are mostly steady but occasionally show single large spikes from electrical interference. Which filter best removes the spikes while preserving the true level?
Return to the chapter’s knowledge check
Return to Signal Processing: Quantization and Filtering · Browse Labs