A Byte of PhysicsLogo

Numerical signal processing

Numerical signal processing transforms sampled data with operations such as filtering, convolution, and spectral analysis. Every operation depends on a declared sample rate, normalization, and boundary choice. A smoother line is not automatically better data: the transform may remove physical variation, add delay, or alter values near edges.

Think like a programmer

Represent filters as pure functions over arrays with an explicit kernel and edge policy. Return a new output array; preserve raw samples and the exact configuration that produced a derived trace. Test an impulse, a constant, and a known-frequency fixture before applying any transform to a simulation result.

Model checklist

Inputs
Sample array, sample interval, kernel coefficients, edge policy, normalization, and any spectral convention.
State
Raw array, transformed array, residual, configuration, and diagnostics.
Rule
Combine neighbouring values with the kernel or project samples into bins without mutating the raw data.
Output
Filtered signal, delay/edge notes, residual, and frequency or gain diagnostics.
Check
A normalized smoother preserves a constant input; an impulse reveals the kernel; edge output changes predictably with the named policy; all output samples are finite.

For a finite kernel h, discrete convolution is

\[y[n]=sum_m h[m]x[n-m],qquad h=left[ rac13, rac13, rac13 ight]\]

The three coefficients add to one, so a constant input should remain constant under a clamp-edge implementation. An impulse input produces a shifted copy of the kernel, making the filter directly inspectable. At either end of a finite array, the expression asks for unavailable neighbours; zero, clamp, reflect, and wraparound each make a different defensible but observable choice.

Three-sample filter inspector

The source is a smooth signal plus alternating variation. Mix controls how much raw versus normalized moving-average output is displayed; clamp edges are part of the model.

Displayed filtered signal
Zero reference

Raw mix 0.5; filter kernel [1/3, 1/3, 1/3]; edge policy clamp. A constant input is preserved by this normalized kernel.

The text result states the exact kernel, edge policy, and gain check; the line is its output view.

Filtering should be part of the experimental record: raw samples, rate, units, kernel, edge policy, ordering, and output. A moving average attenuates rapidly alternating variation, but it also broadens sharp changes and can delay features depending on its implementation. Spectral analysis follows the same discipline: retain complex bins and transform conventions, then validate with constant, impulse, and known-bin fixtures.

Try this experiment

Prediction: A normalized moving average reduces the alternating component while preserving the value of a constant input; edge samples depend on the selected policy.

Set the raw mix to zero and then one, predict which changes disappear, and name the kernel. Apply the same filter to [4, 4, 4, 4] and to [0, 1, 0]. State expected output for the first cell under zero padding and clamp boundaries.

Where this model breaks

Filters introduce delay, edge effects, frequency-dependent amplitude and phase changes, and possible loss of short-lived physical features. Uneven sampling, missing data, sensor saturation, nonlinear processing, adaptive filters, and uncertainty propagation need additional models. Never interpret a filtered visualization without retaining its raw data and settings.

Summary

Treat signal processing as tested immutable array transformations with documented sampling, gain, and boundary contracts. Inspect constants and impulses before trusting a smoother, and keep raw data available to distinguish signal processing from physics.

Glossary

Self-check

  1. Which metadata must accompany a filter?
  2. What test input exposes a filter directly?
  3. Why does a normalized moving average preserve a constant?
  4. Why retain raw data?

Sources

Model contract

Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.

\[\text{observable output} = f(\text{inputs},\,\text{state})\]
Inputs
Quantities you set or measure, with units and useful bounds.
State
Values the program must retain to reproduce the next result.
Rule
The relationship or update that turns inputs and state into a result.
Check
A known limit, unit check, invariant, or measured result that can expose a bad model.

Implement the idea as a model

For Numerical Signal Processing, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Waves II — Analysis and Transformations, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.

Guided experiment

Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.

Where this model breaks

This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.

Summary

Treat Numerical Signal Processing as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.

Glossary

  • Input: a measured value or chosen parameter supplied to a model.
  • State: the smallest set of values needed to continue or reproduce a model.
  • Validation: comparing an output with a known result, limit, invariant, or measurement.

Self-check

  1. Which values are inputs, and which values must remain state?
  2. What observable result would tell you the model is behaving as expected?
  3. Which assumption would you test first before applying the model to a real system?

Model review: turn Numerical Signal Processing into a test

Build filters as tested array transformations with explicit sample-rate and edge-policy contracts.

  1. Name the inputs and units that the waves ii — analysis and transformations model needs.
  2. Separate the state you must keep from values you can calculate when needed.
  3. Write one rule that maps the current state and inputs to an observable result.
  4. Choose a limiting case, unit check, invariant, or known result before trusting an output.
  5. State one assumption you would change before using this simplified model for a real decision.

Share to: