Signals to learning / 10. Integrate and investigate

Lesson 37 of 40 · Project · About 75 minutes

Project: a denoising pipeline

Can you reduce interference without hiding signal distortion?

You will be able to

  • Design a filtering experiment with a clean reference and aligned error metric.
  • Explain why visual smoothness alone is insufficient evidence.

Define a task before choosing a filter

Create a 3 Hz unit-amplitude signal at 64 samples/s and add a reproducible 19 Hz interference tone. Your task is to estimate the clean waveform. Compare the identity baseline with at least two causal moving-average lengths. Record filter initial state and transient policy. This deliberately simple task isolates measurement and alignment skills; it is not a general audio restoration benchmark.

Separate rejection, distortion and timing

Measure error against the clean reference, but do not silently compare a delayed output with an undelayed target. For odd symmetric tap counts, compensate the integer group delay and evaluate a declared interior interval unaffected by unavailable boundaries. Report raw as well as aligned error if latency is relevant. Then add a desired high-frequency tone to reveal a failure mode of your chosen smoother.

What counts as a good result?

A defensible report names the signal/noise models, sample rate, coefficients, padding, alignment and metric interval. It shows the noisy baseline, filtered output and clean reference. Improvement on one frequency pair is limited evidence; explicitly state what happens when desired and unwanted frequencies overlap. Do not claim general noise removal from a deterministic hum example.

MSE_aligned = mean((y[n+d]−s[n])²) on a declared valid interval; d=(M−1)/2

Worked example

A 5-tap symmetric causal average delays the nominal waveform by 2 samples. Comparing y[n+2] with s[n] removes that nominal delay, but not amplitude distortion. The code evaluates a shared interior interval for all candidates.

A common trap

Delay compensation improves comparison fairness; it does not remove real-time latency or repair amplitude response.

Predict, then experiment

Can the visually smoothest output have more clean-reference error than a shorter filter? Before touching the controls, say or write your prediction.

Try it yourself

Smoothness has a cost

What does a causal average preserve and suppress?

64 samples at 64 Hz: clean 3 Hz tone plus deterministic 19 Hz interference. Solid is observed; dashed is filtered; dotted is clean. Zero initial filter state; no delay compensation. Input SNR is a power ratio, not output quality.

Your experiment

Compare lengths 3,5,9 at interference amplitude 0.5. Predict which needs the most delay compensation, then run the reference code locally to inspect aligned MSE.

Change one parameter at a time. Compare what you observed with your prediction and record an explanation in your notes.

Check your understanding

Try from memory first. Hints and feedback are part of learning, not a penalty. These checks are for self-study, not a graded qualification.

1. For a fair clean-reference comparison, delay should be…
Give me a hint

Distinguish an evaluation shift from real processing time.

2. What is the nominal delay of a 9-tap symmetric causal FIR?

Accepted absolute tolerance: ±0.001 samples.

Give me a hint

Apply the linear-phase group-delay formula.

Reference answers (after your attempt)
  1. declared and aligned or explicitly counted in the metric — Correct: choose and disclose the metric policy.
  2. 4samples — (9−1)/2=4 samples.

Apply it: Deliver a one-page denoising report

Use paper, your notes, or a local notebook/editor. Code examples are Python 3 starting points to run yourself; this page does not execute code or automatically assess the practical task.

  1. Run baseline and tap lengths 3,5,9; record unaligned and aligned MSE over the same declared interior.
  2. Add a desired 15 Hz component and repeat. Explain the trade-off rather than selecting by appearance.
  3. Include model, coefficients, clock, boundary/alignment policy, plots or tables, and at least two limitations.
Reference code / starting point
from math import sin, pi
N, fs = 256, 64
clean = [sin(2*pi*3*n/fs) for n in range(N)]
observed = [s + 0.5*sin(2*pi*19*n/fs+0.4)
            for n, s in enumerate(clean)]
indices = range(16, N-16)
def mse(values):
    return sum(values)/len(indices)
print("baseline", mse([(observed[n]-clean[n])**2 for n in indices]))
for taps in (3, 5, 9):
    y = [sum(observed[n-k] if n-k >= 0 else 0
             for k in range(taps))/taps for n in range(N)]
    delay = (taps-1)//2
    raw = mse([(y[n]-clean[n])**2 for n in indices])
    aligned = mse([(y[n+delay]-clean[n])**2 for n in indices])
    print(taps, raw, aligned)
Reference solution & review criteria

Rubric: reproducible inputs; correct zero-state convolution; the same metric interval for every candidate; disclosed delay; clean-reference comparison; a high-frequency failure test; no claims beyond the tested model. There is no universally optimal tap count independent of the signal spectrum and metric.

Your notebook

Notes and progress stay in this browser. They are not sent to the server; ordinary web-server request logs still operate. Export a backup from the course page.

Review list

Completion requires both correct checks and your practical-task acknowledgement.

Go deeper

Sources support further study; the worked examples and questions here are original. Browser experiments are small, disclosed models—not evidence of production-model quality or hardware performance.