Digital Signal Processing
Digital signal processing transforms sampled observations into representations useful for analysis or action. Start with the sampling process, units, and question before choosing a filter or Fourier transform. A clear spectral peak is meaningful only when the acquisition and processing assumptions support the interpretation.
Keep the physical signal separate from its samples and from a plotted estimate. Different continuous signals can produce the same samples. Once that information is lost, a later software filter cannot infer which original signal actually occurred from those samples alone.
TL;DR
- Record sampling rate, units, timing, and acquisition limits.
- Address aliasing before relying on a sampled spectrum.
- Match FFT, window, and spectral scaling to the question.
- Review filter response, phase, transients, and causal availability.
- Treat time-frequency resolution as a tradeoff with explicit settings.
Quick Example
This NumPy/SciPy example samples two cosines at 100 samples per second. The 10 Hz and 90 Hz signals produce numerically matching samples under the declared construction.
Welch estimation finds a peak near 10 Hz. Applying the same digital filter to both sampled inputs should give matching outputs, which makes a good regression check. Real systems add sensors, converters, and analog anti-alias filters that this simulation leaves out.
Core Concepts
Brian McFee's Digital Signals Theory explains aliasing as distinct continuous signals producing the same sampled sequence under a fixed rate. The sampled representation alone cannot distinguish such alternatives. Aliasing chapter.
SciPy's Welch implementation estimates power spectral density by averaging modified periodograms from segments. Its sampling-rate, window, segment, overlap, and scaling parameters affect interpretation, including whether units are power per hertz or power spectrum units. SciPy Welch.
NumPy documents the discrete Fourier transform's frequency representation and normalization conventions. Transform output needs the correct frequency grid and scaling; an array index is not automatically a frequency in hertz. NumPy FFT reference.
Define the processing contract
This editorial contract organizes reproducible analysis. It is not a complete acquisition specification or evidence that a physical system meets it.
For a fictional machine signal, write the observation unit explicitly: acceleration, voltage, or another quantity. A normalized array can simplify a demonstration while hiding the calibration and dynamic range needed for real interpretation.
Protect the sampling boundary
Choose acquisition and anti-alias arrangements for the actual frequency content and hardware. A digital low-pass filter after sampling can remove parts of the sampled sequence, but it cannot distinguish two originals that produced identical samples. The example demonstrates that information limit directly.
Review timing assumptions. Uniformly spaced samples support particular transform interpretations; irregular timestamps, gaps, and clock drift can require different methods or carefully reviewed resampling. Do not replace missing samples with zeros without considering what that operation means.
Check clipping, quantization, and sensor calibration independently. An FFT can accurately transform a clipped sequence while the sequence no longer represents the physical variation you intended to measure. Numerical precision does not restore acquisition information that was never captured.
Keep sampling metadata with the data. A file of values without a reliable rate or timestamp basis cannot support an unqualified frequency claim. Preserve the source and transformation history so another analyst can reconstruct the interpretation.
Read spectra under their actual conventions
A finite observation window limits what the transform sees. Windowing, record length, and whether a sinusoid aligns with the analysis grid can change the displayed distribution of energy. Avoid interpreting every broadened peak as multiple physical sources without checking the analysis settings.
Distinguish frequency-grid spacing from the ability to resolve nearby components under the observation. Adding zero padding can make a plot smoother without supplying a longer observation of the underlying signal. State what information changed and what did not.
Check one-sided versus two-sided output and the normalization needed by the quantity being reported. Magnitude, power, and power spectral density are different representations. A label such as “amplitude” should match the actual scaling and units.
Use known synthetic signals as sanity checks. A tone with declared frequency and amplitude can reveal a mistaken rate, grid, or scaling convention. It verifies that processing path, not the physical explanation of an unknown real signal.
Evaluate filters and time-frequency methods deliberately
Choose a filter from the signal feature you want to preserve and the interference you want to reduce. Review passband and stopband behavior, transition, phase or delay, numerical implementation, and boundary handling. “Smooth” is not a sufficient specification.
Separate offline and online methods. A procedure that uses future samples can be useful for retrospective analysis but unavailable to a real-time decision. Verify the causal availability and latency required by the application before transferring an offline result into production.
Inspect startup and edge transients. A filter that behaves well in the middle of a long record may distort a short event near the boundary. Keep the padding and initialization policy explicit and test representative event locations.
For short-time analysis, choose a window and hop that fit the event duration and frequency question. A short window can localize a changing event while limiting frequency discrimination. A long window can improve some frequency detail while mixing behavior across time. Do not present both as independently precise by default.
Best Practices
Version acquisition assumptions and processing settings together. Keep raw or appropriately preserved source observations under the approved process so a changed analysis can be reviewed rather than silently replacing evidence.
Use a small reproducible signal suite with tones, combinations, transients, missingness, and boundaries relevant to the task. Record expected behavior and distinguish arithmetic checks from physical validation.
For medical, safety, or other consequential interpretation, use qualified domain review and validated acquisition and analysis procedures. This article's synthetic cosines establish no diagnosis, device safety, or real-world condition.
Common Mistakes
Bad: Apply a digital filter and assume acquisition aliasing is fixed.
Correct: Establish the sampling and pre-sampling bandwidth design, then preserve the information limits of the recorded sequence.
Bad: Label FFT bins in hertz without using the actual sample rate.
Correct: Derive and verify the frequency grid and units from the acquisition metadata.
Bad: Deploy an offline future-sample filter as if it were real-time.
Correct: Review causality, latency, initialization, and the actual online implementation.
FAQ
Does the largest spectral peak identify the physical cause?
Not by itself. Acquisition, harmonics, interference, processing, and domain context can produce alternatives. A peak is an observation to investigate.
Does zero padding create new signal information?
It changes the representation and grid of the finite data, but does not supply a longer physical observation. Keep resolution claims tied to the actual signal and method.
What does the example prove?
The two constructed signals have matching samples at the chosen rate, and the selected numerical operations behave as asserted. It does not validate hardware or infer an unknown physical frequency.
Related Topics
- Data Science and Machine Learning — Connect signal features to modeling goals.
- Time-Series Forecasting — Separate retrospective signal analysis from future prediction.
- Floating-Point and Decimal Arithmetic — Keep representation and numerical error explicit.