Skip to content

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., your practice guide

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 install

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

Tier 2 · Web · paste-in setup · No account

Version tested: Python 3.12.7 / Pyodide 0.27.6 in JupyterLite 0.6.4; Chromium 148.0.7778.96; captureSource playwright:jupyterlite. Date: 2026-09-10.

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.

Open in your browser (new tab)

Steps

Screens captured against Python 3 in your browser (JupyterLite) Python 3.12.7 / Pyodide 0.27.6 in JupyterLite 0.6.4; Chromium 148.0.7778.96; captureSource playwright:jupyterlite on 2026-09-10; the tool may have moved on — the text steps are the contract.

  1. 1 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.
    JupyterLite step 1 showing the signal contract.
    Step 1 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  2. 2 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.
    JupyterLite step 2 showing the aliasing comparison.
    Step 2 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  3. 3 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.
    JupyterLite step 3 showing raw timestamped samples.
    Step 3 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  4. 4 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.
    JupyterLite step 4 comparing two filter outputs.
    Step 4 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  5. 5 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.
    JupyterLite step 5 showing DFT peak bins.
    Step 5 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  6. 6 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.
    JupyterLite step 6 showing hysteresis transitions.
    Step 6 · Python 3 in your browser (JupyterLite); numbered callout added to a real capture. Enlarge screenshot (new tab)
  7. 7 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.
    JupyterLite step 7 showing validation and scope.
    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.

  1. What does one LSB, the least significant bit, represent for an ADC?

    Return to the chapter’s knowledge check
  2. Readings 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

Caution

The values are fictional and the DFT uses a rectangular window. Measure the real sensor bandwidth, sample clock and ADC behavior before choosing deployment settings.

Return to Signal Processing: Quantization and Filtering · Browse Labs