DSP Bench
fs2000 Hz
N1024
Nyquist1000 Hz
Δf1.95 Hz
T0.512 s
Rig27.5 Hz shaft
Module—
Orientation · roadmap §1, §149, §150

Signal processing, from first principles to working practice

Sixty-two modules covering the whole roadmap. Every figure on this page is computed live in your browser from the controls beneath it — nothing here is a picture of a result, it is the result. Move a slider and the mathematics runs again.

How the modules are built

Each module follows the same shape: a short explanation of what the idea is and why anyone bothered inventing it, one or more interactive panels where you can break it, the formulas with every symbol defined, and a few questions to check that the idea landed rather than just the words.

Modules62grouped into 11 stages
Interactive panels58all computed live
Formula cards—symbols defined
Glossary terms—filterable

The bench at the top of the screen

Two parameters follow you everywhere: the sampling rate fs and the record length N. Nearly every quantity in digital signal processing is derived from those two numbers, and the strip at the top shows the derivations updating as you work: the Nyquist frequency fs/2, the bin spacing Δf = fs/N, and the record duration T = N/fs. Change the sampling rate in the sampling module and the FFT module inherits it.

One signal, threaded through the course

Rather than a new toy example every module, most panels analyse the same synthetic measurement: an accelerometer on a gearbox test rig. It is deliberately awkward. It contains a shaft rotation and its harmonics, a gear mesh tone with sidebands, a bearing fault that rings after each impact, mains pickup, a slow thermal drift, and broadband noise. It is the signal the roadmap's closing section asks you to be able to analyse, and by the end of these modules you will have taken it apart with every tool here.

A note on trust

Every number printed under a panel was computed by the code running in this page. Where a result should match a textbook value — window figures of merit against Harris (1978), quantisation noise against 6.02N + 1.76 dB, Savitzky–Golay coefficients against the published tables — it was checked against that value during the build. Where a method is an approximation, the panel says so.

Suggested order

The stages in the left rail run in dependency order, and the roadmap's own recommended progression is built into them. If you are short of time, the Core path button in the rail hides everything except the modules that later ones actually depend on. That leaves twenty-six modules which take you from "what is a signal" to a defensible spectral analysis with a designed filter.

Where this material comes from
  • Oppenheim & Schafer, Discrete-Time Signal Processing, 3rd ed., Pearson, 2010 — the standard graduate reference, and the source of most conventions used here
  • Lyons, Understanding Digital Signal Processing, 3rd ed., Prentice-Hall, 2010 — the best practical companion, strong on the things that trip people up
  • Smith, The Scientist and Engineer's Guide to Digital Signal Processing, 1997 — free online, and unmatched on intuition
  • Harris, "On the use of windows for harmonic analysis with the discrete Fourier transform", Proc. IEEE 66(1), 1978 — every window figure in this trainer is checked against it
  • Bendat & Piersol, Random Data: Analysis and Measurement Procedures, 4th ed., Wiley, 2010 — the authority on estimator uncertainty
  • Every module carries its own Sources list; the numerical results in each panel are computed live and were verified against the published values in these works
Foundations · roadmap §2.1 – §2.4

What a signal is

A signal is a measurable quantity that carries information about how something is behaving. The mathematics does not care whether the quantity is a voltage, a pressure, a temperature or a share price.

Formally a signal is a function: it maps an independent variable onto a value. Almost everything else in this course follows from asking two questions about that function — is the independent variable continuous or discrete, and is the value continuous or discrete?

The independent variable need not be time

Time is the usual one, written x(t). But a signal can equally be a function of space (the intensity along a line of a photograph), of two spatial coordinates (an image, I(x,y)), of frequency (a spectrum), of angle, or of sample index. Every technique here transfers: a spatial low-pass filter blurs an image for exactly the reason a temporal low-pass filter smooths a noisy measurement, and spatial aliasing produces moiré patterns for exactly the reason temporal aliasing produces a wagon wheel that turns backwards.

x(t)  continuous time   ·   x[n] = x(nTs)  discrete time
t continuous independent variable, seconds  ·  n integer sample index, dimensionless  ·  Ts sampling interval, seconds

The notation matters and is worth being pedantic about early: round brackets mean a continuous argument, square brackets mean an integer index. x(0.5) is a legitimate question; x[0.5] is not, because there is no sample at index one half. Interpolation is the process of inventing an answer to that illegitimate question, and module 45 is about how honest that invention is.

Discrete-time is not the same as digital

A discrete-time signal is sampled in time but its values may still be real numbers of unlimited precision. A digital signal is discrete in both axes: sampled in time and quantised in amplitude. The distinction is not pedantry — sampling and quantisation cause different problems, are analysed with different mathematics, and are fixed by different means. Sampling too slowly causes aliasing, which is irreversible and is treated in module 15. Quantising too coarsely adds noise, which is tolerable and is treated in module 16.

Sources
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., Prentice Hall, 1997 — chapter 1 for the definitions and notation used here
  • Lyons, Understanding Digital Signal Processing, 3rd ed., Prentice Hall, 2010 — the practical framing of discrete versus digital
Foundations · roadmap §2.5

Classifying signals

The classifications are not taxonomy for its own sake. Each one tells you which tools are legal to use, and several classic mistakes are simply the use of a tool on a signal of the wrong class.

ClassTestWhy it matters
DeterministicFuture values are exactly predictable from a ruleCan be described by a formula; averaging repeated trials converges to the signal itself
RandomDescribed only by statisticsYou must talk about power spectral density, not spectrum; module 21
Periodicx(t) = x(t + T) for some T > 0Has a Fourier series: a line spectrum at harmonics of 1/T
AperiodicNo such T existsHas a Fourier transform: a continuous spectrum
Evenx(−t) = x(t)Purely real Fourier transform
Oddx(−t) = −x(t)Purely imaginary Fourier transform
Energy0 < E < ∞, so P = 0Transients, pulses. Talk about energy, and energy spectral density
PowerE = ∞ but 0 < P < ∞Sinusoids, noise, anything that runs forever. Talk about power, and PSD
Causalx(t) = 0 for t < 0Physically realisable as a response starting at an event
Real / complexValues real, or in ℂReal signals have conjugate-symmetric spectra, so half the spectrum is redundant; module 38

Every signal splits into an even and an odd part

This decomposition is not a curiosity — it is why the Fourier transform of a real signal has a real part that comes entirely from the even content and an imaginary part that comes entirely from the odd content.

xe(t) = ½[x(t) + x(−t)]    xo(t) = ½[x(t) − x(−t)]    x(t) = xe(t) + xo(t)
xe even part  ·  xo odd part  ·  both defined for every signal, whatever its symmetry
The classification that trips people

"Periodic" is a much stronger claim than "repetitive". A sum of two sinusoids is periodic only if the ratio of their frequencies is rational. 27.5 Hz and 50 Hz give a period of 0.4 s because 11:20 is a ratio of integers. 27.5 Hz and 50√2 Hz never repeat at all, and the resulting signal has no Fourier series, only a transform. Real machinery running against mains-locked equipment is full of this.

Sources
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., 1997 — §1.2 for signal classes and the even/odd decomposition
  • Papoulis, Probability, Random Variables and Stochastic Processes, 4th ed., McGraw-Hill, 2002 — the deterministic/random boundary
Foundations · roadmap §3

Signal operations

Five operations account for most of what is ever done to a signal before it reaches a system: scale the amplitude, add signals, shift in time, scale time, and multiply signals together.

y(t) = A · x( a(t − t0) )
A amplitude scale  ·  a time scale: |a|>1 compresses, |a|<1 expands, a<0 reverses  ·  t0 shift, positive = delay

The order of operations is where mistakes happen. In x(a(t − t0)) the shift is applied to t before scaling, so the feature that was at t = 0 in the original appears at t = t0 in the result regardless of a. Written the other way, x(at − t0), the same feature appears at t0/a. The panel below applies them in the bracketed order and draws the reference feature so you can watch where it lands.

Why multiplication deserves its own module

Adding two signals puts both spectra side by side. Multiplying two signals does something far more interesting: it moves them. Multiplying by a sinusoid shifts a spectrum bodily up and down the frequency axis, which is what modulation, mixing and heterodyning all are (module 39). Multiplying by a finite-length window is what every practical FFT does whether you asked for it or not, and it convolves the true spectrum with the window's own spectrum — the origin of spectral leakage (module 18).

x(t) · cos(2πfct)   ⟷   ½X(f − fc) + ½X(f + fc)
fc carrier or local oscillator frequency, Hz  ·  X(f) spectrum of x  ·  multiplication in time ⟷ shifting in frequency
Sources
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., 1997 — §1.2.1 on transformations of the independent variable
  • Lyons, Understanding Digital Signal Processing, 3rd ed., 2010 — the practical consequences of multiplication
Foundations · roadmap §4

Elementary signals

A dozen standard signals appear again and again, both as building blocks and as test inputs. Recognising them on sight, and knowing their transforms, removes a surprising amount of work later.

The impulse, and the property that makes it useful

The continuous-time impulse δ(t) is not a function in the ordinary sense. It is defined by what it does inside an integral: it has zero width, infinite height, unit area, and it picks out the value of whatever it multiplies. That is the sifting property, and it is the single most useful identity in the subject.

∫−∞∞ x(t) δ(t − t0) dt = x(t0)      Σk x[k] δ[n − k] = x[n]
δ(t) Dirac delta, units of 1/s so that the integral is dimensionless  ·  δ[n] Kronecker delta: exactly 1 at n = 0 and 0 elsewhere, dimensionless

The discrete version is much better behaved: δ[n] is an ordinary sequence, equal to one at n = 0. The sum above says any sequence is a sum of shifted, scaled impulses — which is precisely the observation that leads to convolution in module 08.

Why sinc keeps appearing

The sinc function is the Fourier transform of a rectangular pulse, and rectangles are everywhere: a finite recording is a rectangular window on an infinite signal, a zero-order-hold DAC output is a train of rectangles, an ideal brick-wall filter is a rectangle in frequency. Every time you meet a rectangle in one domain, expect a sinc in the other — and expect its side lobes to cause trouble.

Sources
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., 1997 — §1.4 on the unit impulse and step
  • Bracewell, The Fourier Transform and Its Applications, 3rd ed., McGraw-Hill, 2000 — the definitive treatment of δ, sinc and rectangle functions
Foundations · roadmap §5

Energy, power and the numbers that describe amplitude

"How big is this signal" has at least five defensible answers, and choosing the wrong one is a common source of disagreement between two people looking at the same data.

E = ∫−∞∞ |x(t)|² dt    E = Σn=−∞∞ |x[n]|²
E signal energy. For a voltage across 1 Ω this is joules; in general it is a squared-units integral, so state the units
P = limT→∞ (1/T) ∫−T/2T/2 |x(t)|² dt    xrms = √P
P mean-square value, i.e. average power  ·  xrms root-mean-square, the amplitude of the DC signal carrying the same power

An energy signal has finite energy and therefore zero average power — every transient, impact and pulse. A power signal has infinite energy but finite average power — every sinusoid, every noise process, every steady machine vibration. No signal is both, and the classification decides whether you should be plotting an energy spectral density or a power spectral density.

Crest factor: the number that catches clipping

The ratio of peak to RMS is the single most useful diagnostic in the list. A pure sine has a crest factor of exactly √2 (3.01 dB). Gaussian noise sits around 3 to 4 depending on record length. A bearing fault, which is a train of sharp impacts sitting on top of a smooth vibration, pushes it well above that — which is why crest factor is a standard condition-monitoring feature. And a signal that has been clipped by the ADC has its crest factor squashed towards 1, which is how you detect clipping without ever looking at the raw trace.

C = xpeak / xrms    CdB = 20 log10(xpeak / xrms)
C crest factor, dimensionless  ·  sine √2 ≈ 1.414  ·  square wave 1  ·  Gaussian noise ≈ 3–5  ·  impulsive ≫ 5
Sources
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., 1997 — §1.1.2 energy and power definitions
  • Randall, Vibration-based Condition Monitoring, Wiley, 2011 — crest factor and kurtosis as fault indicators
Systems · roadmap §6

What a system does, and the six questions to ask about it

A system maps an input signal to an output signal. Six properties decide which analytical tools are available to you — and if two of them hold, an enormous amount follows for free.

x(t)  ⟶  ⎡ System ⎤  ⟶  y(t) = T{x(t)}
T{·} the operator describing the system: an amplifier, a filter, a cable, a structure, a whole measurement chain

The six properties

Linearity is two conditions at once. Additivity: the response to a sum is the sum of the responses. Homogeneity: scaling the input scales the output by the same factor. Together they give superposition, which is what lets you decompose an input into simple pieces, process them separately, and add the answers.

T{a·x₁(t) + b·x₂(t)} = a·T{x₁(t)} + b·T{x₂(t)}   for all a, b, x₁, x₂
a, b arbitrary constants, possibly complex  ·  must hold for every pair of inputs, not just the ones you tried

Time invariance means the system does not care when you apply the input: delay the input and the output is delayed by the same amount, otherwise unchanged. A filter with fixed coefficients is time invariant; an adaptive filter, by design, is not. Causality means the output at any instant depends only on present and past inputs — mandatory for anything running in real time, optional for offline processing (module 48). BIBO stability means every bounded input produces a bounded output. Memory: a memoryless system's output depends only on the input at the same instant; anything with memory holds state. Invertibility: distinct inputs give distinct outputs, so the input can in principle be recovered.

The trap in testing linearity

Trying one or two inputs proves nothing. y = x + 1 passes the additivity test for the specific input x = 0, and y = x² passes homogeneity for a = 1. A single counter-example disproves linearity; no finite number of successes proves it. The systematic route is to check the definition symbolically — or, in practice, to check whether the operation involves anything other than sums of scaled, delayed copies of the input and output.

Sources
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., 1997 — §1.6 system properties with worked counter-examples
  • Proakis & Manolakis, Digital Signal Processing, 4th ed., Pearson, 2006 — §2.2, the discrete-time treatment
Systems · roadmap §7, §9

Linear time-invariant systems

If a system is both linear and time invariant, one measurement characterises it completely and for ever: its response to a single impulse.

The argument is three lines long and is worth following, because everything else in the course rests on it. Any input can be written as a sum of shifted, scaled impulses (module 04). Time invariance says the response to a shifted impulse is a shifted impulse response. Linearity says the response to the sum is the sum of the responses. Therefore:

y[n] = Σk x[k]·h[n − k]    y(t) = ∫ x(τ)·h(t − τ) dτ
h[n], h(t) impulse response — the output when the input is a single unit impulse  ·  k, τ dummy variables summed or integrated over

That is convolution, and module 08 is devoted to it. The point here is what it means: h completely determines the system. Measure it once and you can predict the response to any input whatsoever, without ever knowing what is inside the box.

Three faces of the same information

The impulse response, the step response and the frequency response are three views of one object. The step response is the running integral of the impulse response (because the step is the running integral of the impulse, and the system is linear). The frequency response is the Fourier transform of the impulse response. Measuring whichever is most convenient gives you the other two.

Why sinusoids, and not some other family

Feed a complex exponential into an LTI system and the output is the same complex exponential, scaled by a complex constant. The frequency is untouched. No other family of signals has this property for all LTI systems — sinusoids are the eigenfunctions of LTI systems, and the complex constant is the eigenvalue.

x(t) = ej2πft  ⟶  y(t) = H(f)·ej2πft  where  H(f) = ∫ h(τ)e−j2πfτdτ
H(f) frequency response, complex: |H(f)| is the gain at that frequency, ∠H(f) the phase shift  ·  the input frequency appears unchanged in the output

This is the entire justification for frequency-domain thinking. An LTI system cannot create a frequency that was not in its input — it can only change the amplitude and phase of what was already there. If you see a new frequency at the output of a supposedly linear system, the system is not linear, and that observation is a standard diagnostic (module 44 on harmonic distortion).

Sources
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., 1997 — chapter 2, the derivation of convolution from LTI properties; §3.2 on eigenfunctions
  • Lyons, Understanding Digital Signal Processing, 3rd ed., 2010 — impulse, step and frequency response as practical measurements
Systems · roadmap §8

Convolution

Flip one signal, slide it across the other, and at every position multiply and add. That is the whole operation — and it is what every linear filter physically does.

y[n] = Σk=−∞∞ x[k]·h[n − k]   ≡   x[n] * h[n]
* convolution operator (not multiplication)  ·  h[n−k] the impulse response reversed in k and shifted by n  ·  output length = len(x) + len(h) − 1

Doing it graphically

The four steps never change: reflect h about the origin, shift it to position n, multiply point by point with x, and sum the products. The slider below moves n; the shaded area is the product being summed, and its total is the single output value plotted at that n. Work through it once by hand and you will never need to again.

The properties, and why they are useful

PropertyStatementWhat it buys you
Commutativex * h = h * xEither signal may be the one you flip — flip the shorter one
Associative(x * h₁) * h₂ = x * (h₁ * h₂)A cascade of filters is one filter, whose impulse response is the convolution of the parts
Distributivex * (h₁ + h₂) = x*h₁ + x*h₂Parallel paths add; a filter bank can be analysed branch by branch
Identityx * δ = xThe impulse is the "do nothing" system
Shiftx * δ[n−d] = x[n−d]A pure delay is convolution with a shifted impulse

The result that changes how you work

x(t) * h(t)   ⟷   X(f) · H(f)
Convolution in one domain is multiplication in the other. This is the convolution theorem, and it works both ways: multiplying in time convolves in frequency

Filtering is therefore a choice of viewpoint. In the time domain the filter slides a kernel along the data; in the frequency domain it multiplies the spectrum by a gain curve. They are the same operation. The practical consequence is computational: convolving two long signals directly costs order N·M operations, while transforming, multiplying and transforming back costs order N log N. Module 51 covers where the crossover sits and how overlap-add handles continuous streams.

Sources
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., 1997 — §2.1–2.3, graphical convolution and its properties
  • Smith, The Scientist and Engineer's Guide to Digital Signal Processing, California Technical Publishing, 1997 — chapters 6–7, the clearest visual treatment available
Frequency · roadmap §10

Frequency-domain thinking

The same signal, described two ways. Neither description is more true than the other, but for any given question one of them is usually much easier.

The time domain answers questions about when: when did the impact occur, how long did the transient last, what is the peak value. The frequency domain answers questions about what: what is rotating, at what rate, and which resonance is being excited. A signal that looks like meaningless hash in time can be three clean lines in frequency, and a spectrum that looks featureless can hide an obvious event in time.

The vocabulary

TermMeaning
DC componentThe zero-frequency term: the mean value of the signal
FundamentalThe lowest frequency of a periodic signal; its reciprocal is the period
HarmonicsInteger multiples of the fundamental. Produced by any periodic non-sinusoidal shape, and by non-linearity
Spectral magnitudeHow much of each frequency is present
Spectral phaseThe relative timing of each frequency. Discard it and you can no longer reconstruct the signal
BandwidthThe width of the frequency range that carries the signal, by some stated definition (−3 dB, −20 dB, 99 % power)
Frequency resolutionThe smallest separation of two tones you can still tell apart: Δf = 1/T, set by record duration
Phase is not optional

It is tempting to look only at magnitude spectra, because that is what most instruments display. But magnitude alone does not determine a signal: two records with identical magnitude spectra and different phase can look completely different in time — one a clean impulse, the other a diffuse rumble of the same total energy. Phase carries the timing, and therefore the shape. Module 34 on group delay and module 60 on phase unwrapping treat it properly.

Sources
  • Smith, The Scientist and Engineer's Guide to DSP, 1997 — chapters 8–10 on interpreting spectra
  • Bracewell, The Fourier Transform and Its Applications, 3rd ed., 2000 — the duality of the two descriptions
Frequency · roadmap §11

Fourier series

Any reasonable periodic signal is a sum of sinusoids at integer multiples of its fundamental frequency. The coefficients tell you how much of each.

x(t) = a0 + Σn=1∞ [ ancos(2πnf0t) + bnsin(2πnf0t) ]
f0 fundamental frequency = 1/T₀, Hz  ·  a0 mean (DC) value  ·  an, bn cosine and sine coefficients of the nth harmonic
x(t) = Σn=−∞∞ cnej2πnf₀t    cn = (1/T₀)∫T₀ x(t)e−j2πnf₀tdt
cn complex Fourier coefficient: |cn| is the magnitude spectrum, ∠cn the phase spectrum  ·  c−n = cn* for real signals

The complex form is not a different theory, it is the same theory written more compactly — one complex coefficient per harmonic instead of two real ones, and negative frequencies carrying the conjugate half. Every result later in the course is stated in the complex form, so it is worth becoming comfortable with it now.

Building waveforms from harmonics

The classic three shapes each have a characteristic harmonic signature, and recognising them in a real spectrum is a genuinely useful skill: odd harmonics only with 1/n amplitudes means a square wave somewhere in the chain; odd harmonics with 1/n² means a triangle; all harmonics with 1/n means a sawtooth.

Gibbs phenomenon

Add more harmonics to a square wave and the approximation improves everywhere except at the discontinuity, where an overshoot of about 9 % of the step height stubbornly refuses to shrink. It gets narrower as harmonics are added but never shorter. This is not a numerical artefact — it is what a truncated series does at a jump, and it is the same effect that produces ringing at the edges of a sharply filtered signal, and overshoot around impulsive events in filtered data.

Sources
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., 1997 — chapter 3, including the convergence conditions and Gibbs
  • Bracewell, The Fourier Transform and Its Applications, 3rd ed., 2000 — series as a special case of the transform
Frequency · roadmap §12

The continuous Fourier transform

Let the period of a Fourier series go to infinity and the discrete harmonics merge into a continuum. The result applies to any signal, periodic or not.

X(f) = ∫−∞∞ x(t)e−j2πftdt    x(t) = ∫−∞∞ X(f)e+j2πftdf
X(f) complex spectrum, units of (signal units)·s = (signal units)/Hz  ·  note the sign of the exponent flips between forward and inverse, and there is no 1/2π when the transform is written in f rather than ω

The pairs worth memorising

Six transform pairs cover most of what you will meet. The panel lets you vary the width of each and watch the other side respond — always in the opposite direction, which is the reciprocal spreading principle: narrow in time is wide in frequency.

The properties, and what each one is used for

PropertyStatementUsed for
Linearityax₁+bx₂ ⟷ aX₁+bX₂Decomposing complicated signals
Time shiftx(t−t₀) ⟷ X(f)e−j2πft₀A delay is a linear phase ramp — the basis of time-delay estimation, module 60
Frequency shiftx(t)ej2πfct ⟷ X(f−fc)Modulation and mixing, module 39
Time scalingx(at) ⟷ (1/|a|)X(f/a)Speeding a signal up spreads its spectrum; Doppler, module 57
Differentiationdx/dt ⟷ j2πf·X(f)Explains why differentiating amplifies high-frequency noise, module 34
Integration∫x dt ⟷ X(f)/(j2πf) + ½X(0)δ(f)Converting acceleration to velocity — and why DC offset ruins it
DualityIf x(t) ⟷ X(f), then X(t) ⟷ x(−f)Every pair gives you a second pair free
Convolutionx*h ⟷ X·HFiltering, module 08
Parseval∫|x(t)|²dt = ∫|X(f)|²dfEnergy is conserved between domains — the check that your FFT scaling is right
Sources
  • Bracewell, The Fourier Transform and Its Applications, 3rd ed., 2000 — the standard reference for pairs and properties
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., 1997 — chapter 4
Frequency · roadmap §13

The Laplace transform

Generalise the Fourier transform by letting frequency become complex. You gain the ability to describe growth and decay, and with it a clean account of stability.

X(s) = ∫0∞ x(t)e−stdt    s = σ + jω
s complex frequency, s⁻¹  ·  σ real part: growth (σ>0) or decay (σ<0) rate  ·  ω imaginary part: oscillation rate, rad/s  ·  setting σ = 0 recovers the Fourier transform, provided the region of convergence includes the jω axis

That last proviso is the whole reason the Laplace transform exists. A growing exponential has no Fourier transform — the integral does not converge. It does have a Laplace transform, valid in the region of the s-plane where e−σt decays fast enough to win. The region of convergence is part of the answer, not a footnote: the same algebraic expression can describe a stable causal system or an unstable anticausal one, and only the ROC distinguishes them.

Transfer functions, poles and zeros

H(s) = Y(s)/X(s) = K · (s − z₁)(s − z₂)… / (s − p₁)(s − p₂)…
zi zeros: values of s where the response vanishes  ·  pi poles: values where it blows up  ·  K overall gain

The geometry is the intuition. To find the frequency response at some frequency ω, stand at the point s = jω on the imaginary axis and measure the distances to every pole and every zero. The gain is the product of the zero distances divided by the product of the pole distances. Move close to a pole and the gain rises — that is a resonance. Move close to a zero and it falls — that is a notch. The panel below draws those distances as you drag the poles.

Stable and causal  ⟺  every pole has Re{s} < 0
A pole in the right half plane means a mode growing as eσt. A pole exactly on the imaginary axis means an undamped oscillation that neither grows nor decays — marginally stable, and in practice unstable once real components are involved
Where you will actually meet it

Laplace is the natural language of analog filters and of control systems, and it is how analog prototypes are specified before being converted to digital by the bilinear transform (module 31). It also gives the cleanest account of what a resonance is: a lightly damped pole pair, whose distance from the imaginary axis sets the sharpness and whose height sets the resonant frequency. The digital counterpart, the z-transform in module 29, is the same picture on a different map.

Sources
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., 1997 — chapter 9, including the role of the region of convergence
  • Franklin, Powell & Emami-Naeini, Feedback Control of Dynamic Systems, 7th ed., Pearson, 2015 — pole locations and transient behaviour
Sampling · roadmap §14

Sampling theory

Sampling replaces a continuous signal with a list of numbers. The remarkable result is that under one condition, nothing is lost — the continuous signal can be reconstructed exactly.

fs > 2·fmax    Ts = 1/fs    fNyq = fs/2
fs sampling frequency, Hz  ·  fmax highest frequency present in the signal, Hz  ·  fNyq Nyquist frequency — the highest representable frequency  ·  2fmax the Nyquist rate — the minimum acceptable fs
Two terms, constantly confused

The Nyquist frequency is a property of your sampling: half the sample rate. The Nyquist rate is a property of your signal: twice its highest frequency. You sample above the Nyquist rate, and the result is a Nyquist frequency above your signal's content. Note also that the theorem's inequality is strict — sampling a 100 Hz sine at exactly 200 Hz can land every sample on a zero crossing and recover nothing.

What sampling does in the frequency domain

Sampling multiplies the signal by an impulse train. Multiplication in time is convolution in frequency, and the transform of an impulse train is another impulse train — so the spectrum is replicated at every multiple of fs. If the replicas do not overlap, a low-pass filter can isolate the original and the signal is recovered exactly. If they do overlap, the overlapping parts add together and are permanently indistinguishable. That overlap is aliasing.

The condition is about bandwidth, not about frequency

The theorem as usually stated assumes the signal occupies 0 to fmax. What actually matters is that the replicas do not overlap, and a signal occupying 90–100 MHz has a bandwidth of only 10 MHz. Such a signal can be sampled at rates far below 2×100 MHz provided the replicas land cleanly — deliberate, controlled aliasing. That is bandpass sampling, module 53.

Sources
  • Shannon, "Communication in the presence of noise", Proc. IRE 37(1), 1949 — the original statement
  • Oppenheim & Willsky, Signals and Systems, 2nd ed., 1997 — chapter 7, the impulse-train derivation used here
Sampling · roadmap §15

Aliasing

A frequency above the Nyquist limit does not disappear. It reappears somewhere else, indistinguishable from a genuine signal, and no amount of later processing can remove it.

Two sinusoids whose frequencies differ by a multiple of fs produce identical samples. Not similar — identical. The information needed to tell them apart was never recorded. This is why an anti-aliasing filter must be analog and must sit before the ADC: once the samples exist, it is too late.

falias = | f − round(f / fs) · fs |
f true input frequency, Hz  ·  falias the apparent frequency in the sampled data, always between 0 and fs/2  ·  the spectrum folds back and forth about 0 and fs/2

The roadmap's sampling experiment

Roadmap project 2 asks you to sample a 100 Hz sinusoid at 1000, 300, 210, 150 and 90 Hz and observe what happens. The table below runs it. Note 210 Hz: comfortably above the Nyquist rate of 200 Hz, and the result is correct but visually unconvincing — only 2.1 samples per cycle. Correct sampling and useful-looking sampling are different standards.

Aliasing in other independent variables

Sample space too coarsely and you get spatial aliasing: moiré patterns in a photograph of a striped shirt, jagged edges in an undersampled render, and — in sensor arrays — an ambiguity about which direction a wave arrived from, because the array elements sample the wavefront in space. Sample time too coarsely with a camera and a rotating propeller appears stationary or turns backwards. It is one phenomenon.

Prevention, in order of preference

1. Analog low-pass filter before the ADC, with its stopband starting below fs/2. This is the only real defence. 2. Sample considerably faster than you need, which relaxes the filter's transition band (module 52). 3. Know your sensor's bandwidth — a sensor that physically cannot respond above 500 Hz provides some anti-aliasing for free, but check the specification rather than assuming it.

Sources
  • Lyons, Understanding Digital Signal Processing, 3rd ed., 2010 — §2.4, the folding diagram
  • Smith, The Scientist and Engineer's Guide to DSP, 1997 — chapter 3
Sampling · roadmap §16, §99, §100

Analog-to-digital conversion

Four stages, each with its own failure mode: filter, sample, hold, quantise.

analog → anti-alias filter → sample & hold → quantiser → digital
Each stage is lossy in a different way, and diagnosing bad data means knowing which one to suspect

Quantisation

An N-bit converter has 2N levels spread across its input range. The step size and the resulting noise follow immediately:

q = Vrange / 2N    σq = q/√12    SQNRdB = 6.02N + 1.76
q quantisation step (LSB size) in volts  ·  σq RMS quantisation error, assuming it is uniformly distributed over ±q/2  ·  SQNR signal-to-quantisation-noise ratio for a full-scale sinusoid — the qualifier matters

The 6.02 dB per bit is worth internalising: each extra bit halves the step and buys 6 dB. But the 1.76 dB assumes a sine filling the whole range. A signal using only a tenth of the range loses 20 dB of that, which is why input gain staging matters as much as converter resolution. A 16-bit converter used across 5 % of its range delivers roughly the performance of a 12-bit one.

Saturation and clipping

Exceed the input range and the converter simply stops following. The flat tops that result are not a gentle distortion — they are a discontinuity in the slope, and they generate harmonics across the entire spectrum. Clipped data cannot be repaired, and analysis of it produces confident, wrong answers. Detect it by checking for repeated extreme values, or by watching the crest factor collapse (module 05).

In practice

Two habits catch most converter problems before they reach the analysis. First, record and check the fraction of samples at the extreme codes — anything above a handful in a long record means clipping. Second, plot a histogram of the raw integer codes: a healthy record fills the range smoothly, while a stuck bit, a missing code or an over-ranged input all show up immediately as structure that should not be there.

Sources
  • Kester (ed.), The Data Conversion Handbook, Analog Devices / Newnes, 2005 — the standard practical reference
  • Widrow & Kollár, Quantization Noise, Cambridge, 2008 — when the uniform-noise model holds and when it does not
Sampling · roadmap §17

Digital-to-analog conversion and reconstruction

Getting back out is not simply the reverse of getting in. The staircase a DAC produces is not the original signal, and two corrections are needed.

A practical DAC holds each sample value until the next one arrives — a zero-order hold. That staircase contains the wanted signal plus images: copies of the spectrum centred on every multiple of fs, which were always there in the sampled representation and are now radiated into the analog world unless removed. It also imposes a gentle low-pass tilt, because holding a value for Ts is convolution with a rectangle of width Ts, and that is a sinc in frequency.

HZOH(f) = Ts · sinc(f Ts) · e−jπfTs    droop at fs/2 = −3.92 dB
sinc(x) = sin(πx)/(πx)  ·  the exponential term is a constant delay of half a sample  ·  the −3.92 dB figure is a fixed consequence of the hold, independent of the converter's quality

So a complete reconstruction path needs a reconstruction filter to suppress the images, and often a sinc-compensation stage — a mild high-frequency boost — to undo the droop. Oversampling makes both jobs much easier by pushing the first image far away from the wanted band, which is why audio converters run at many times the nominal rate internally.

Sources
  • Kester (ed.), The Data Conversion Handbook, 2005 — reconstruction, images and sinc compensation
  • Lyons, Understanding Digital Signal Processing, 3rd ed., 2010 — §10 on sample-rate conversion and imaging
Digital Fourier · roadmap §18, §19, §20

The discrete Fourier transform

N samples in, N complex numbers out. Each output is the correlation of your data with one complex exponential.

X[k] = Σn=0N−1 x[n]·e−j2πkn/N    k = 0, 1, … N−1
X[k] complex value of bin k  ·  k bin index, not a frequency  ·  bin k corresponds to f = k·fs/N  ·  N transform length
Δf = fs/N = 1/T    fk = k·Δf    bins 0 … N/2 are 0 … fs/2
Δf bin spacing, Hz — equal to the reciprocal of the record duration, not of the sampling interval

Negative frequencies and the two-sided spectrum

The second half of the output, bins N/2+1 to N−1, represents negative frequencies. For real input these are the complex conjugates of the first half and carry no new information, which is why instruments show a one-sided spectrum with the amplitudes doubled. For complex input — IQ data from a radio or radar receiver — the two halves are genuinely different, and discarding one destroys the ability to tell an upward Doppler shift from a downward one (module 38).

DFT and FFT are not the same kind of thing

The DFT is a mathematical transform: a definition. The FFT is an algorithm for computing it quickly, by exploiting the symmetry of the exponentials to reduce the cost from N² to N log₂N operations. The answers are identical. For N = 4096 the saving is a factor of about 340; for N = 1048576 it is nearly 90 000, which is the difference between practical and impossible.

Getting amplitudes right

Raw FFT output is not in engineering units. To read a sinusoid's amplitude off the plot you must divide by N, double for the one-sided spectrum, and divide by the window's coherent gain. Miss any of those and you will be out by a factor of two, N, or 2.3 — module 19 covers the window correction and module 61 the full estimation procedure.

Ak = 2·|X[k]| / (N · CG)    (DC and Nyquist bins: no factor of 2)
Ak amplitude of a sinusoid at bin k, in the same units as x  ·  CG coherent gain of the window: 1 for rectangular, 0.5 for Hann, 0.2156 for flat-top
Sources
  • Cooley & Tukey, "An algorithm for the machine calculation of complex Fourier series", Math. Comp. 19, 1965
  • Lyons, Understanding Digital Signal Processing, 3rd ed., 2010 — chapters 3–4, the clearest account of DFT scaling conventions
Digital Fourier · roadmap §21

Spectral leakage

The DFT assumes your record repeats for ever. When the ends do not match, it sees a discontinuity that was never in the signal — and reports the frequencies needed to make one.

The transform of an N-sample record is exactly the transform of an infinite signal formed by joining copies of that record end to end. If the record happens to contain a whole number of cycles, the joins are seamless and the tone lands exactly in one bin. If it does not, each join is a step change, and the spectrum acquires the broadband content of a step: energy smeared across every bin.

Why you cannot simply avoid it

Integer-cycle recording works only when you know the frequency in advance and control the sample clock — order tracking on a machine with a tachometer can do it, and it is genuinely the best answer where it is available. But a real record contains many frequencies at once and cannot be integer for all of them, so leakage is the normal case and windowing is the standard mitigation. Module 20.

What leakage costs you

Two things. First, amplitude error: a tone falling between bins is split between neighbours and its peak reads low — up to 3.92 dB low with no window, which is the worst-case scalloping loss. Second, masking: the skirts of a strong component bury weak ones nearby. A −13 dB first side lobe means a component 20 dB down and a few bins away is simply invisible. Window functions trade the first problem against the second.

Sources
  • Harris, "On the use of windows for harmonic analysis with the discrete Fourier transform", Proc. IEEE 66(1), 1978 — the definitive treatment; all figures of merit in the next module follow its definitions
Digital Fourier · roadmap §22

Window functions

Taper the ends of the record to zero and the periodic extension becomes continuous. The discontinuity goes away, and with it most of the leakage — at a price.

The price is resolution. Every window widens the main lobe in exchange for lowering the side lobes, and there is no window that does both. The choice is therefore a question about your measurement: are you trying to separate two close components of similar size, or find a small one next to a large one, or measure an amplitude accurately?

The three figures of merit

CG = (1/N)Σw[n]  ·  ENBW = N·Σw²[n] / (Σw[n])²  ·  scalloping loss = |W(½ bin)| / |W(0)|
CG coherent gain: the factor by which a sinusoid's amplitude is reduced — divide by it to recover true amplitude  ·  ENBW equivalent noise bandwidth in bins: the width of the ideal rectangular filter passing the same noise power — use it to convert a spectrum to a PSD  ·  scalloping loss: worst-case amplitude error for a tone falling between bins

All three are computed live in the panel above from the actual window samples, not quoted from a table. They match the published values in Harris (1978), which is the paper every window table in every textbook derives from.

Choosing one

SituationWindowReasoning
General purpose, don't know yetHannGood compromise: −31 dB side lobes, 1.5 bin ENBW. The sensible default
Accurate amplitude of a toneFlat-topScalloping loss under 0.01 dB, so the peak reads true wherever it falls. Very poor resolution — 3.8 bin ENBW
Small signal near a large oneBlackman–Harris−92 dB side lobes stop the strong component masking the weak one
Two close tones of similar sizeRectangular or HammingNarrowest main lobe wins when resolution is the binding constraint and there is nothing weak to mask
Transient shorter than the recordRectangularThe signal already tapers to zero on its own; a window would just attenuate it and distort the shape
Adjustable trade-offKaiserOne parameter β sweeps continuously from rectangular to very low side lobes
Sources
  • Harris, "On the use of windows for harmonic analysis with the DFT", Proc. IEEE 66(1), 1978
  • Nuttall, "Some windows with very good sidelobe behavior", IEEE Trans. ASSP 29(1), 1981 — corrections and additions to Harris
Digital Fourier · roadmap §23, §130, §131

Zero padding, and what resolution actually means

Appending zeros to a record gives a smoother-looking spectrum with more points. It does not let you see anything that was not already resolvable.

Zero padding interpolates. The underlying spectrum — the transform of the windowed record — is a continuous function, and the DFT samples it at N points. Padding to 4N samples it at 4N points, revealing the shape between the original bins. That is genuinely useful: it makes peak interpolation easier, improves the readability of a plot, and reduces apparent scalloping. What it cannot do is separate two components that the record duration was too short to distinguish, because the width of the main lobe is set by the duration of the actual data and padding does not change it.

Δfdisplay = fs/NFFT    but    Δfresolution ≈ ENBW / Tdata
NFFT transform length after padding  ·  Tdata duration of the real samples, seconds  ·  the first is a display choice; the second is a physical limit

Resolution versus sampling rate

These are independent and constantly conflated. The sampling rate sets the highest frequency you can see: fs/2. The record duration sets the finest frequency difference you can resolve: roughly 1/T. Sampling ten times faster for the same number of samples gives you a wider frequency axis and worse resolution, because T has fallen by ten.

Set by fsfs/2highest visible frequency
Set by T1/Tfinest resolvable spacing
Set by NFFTfs/NFFTplot point spacing only
Set by the windowENBWwidening factor on resolution
Sources
  • Lyons, Understanding Digital Signal Processing, 3rd ed., 2010 — §3.11 on zero padding, with the same warning
  • Harris, Proc. IEEE 66(1), 1978 — resolution defined via equivalent noise bandwidth
Digital Fourier · roadmap §24

Power spectral density

For random signals the spectrum of a single record is a poor estimate — as noisy as the data itself, and it does not improve with more data. The PSD is the estimate that does.

A single periodogram has a standard deviation roughly equal to its own mean, whatever N you use. Doubling the record length gives you twice as many bins, each just as noisy. The fix is to average: split the record into segments, transform each, and average the resulting power spectra. That is Welch's method, and the variance falls in proportion to the number of segments.

Sxx(f) = |X(f)|² / (fs·Σw²[n])    units: (signal units)²/Hz
Sxx one-sided PSD  ·  the Σw² normalisation makes the result independent of the window and of N  ·  integrating Sxx over any band gives the mean-square value in that band

The defining property is that a PSD does not depend on how long you recorded or which window you used. A raw spectrum's noise floor drops as you lengthen the record, which is confusing; a PSD's noise floor stays put, and its level is a genuine property of the process. That is what makes PSDs the right currency for noise specifications, vibration standards and sensor datasheets.

The trade-off Welch forces on you

For a fixed record, more segments means less variance but shorter segments, and therefore coarser frequency resolution. Averaging 64 segments gives a smooth curve you can quote a number from; averaging 4 gives a ragged one that still resolves fine detail. Choose by asking what the estimate is for — a resonance search wants resolution, a broadband noise level wants stability. Overlapping segments by 50 % recovers some of the lost statistical efficiency for free, because the tapered ends of a windowed segment would otherwise waste that data.

Sources
  • Welch, "The use of FFT for the estimation of power spectra", IEEE Trans. Audio Electroacoust. 15(2), 1967
  • Bendat & Piersol, Random Data: Analysis and Measurement Procedures, 4th ed., Wiley, 2010 — chapter 11 on estimator variance and degrees of freedom
Digital Fourier · roadmap §25

Decibels

A logarithmic ratio. The only two things to get right are whether you are dealing with power or amplitude, and what the reference is.

L = 10 log10(P₂/P₁)    L = 20 log10(A₂/A₁)
The factor differs because power is proportional to amplitude squared, and log(A²) = 2log(A). They are the same formula, applied to quantities that differ by a square

The consequence is that a factor of two in power is +3.01 dB but a factor of two in amplitude is +6.02 dB. Mixing them up produces errors of exactly a factor of two in the answer, which is common enough to be worth a deliberate check whenever a result seems out by 3 or 6 dB.

Suffixes mean references

UnitReferenceWhere used
dBnone — a pure ratioGains, attenuations, differences between two measurements
dBm1 milliwattRF and communications power levels
dBW1 wattTransmitter power; dBW = dBm − 30
dBV1 volt RMSAudio and instrumentation voltage levels
dBu0.775 V RMSProfessional audio (historically 1 mW into 600 Ω)
dBFSconverter full scaleDigital audio and ADC levels; always ≤ 0
dB re 1 µPa1 micropascalUnderwater acoustics — a different reference from airborne sound, hence the 26 dB offset that catches people out
A dB value without a stated reference is not a measurement

"The noise floor is −90 dB" means nothing on its own. −90 dBFS, −90 dBV and −90 dB relative to the signal are three different claims. Where a plot's y-axis says only "dB", find out what the reference is before drawing conclusions from it.

Sources
  • IEC 60027-3, Letter symbols to be used in electrical technology — Part 3: Logarithmic and related quantities
  • Horowitz & Hill, The Art of Electronics, 3rd ed., Cambridge, 2015 — §1.3.2 for practical use of the suffixed units
Noise · roadmap §26

Noise

Noise is not one thing. Its colour, its distribution and its origin each tell you something different about where it came from and what will remove it.

Two independent descriptions are needed. Colour is how power is distributed across frequency. Distribution is how the amplitude values are spread. They are unrelated: white Gaussian and white uniform noise have the same spectrum and different histograms, and a signal can be Gaussian at every instant while being strongly coloured.

Colours

S(f) ∝ 1/fα    α = 0 white  ·  1 pink  ·  2 brown  ·  −2 violet
S(f) power spectral density  ·  α spectral exponent  ·  pink noise has equal power per octave, which is why it sounds balanced to the ear while white noise sounds harsh
TypeSpectrumTypical physical source
White / thermal (Johnson)flatResistor thermal agitation, amplifier input noise. Sets the floor of almost every electronic measurement
Pink (1/f), flicker−3 dB/octaveSemiconductor surface effects, drift in almost every physical process. Dominates at low frequencies
Brown (1/f²)−6 dB/octaveRandom walk — integrated white noise. Gyroscope bias drift, temperature wander
Shotflat, Poisson countsDiscrete carrier arrivals: photon detection, junction current. Variance proportional to the mean
Quantisationapproximately flatThe ADC. Deterministic in principle but usefully modelled as noise (module 15)
Interferencediscrete linesMains hum and its harmonics, switching supplies, clock feedthrough. Not random — and therefore removable
Interference is not noise, and the distinction is practical

Random noise is reduced by averaging, by narrowing bandwidth, or by longer integration — √N improvements. Mains hum at 50 Hz averages perfectly coherently and never goes away; it needs a notch filter, better grounding, or removal at source. If your "noise" sits at a specific frequency and stays there, stop averaging and start looking for the cable.

Sources
  • Johnson, "Thermal agitation of electricity in conductors", Phys. Rev. 32, 1928; Nyquist's theoretical companion paper, same volume
  • Vasilescu, Electronic Noise and Interfering Signals, Springer, 2005 — the colour taxonomy and physical origins used here
Noise · roadmap §27

Signal-to-noise ratio

A single number that decides whether a measurement is possible at all. Almost every processing technique in this trainer is, at bottom, a way of improving it.

SNR = Psignal/Pnoise    SNRdB = 10 log10(Ps/Pn) = 20 log10(As,rms/An,rms)
P mean-square (power) values  ·  the 10 and the 20 give the same answer because power is amplitude squared  ·  always state the bandwidth: SNR in a 1 Hz bin and SNR in the full band are different numbers

Three ways to buy SNR

coherent averaging: +10 log10(N) dB  ·  filtering: +10 log10(Bin/Bout) dB  ·  matched filter: +10 log10(TB) dB
N number of averaged repetitions, each triggered identically  ·  B bandwidth before and after filtering  ·  TB time–bandwidth product of the known pulse shape (module 41)

All three work the same way: the signal adds coherently while the noise adds in power. Averaging 100 triggered repetitions gives 20 dB. Narrowing a 10 kHz measurement to the 100 Hz band the signal actually occupies gives 20 dB. Both require knowing something about the signal — when it occurs, or where it lives in frequency. SNR improvement is always paid for with prior knowledge.

Processing gain has a hard limit

Coherent averaging needs the signal to be identical and identically aligned in every repetition. A timing jitter of a fraction of a period causes the signal to partly cancel too, and the gain flattens out well short of 10log₁₀N. If averaging stops improving your result, suspect trigger jitter or drift before suspecting the noise.

Sources
  • Bendat & Piersol, Random Data, 4th ed., 2010 — chapter 8 on averaging and estimator variance
  • Van Trees, Detection, Estimation and Modulation Theory, Part I, Wiley, 2001 — processing gain from the estimation-theory side
Noise · roadmap §28, §29

Random signals and stationarity

A random signal has no formula. What it has is statistics — and those only mean something if they hold still.

A stationary process has statistics that do not change with time. Weak (wide-sense) stationarity, which is what practical work relies on, requires only that the mean is constant and the autocorrelation depends on the lag rather than on absolute time. An ergodic process is one where averaging over time gives the same answer as averaging over many realisations — which matters enormously, because you almost always have one long record rather than a thousand short ones.

μx = E[x(t)]  ·  σx² = E[(x−μ)²]  ·  Rxx(τ) = E[x(t)x(t+τ)]
E[·] expectation, the ensemble average  ·  stationary in the wide sense means μ is constant and R depends only on τ  ·  ergodic means the time average over one record converges to E[·]

The distributions worth recognising

Gaussian arises whenever many small independent contributions add — the central limit theorem — which covers thermal noise and most measurement error. Uniform describes quantisation error. Rayleigh describes the magnitude of a complex Gaussian, so it is the distribution of an FFT bin's magnitude in noise, and of fading in radio. Poisson counts rare independent events. Knowing which one applies determines the correct detection threshold (module 41) and whether a large excursion is remarkable or routine.

Check stationarity before trusting any spectrum

A PSD of a non-stationary signal is an average over states that never coexisted, and can describe a condition the machine was never in. The cheap test is to split the record into blocks and compare their means, variances and spectra. If they drift, either analyse the segments separately or move to a time–frequency method (module 36).

Sources
  • Papoulis & Pillai, Probability, Random Variables and Stochastic Processes, 4th ed., McGraw-Hill, 2002
  • Bendat & Piersol, Random Data, 4th ed., 2010 — chapter 4, stationarity tests for real records
Noise · roadmap §30, §31

Correlation and autocorrelation

Slide two signals past each other and measure the overlap at every shift. It finds hidden periodicities, measures delays, and connects directly to the spectrum.

Rxy[m] = Σn x[n]·y[n+m]    Rxx[m] = Σn x[n]·x[n+m]
m lag in samples  ·  cross-correlation compares two signals; autocorrelation compares a signal with itself  ·  identical to convolution except that one signal is not reversed — which is why correlation finds matches and convolution applies systems

The autocorrelation of white noise is a single spike at zero lag: no sample tells you anything about any other. The autocorrelation of a periodic signal keeps returning to a peak at every period, even when the signal is invisible in the raw time record. That property makes it the classic tool for pulling periodicity out of noise, and it is the basis of pitch detection in speech.

Wiener–Khinchin

Sxx(f) = ℱ{Rxx(τ)}
The power spectral density and the autocorrelation are a Fourier transform pair. Two descriptions of the same information — one in lag, one in frequency

This is why a PSD can be computed either by averaging periodograms or by transforming the autocorrelation, and why a narrow spectral peak corresponds to a slowly decaying autocorrelation. It also explains the shape of coloured noise: filtering shapes the spectrum, which necessarily shapes the correlation between neighbouring samples.

Cross-correlation for time delay

If y is a delayed, scaled, noisy copy of x, the peak of Rxy sits at the delay. This is how sonar ranges, how a two-microphone array finds a direction, and how ultrasonic flow meters work. Normalising gives a coefficient between −1 and +1 that also reports how confident the match is, which matters when several peaks compete (module 60).

Sources
  • Wiener, "Generalized harmonic analysis", Acta Math. 55, 1930; Khinchin, Math. Ann. 109, 1934
  • Knapp & Carter, "The generalized correlation method for estimation of time delay", IEEE Trans. ASSP 24(4), 1976
Filters · roadmap §32, §33

Filter fundamentals

A filter is an LTI system chosen for the shape of its frequency response. Everything else — the design method, the implementation — follows from a specification written in five numbers.

fpass, fstop, Apass, Astop, and the type
fpass edge of the band to keep, Hz  ·  fstop start of the band to reject, Hz  ·  Apass permitted ripple in the passband, dB  ·  Astop required attenuation, dB  ·  the gap fstop − fpass is the transition band, and it is what costs you

These five numbers determine the required order. A narrow transition band is expensive: halving it roughly doubles the order of an IIR filter and doubles the length of an FIR one. Before designing anything, ask whether the transition band can be widened — often the signal and the interference are further apart than the first specification assumed.

The four responses

Low-pass keeps frequencies below a cutoff: anti-aliasing, smoothing, envelope extraction. High-pass removes drift and DC offsets. Band-pass isolates a band of interest, such as a single gear-mesh order or a radio channel. Band-stop or notch removes a narrow interferer, typically mains hum. A notch is a band-stop with a very high Q and requires care: too narrow and it drifts off the interference, too wide and it removes signal.

−3 dB is a convention, not a boundary

The "cutoff frequency" of a filter is usually where the response has fallen by 3 dB — 70.7 % of amplitude, half the power. Content is not removed there; it is barely touched. If you need something genuinely gone, specify the frequency at which you need 40 or 60 dB of attenuation and design to that. Chebyshev and elliptic designs use the ripple edge rather than −3 dB as their reference, so the same nominal cutoff means different things across families.

Sources
  • Oppenheim & Schafer, Discrete-Time Signal Processing, 3rd ed., Pearson, 2010 — chapter 7
  • Zumbahlen (ed.), Linear Circuit Design Handbook, Analog Devices, 2008 — practical specification of analog anti-alias filters
Filters · roadmap §34

The classical filter families

Four approximations to the impossible ideal, each sacrificing something different. Choosing between them is choosing which imperfection you can live with.

The ideal brick wall is unrealisable — it is non-causal and its impulse response extends infinitely in both directions. Every real filter approximates it, and the classical families differ in where they put the approximation error.

FamilyPassbandStopbandRoll-offPhaseUse when
Butterworthmaximally flatmonotonicslowestmoderateAmplitude accuracy in the passband matters and you can afford the order. The safe default
Chebyshev Iequal ripplemonotonicfastworseYou need steep roll-off and can tolerate a stated passband ripple
Chebyshev IIflatequal ripplefastworsePassband must stay flat but the stopband only needs to reach a level, not keep falling
Elliptic (Cauer)equal rippleequal ripplesteepestworstLowest possible order for a given specification. Standard for anti-aliasing where phase does not matter
Besselflatmonotonicslowestmaximally linearPulse shapes and timing must survive. The only family that preserves waveform shape
The trade-off in one sentence

For a fixed order, steeper amplitude roll-off is bought with more nonlinear phase and more ringing on transients. Elliptic gives the sharpest cut and the worst overshoot; Bessel gives the cleanest step response and the laziest roll-off. If your measurement is about frequency content, favour steepness; if it is about waveform shape or arrival time, favour phase linearity — or use a zero-phase FIR approach instead (module 33).

Sources
  • Parks & Burrus, Digital Filter Design, Wiley, 1987 — the approximation theory behind all five families
  • Thomson, "Delay networks having maximally flat frequency characteristics", Proc. IEE 96, 1949 — the Bessel filter
Filters · roadmap §35, §36

The z-transform, poles and zeros

The discrete-time counterpart of Laplace. It turns difference equations into algebra, and it turns a filter's behaviour into a picture you can read at a glance.

X(z) = Σn x[n]·z−n    H(z) = Y(z)/X(z) = B(z)/A(z)
z complex variable  ·  z−1 is a one-sample delay, which is the whole reason the transform is useful  ·  H(z) transfer function  ·  roots of B are zeros, roots of A are poles

Evaluating H(z) on the unit circle, z = ejω, gives the frequency response — the unit circle is the frequency axis, running from DC at z = 1 round to the Nyquist frequency at z = −1. A zero near the circle pulls the response down at that angle; a pole near it pushes the response up. The whole frequency response can be read off the pole–zero diagram as a ratio of distances.

Stability

causal and stable ⟺ all poles strictly inside the unit circle, |pi| < 1
The discrete analogue of "left half plane" for continuous systems. A pole exactly on the circle oscillates for ever; outside, the output diverges

This is a hard rule with practical consequences. A high-order IIR filter implemented as a single long difference equation can have poles that are stable in exact arithmetic but drift outside the circle when the coefficients are rounded to finite precision. Factoring into second-order sections avoids it, which is why every serious implementation uses them (module 32).

Sources
  • Oppenheim & Schafer, Discrete-Time Signal Processing, 3rd ed., 2010 — chapter 3
  • Proakis & Manolakis, Digital Signal Processing, 4th ed., Pearson, 2006 — §3, region of convergence and stability
Filters · roadmap §37

FIR filters

A finite impulse response: the output is a weighted sum of the last N inputs and nothing else. Always stable, and capable of exactly linear phase.

y[n] = Σk=0N−1 bk·x[n−k]
bk the N filter coefficients, which are the impulse response  ·  no feedback, so no poles away from the origin and no possibility of instability  ·  N filter length, or "taps"

Linear phase

If the coefficients are symmetric, bk = bN−1−k, every frequency is delayed by exactly the same amount: (N−1)/2 samples. No frequency-dependent distortion of the waveform, and the delay is a known constant you can simply subtract. This is the reason FIR filters dominate anywhere waveform shape or relative timing matters — audio crossovers, radar pulse processing, biomedical signals, anything where a peak's arrival time is the measurement.

Design methods

MethodIdeaCharacter
Window methodTake the ideal (infinite, sinc) impulse response and truncate it with a windowSimple and predictable. Ripple is set by the window's side lobes; passband and stopband ripple are always equal
Frequency samplingSpecify the response at N equally spaced frequencies and inverse-transformDirect control at the sample points, uncontrolled between them. Useful for arbitrary shapes
Parks–McClellan (Remez)Minimise the maximum error by equiripple approximationOptimal: shortest filter for a given specification. Lets passband and stopband ripple be weighted differently
Least squaresMinimise total squared errorSmaller average error but larger peaks near the band edges. Good when overall energy matters more than worst case
The cost

FIR filters need far more coefficients than an IIR of equivalent sharpness — often by a factor of ten or more. A 60 dB stopband with a 1 % transition band might need 500 taps as an FIR and an eighth-order IIR. That is 500 multiplies per sample and a delay of 250 samples. Kaiser's estimate N ≈ (Astop − 8)/(2.285·Δω) gives the length before you commit.

Sources
  • Parks & McClellan, "Chebyshev approximation for nonrecursive digital filters with linear phase", IEEE Trans. Circuit Theory 19(2), 1972
  • Kaiser, "Nonrecursive digital filter design using the I₀-sinh window function", Proc. IEEE ISCAS, 1974 — the length estimate quoted above
Filters · roadmap §38

IIR filters

Feedback makes them enormously more efficient than FIR filters, and introduces every problem that FIR filters do not have.

y[n] = Σk=0M bkx[n−k] − Σk=1N aky[n−k]
The second sum is the feedback: past outputs influence the present one  ·  the impulse response never truly ends, hence "infinite"  ·  ak denominator coefficients — these create the poles, and hence the stability question

Designing by transformation

The standard route borrows a century of analog filter theory: design an analog prototype with the classical families, then map it to discrete time. The bilinear transform is the usual mapping. It substitutes s = (2/T)(z−1)/(z+1), which maps the entire left half plane inside the unit circle — so a stable analog filter always becomes a stable digital one.

ωanalog = (2/T)·tan(ωdigital/2)    pre-warp: fa = (fs/π)·tan(πfd/fs)
The mapping squeezes the infinite analog frequency axis onto the finite digital one, compressing frequencies near Nyquist — frequency warping. Pre-warping the critical frequencies before designing makes the cutoff land exactly where you asked
Three IIR-only hazards

Instability — poles can leave the unit circle, particularly with rounded coefficients at high order. Nonlinear phase — different frequencies are delayed differently, so waveform shape is not preserved and peaks move. Transients — the filter has internal state, so the first samples of the output are contaminated until the state settles, roughly 5 time constants (module 55). None of these applies to FIR.

Sources
  • Oppenheim & Schafer, Discrete-Time Signal Processing, 3rd ed., 2010 — §7.1, the bilinear transform and pre-warping
  • Rabiner & Gold, Theory and Application of Digital Signal Processing, Prentice-Hall, 1975
Filters · roadmap §39

Implementation structures and finite precision

The same transfer function can be computed in several arrangements. They are equivalent in exact arithmetic and very different in practice.

Direct form I keeps separate delay lines for input and output — more memory, but the intermediate sum has full precision. Direct form II shares one delay line and uses half the storage, at the cost of an internal node whose range can be much larger than either input or output, which is a real overflow risk. The transposed direct form II is usually the best choice in floating point: same low storage, better numerical behaviour.

Second-order sections

Any high-order filter should be factored into cascaded biquads. The reason is coefficient sensitivity: the roots of a high-degree polynomial move violently when its coefficients are perturbed slightly. A tenth-order filter written as a single difference equation can lose stability from rounding alone, while the same filter as five biquads is entirely robust, because each section's two poles depend on only two coefficients.

Fixed point

Qm.n format: 1 sign bit, m integer bits, n fractional bits    resolution 2−n, range ±2m
Every arithmetic operation must be checked against both limits: overflow at the top, and loss of small values at the bottom

Fixed-point implementation adds three distinct effects. Coefficient quantisation moves the poles and zeros, changing the response from the one you designed. Round-off noise is injected at every multiply and shaped by the remaining filter stages. Limit cycles are small self-sustaining oscillations that persist with zero input, caused by rounding in the feedback path. Scaling — deliberately attenuating at each stage to prevent overflow — trades headroom against SNR, and getting that balance right is most of the work in a fixed-point design.

Sources
  • Oppenheim & Schafer, Discrete-Time Signal Processing, 3rd ed., 2010 — chapter 6, structures and finite-precision effects
  • Jackson, "On the interaction of roundoff noise and dynamic range in digital filters", Bell Syst. Tech. J. 49, 1970
Filters · roadmap §40

Phase, group delay and zero-phase filtering

A filter's magnitude response tells you what survives. Its phase response tells you where it ends up in time — and that is often the measurement.

τg(ω) = −dφ(ω)/dω    τp(ω) = −φ(ω)/ω
φ(ω) phase response, radians  ·  τg group delay — the delay of the envelope, and the one that matters for pulses and transients  ·  τp phase delay — the delay of the individual carrier cycles

If group delay is constant, every frequency is held up by the same amount and the waveform emerges intact, merely late. If it varies, different components arrive at different times and the shape is destroyed — a sharp pulse smears out, a step acquires overshoot and ringing, and the apparent arrival time of an event becomes a function of its frequency content.

Zero-phase filtering

Offline, you can escape the problem entirely. Filter the record forwards, reverse it, filter again, and reverse back. The two passes apply the same phase distortion in opposite senses, so it cancels exactly. The magnitude response is squared, so the effective attenuation doubles in dB and the effective cutoff moves.

|Heff(ω)| = |H(ω)|²    φeff(ω) = 0    −3 dB point moves to the original −1.5 dB point
Design for half the required attenuation in dB, since you get two passes  ·  strictly non-causal: it uses future samples, so it cannot be used in real time or in a control loop
Two things zero-phase filtering does not fix

It still smears energy in time, and now symmetrically — a sharp transient acquires a precursor before it happens, which can be badly misleading when you are looking for onset times. And the record's ends are contaminated from both directions, so discard a settling length from each end rather than just the start.

Sources
  • Oppenheim & Schafer, Discrete-Time Signal Processing, 3rd ed., 2010 — §5.1, phase and group delay
  • Gustafsson, "Determining the initial states in forward–backward filtering", IEEE Trans. Sig. Proc. 44(4), 1996 — the edge-transient correction used by filtfilt
Filters · roadmap §41, §42

Smoothing, and differentiating without disaster

The moving average is the most-used and least-understood filter in engineering. And differentiation, done naively, will amplify your noise by a factor of a thousand.

The moving average is a bad low-pass filter

y[n] = (1/M)Σk=0M−1 x[n−k]    |H(f)| = |sin(πfM/fs) / (M·sin(πf/fs))|
M window length  ·  first null at fs/M  ·  first side lobe only −13.3 dB down, so it barely attenuates anything above the cutoff

It is optimal for one specific job — minimising white noise while preserving a step edge in the time domain — and it is genuinely the right choice for that. As a frequency-selective filter it is poor: the response is a sinc, with side lobes that leak badly, and a passband that already droops well before the nominal cutoff. If you want a low-pass filter, design one.

When the noise is spikes, not hiss

A single large outlier drags a moving average by (spike ÷ M) across the whole window. A median filter ignores it completely, because a median is insensitive to values that are merely extreme. Medians preserve step edges perfectly too, where a linear filter must always round them off. The cost is nonlinearity: no transfer function, no superposition, and the behaviour on real signals must be checked empirically. The Hampel filter refines this by replacing only points that lie more than a few robust standard deviations from the local median, leaving everything else untouched.

Savitzky–Golay

Fit a low-order polynomial to a sliding window by least squares and take the value of the fit at the centre. Because the fit is linear in the data, the whole operation collapses to a fixed FIR kernel — the famous [−3, 12, 17, 12, −3]/35 for a quadratic over five points. It preserves peak heights and widths far better than a moving average, which is why it dominates in spectroscopy and chromatography, and the same fit gives you smoothed derivatives for free.

Differentiation amplifies noise by ω

The gain of a differentiator rises linearly with frequency, so noise at 1 kHz is amplified a thousand times more than a 1 Hz signal. A simple difference y[n] = x[n] − x[n−1] on a noisy record produces something dominated entirely by the noise. Always band-limit first, or use a Savitzky–Golay derivative kernel, which combines the smoothing and the differentiation into one operation with a bounded gain. Integration has the opposite hazard: it has infinite gain at DC, so any offset — however small — grows without bound as a ramp.

Sources
  • Savitzky & Golay, "Smoothing and differentiation of data by simplified least squares procedures", Anal. Chem. 36(8), 1964
  • Schafer, "What is a Savitzky–Golay filter?", IEEE Sig. Proc. Mag. 28(4), 2011 — the modern DSP reading of it
Time–frequency · roadmap §43

Decimation, interpolation and resampling

Changing the sample rate is easy to do and easy to do wrong. Both directions need a filter, and each needs it on a different side of the operation.

decimate by M: filter, then discard    interpolate by L: insert zeros, then filter
M decimation factor  ·  L interpolation factor  ·  rational rate change by L/M: upsample by L, filter once at the higher rate, then downsample by M

Decimation. Keeping every M-th sample is sampling all over again, at fs/M, so everything above the new Nyquist frequency aliases. The anti-alias filter must come first, cut off below fs/(2M), and then the discarding is safe. Skipping it is one of the most common bugs in signal-processing code, and it produces plausible-looking spectra with entirely fictitious peaks.

Interpolation. Inserting L−1 zeros between samples leaves the spectrum unchanged but now, at the higher rate, the old replicas sit inside the new band as images. A low-pass filter at the old Nyquist removes them, and its gain must be L to restore the amplitude lost by the zeros.

Efficiency: do not compute what you throw away

Filtering at the full rate and then discarding M−1 of every M outputs wastes almost all the work. Polyphase decomposition computes only the outputs that survive, cutting the cost by exactly M. For interpolation it skips the multiplications by the inserted zeros, saving L. This is why a well-written resampler is far faster than the obvious implementation, and why large rate changes are done in several small stages rather than one big one.

Sources
  • Crochiere & Rabiner, Multirate Digital Signal Processing, Prentice-Hall, 1983
  • Vaidyanathan, Multirate Systems and Filter Banks, Prentice-Hall, 1993 — polyphase structures
Time–frequency · roadmap §44

The short-time Fourier transform

Real signals change. Chop the record into overlapping windows, transform each, and you can watch the spectrum evolve — subject to one unavoidable trade-off.

X[m,k] = Σn x[n]·w[n−mH]·e−j2πkn/N
m frame index  ·  H hop size in samples  ·  w window  ·  N frame length  ·  the spectrogram is |X[m,k]|², normally shown in dB

The trade-off is not a limitation of the method

Δt · Δf ≥ 1/(4π)    in practice: Δf ≈ ENBW·fs/N,  Δt ≈ N/fs
A long window resolves frequency and blurs time; a short window resolves time and blurs frequency. The product is bounded below — this is the same inequality as Heisenberg's, and for the same mathematical reason

So the window length is a statement about what you are looking for. Distinguishing two close tones needs a long window. Locating a click needs a short one. If you need both at once, you need more than one spectrogram — or a method that varies its resolution with frequency, which is what wavelets do.

Practical settings

Overlap of 50 % with a Hann window, or 75 % for smoother displays, gives good reconstruction and even weighting of every sample. Below 50 % overlap the tapered window edges under-weight parts of the record and events can fall between frames. Hop size sets the time axis resolution of the display; window length sets the actual resolution — as with zero padding, do not confuse the two.

Sources
  • Allen & Rabiner, "A unified approach to short-time Fourier analysis and synthesis", Proc. IEEE 65(11), 1977
  • Gabor, "Theory of communication", J. IEE 93(26), 1946 — the time–frequency uncertainty relation
Time–frequency · roadmap §45

Wavelets

The STFT uses one window length for every frequency. A wavelet transform scales the window with the frequency — short windows for high frequencies, long ones for low.

This matches how signals usually behave. A transient click is brief and broadband; a slow oscillation is long and narrowband. Analysing both with the same window means compromising on both. The wavelet's constant-Q tiling gives fine time resolution where events are fast and fine frequency resolution where they are slow.

W(a,b) = (1/√a)∫ x(t)·ψ*((t−b)/a) dt
ψ the mother wavelet — a short oscillation, zero mean  ·  a scale, inversely related to frequency  ·  b translation in time  ·  the 1/√a keeps energy constant across scales

Where it earns its place

Transient detection in vibration monitoring — a bearing fault is a train of short impacts that a spectrogram either locates badly or resolves badly. Denoising, by thresholding small wavelet coefficients and reconstructing, which removes noise while keeping edges sharp in a way linear filtering cannot. Compression, where JPEG 2000 uses a wavelet transform. And multi-resolution analysis generally, whenever a signal has structure at several scales at once.

Not a replacement for the Fourier transform

Wavelets have no single frequency axis you can quote a number from, the choice of mother wavelet materially changes the result, and coefficients are harder to interpret physically than a spectrum in engineering units. For stationary signals a PSD is better in every way. Reach for wavelets when the signal is genuinely multi-scale or transient — not as a default upgrade.

Sources
  • Mallat, A Wavelet Tour of Signal Processing, 3rd ed., Academic Press, 2008
  • Daubechies, Ten Lectures on Wavelets, SIAM, 1992
Time–frequency · roadmap §46

The Hilbert transform, envelopes and IQ

Discard the negative frequencies and the signal becomes complex. Its magnitude is the envelope, its phase derivative is the instantaneous frequency, and it is the foundation of every modern receiver.

xa(t) = x(t) + j·ℋ{x(t)}    A(t) = |xa(t)|    fi(t) = (1/2π)·dφ/dt
ℋ Hilbert transform: a 90° phase shift at every frequency  ·  xa the analytic signal — same information, no negative frequencies  ·  A(t) instantaneous amplitude, the envelope  ·  fi instantaneous frequency

Envelope detection

The magnitude of the analytic signal is the envelope, computed without rectifying and low-pass filtering and without the distortion that introduces. This is the standard first step in bearing fault diagnosis: a fault produces impacts that ring the structure at a high resonant frequency, and the useful information is the rate of the impacts, not the resonance. Band-pass around the resonance, take the envelope, then take the spectrum of the envelope — and the fault frequency appears clearly where the raw spectrum showed nothing (module 54).

IQ representation

Splitting the analytic signal into real and imaginary parts gives in-phase and quadrature components. Radio, radar and sonar receivers work in IQ because it halves the required sample rate for a given bandwidth, and because it preserves the sign of a frequency offset — with a real signal you cannot tell an upward Doppler shift from a downward one, and with IQ you can.

Sources
  • Randall & Antoni, "Rolling element bearing diagnostics — a tutorial", Mech. Syst. Signal Process. 25(2), 2011 — envelope analysis in practice
  • Boashash, "Estimating and interpreting the instantaneous frequency of a signal", Proc. IEEE 80(4), 1992
Time–frequency · roadmap §47

Modulation, mixing and heterodyning

Multiplying by a sinusoid shifts a spectrum. That single fact underlies radio, every superheterodyne receiver, and the sidebands that appear around a gear mesh frequency.

x(t)·cos(2πfct) ⟷ ½X(f−fc) + ½X(f+fc)
Multiplication in time is convolution in frequency; convolving with a pair of impulses at ±fc copies the spectrum to those positions and halves it

Amplitude modulation, and why it matters mechanically

AM produces a carrier plus sidebands at fc ± fm. In communications that is a design choice. In machinery it is a diagnosis: if a load varies once per shaft revolution, it amplitude-modulates the gear mesh tone, and the spectrum shows the mesh frequency flanked by sidebands spaced at the shaft rate. The spacing identifies which shaft, and the sideband amplitude tracks the severity. The rig example threaded through this trainer has exactly this structure — 632.5 Hz mesh with ±27.5 Hz sidebands.

Frequency modulation

FM encodes information in the instantaneous frequency instead. Its spectrum is much less obvious — Bessel functions of the modulation index — and its bandwidth is approximated by Carson's rule, B ≈ 2(Δf + fm). Mechanically, FM sidebands appear when shaft speed fluctuates within a revolution, so an AM/FM mixture in gear sidebands distinguishes a load problem from a torsional one.

Sources
  • Proakis & Salehi, Communication Systems Engineering, 2nd ed., Prentice-Hall, 2002 — chapters 3–4
  • Randall, Vibration-based Condition Monitoring, 2nd ed., Wiley, 2021 — modulation sidebands as a diagnostic
Time–frequency · roadmap §44, §46

Chirps and instantaneous frequency

When frequency changes during the record, a single spectrum describes a state the signal never occupied. You need to follow it instead.

A chirp sweeps frequency with time. Linear chirps are the workhorse of radar and sonar because they can be compressed to a sharp peak after transmission (module 41), and they appear naturally whenever a machine runs up or coasts down. Their whole-record spectrum is a broad, flat plateau spanning the swept range — technically correct and diagnostically useless.

x(t) = cos(2π(f0t + ½kt²))    fi(t) = f0 + kt    k = (f1−f0)/T
k chirp rate, Hz/s  ·  note that the instantaneous frequency is the derivative of the phase, not the phase argument itself — forgetting the factor of ½ in the quadratic term is a classic error that halves the sweep rate
Instantaneous frequency can be nonsense

It is only meaningful for a signal with a single dominant component. Compute it for a sum of two tones and you get a quantity that oscillates wildly, sometimes going negative, describing neither. Band-pass to isolate one component first, and treat any instantaneous-frequency estimate where the envelope is near zero as undefined — the phase is unconstrained there and its derivative explodes.

Sources
  • Boashash, Time–Frequency Signal Analysis and Processing, 2nd ed., Academic Press, 2016
  • Cohen, Time–Frequency Analysis, Prentice-Hall, 1995
Estimation · roadmap §48, §49

Detection and the matched filter

If you know the shape of what you are looking for, correlating with that shape is provably the best thing you can do in white noise. There is no cleverer filter.

h[n] = s[N−1−n]    SNRpeak = 2Es/N0
s[n] the known signal shape  ·  h[n] the matched filter: the time-reversed template, so that convolution performs correlation  ·  Es total signal energy  ·  N0 noise power spectral density

The output SNR depends only on the signal's energy, not on its shape or duration. A long quiet pulse and a short loud one with the same energy detect equally well — which is exactly why radar transmits long coded pulses and compresses them on receive, getting the range resolution of a short pulse with the energy of a long one.

Thresholds and the two ways to be wrong

PFA = P(y > γ | noise only)    PD = P(y > γ | signal present)
γ the threshold  ·  raising it reduces false alarms and misses more real events; lowering it does the reverse. There is no setting that avoids both

The ROC curve plots PD against PFA as the threshold sweeps. Its shape is fixed by the SNR; the threshold only chooses your position along it. Improving detection therefore means improving SNR, not tuning the threshold — a distinction worth being firm about when someone asks you to "just make it more sensitive".

Sources
  • Van Trees, Detection, Estimation and Modulation Theory, Part I, 2nd ed., Wiley, 2001
  • Kay, Fundamentals of Statistical Signal Processing, Vol. II: Detection Theory, Prentice-Hall, 1998
Estimation · roadmap §50, §51

Preprocessing: the steps before the analysis

Most bad results come from skipping these, not from choosing the wrong transform.

Remove the mean and the trend

A DC offset puts all its energy in bin 0, and leakage from that huge bin swamps the low-frequency region you probably care about. A linear trend is worse: it is a ramp, its spectrum falls as 1/f², and it contaminates a wide band. Subtracting the mean is one line; subtracting a least-squares straight line is barely more, and both should be reflexive before any spectral estimate.

Order matters, and detrending is not always right

Detrend before windowing — windowing a record with an offset creates a bump at the window's own shape. But if the trend is the measurement — a drift study, a settling test, a temperature ramp — removing it destroys the signal. Ask what the low-frequency content means before deleting it.

Normalisation

MethodFormulaUse when
Mean removalx − μAlways, before spectral analysis
Z-score(x − μ)/σComparing channels with different units or gains; feeding machine learning
Peakx / max|x|Display, audio levels. Sensitive to a single outlier
RMSx / rms(x)Equalising energy rather than peaks; more robust than peak normalisation
Calibrationx · ksensConverting counts to engineering units. Do this first, and keep the units with the data

The checklist

1Convert to unitscounts → V → engineering units
2Inspect rawplot it; check clipping and gaps
3Handle outliershampel or median, if they are artefacts
4Detrendmean, then linear if justified
5Filterband-limit to what matters
6Windowthen transform
Sources
  • Bendat & Piersol, Random Data, 4th ed., 2010 — chapter 10, data qualification and preparation
  • Wickham, "Tidy data", J. Stat. Software 59(10), 2014 — on keeping units and provenance with the data
Practice · roadmap §52, §53

What real data actually looks like

Textbook signals are clean, complete and correctly scaled. Real records have dropouts, spikes, saturation, and a sample clock that is not quite what the datasheet says.

DefectHow to spot itWhat to do
Clipping / saturationFlat tops at a constant value; a histogram with spikes at the extremes; new harmonics appearing as level risesCannot be repaired — the information is gone. Reduce gain and re-record. Flag and exclude the affected spans
Dropouts / gapsRuns of exact zeros or repeated identical values; timestamps that jumpNever interpolate silently. Mark them, and exclude affected windows from spectra
SpikesIsolated points many standard deviations out, often single-sampleHampel or median replacement if they are genuinely artefacts — but check they are not the signal (impacts look like spikes)
Stuck / dead channelVariance near zero, or a constant valueDetect automatically before analysis; a flat channel produces a beautiful, meaningless spectrum
Clock errorKnown tone appears at the wrong frequency; two devices drift apart over a long recordCalibrate against a reference tone; resample to a common time base
Quantisation floorSignal occupies only a few LSBs; the histogram is comb-likeIncrease gain. No amount of processing recovers resolution that was never digitised
Interpolating across a gap invents data

Filling a gap with a straight line, or with zeros, creates a signal that was never measured, and the spectrum will faithfully report its content. Zeros are especially bad: a sudden step to zero and back is a broadband transient. If you must fill, fill with something spectrally neutral and — more importantly — keep a mask of which samples are real and carry it through the analysis.

Sources
  • Bendat & Piersol, Random Data, 4th ed., 2010 — chapter 10 on data qualification
  • Hampel, "The influence curve and its role in robust estimation", J. Amer. Stat. Assoc. 69, 1974
Practice · roadmap §54, §55

Features, harmonics and distortion

Reducing a record to a handful of numbers that mean something — and knowing which of those numbers are actually sensitive to the thing you care about.

Time-domain features

RMS = √(⟨x²⟩)  ·  crest = peak/RMS  ·  kurtosis = ⟨(x−μ)⁴⟩/σ⁴
RMS overall energy — robust but slow to respond to a localised fault  ·  crest factor ratio of peak to RMS: about 1.41 for a sine, higher when impulsive  ·  kurtosis 3.0 for Gaussian noise, rising sharply with impulsiveness — the classic early-warning indicator for bearing damage

Kurtosis illustrates the general point about features nicely. It is highly sensitive to early impulsive faults, and then it falls back towards 3 as the fault worsens and the impacts become continuous — so a single reading is ambiguous and the trend is what matters. No feature is meaningful without a baseline.

Harmonics and THD

THD = √(ΣAk² for k ≥ 2) / A1
A1 amplitude of the fundamental  ·  Ak amplitude of the k-th harmonic  ·  quoted as a percentage or in dB; some definitions use total RMS in the denominator, so always state which

Harmonics mean nonlinearity. A perfectly linear system fed a sine returns a sine; anything else — clipping, backlash, a loose joint, an amplifier at its limit — folds energy into integer multiples. The pattern is diagnostic: symmetric distortion such as clipping produces odd harmonics, while asymmetric distortion produces even ones too.

Sources
  • Randall, Vibration-based Condition Monitoring, 2nd ed., Wiley, 2021 — feature selection and trending
  • IEEE Std 1241-2010, Terminology and Test Methods for Analog-to-Digital Converters — THD and SINAD definitions
Practice · roadmap §56

Interpolation, in time and in frequency

Estimating values between the samples you have. The right method depends entirely on whether you are reconstructing a band-limited signal or just drawing a smooth line.

MethodCharacterUse for
Zero-order holdStaircase; sinc-shaped spectral droop and strong imagesNothing analytical. It is what a DAC does before reconstruction
LinearContinuous but kinked; attenuates high frequencies noticeablyDisplay, and rough resampling where accuracy is not critical
Cubic splineSmooth first and second derivatives; can overshoot near sharp featuresSmooth physical quantities; plotting; non-uniform data
Sinc / band-limitedExact for a properly sampled band-limited signalCorrect resampling of sampled signals. This is what the sampling theorem prescribes

Interpolating a spectral peak

A different problem with a neat solution. A peak in a magnitude spectrum rarely falls exactly on a bin, so the bin index underestimates the true frequency by up to half a bin. Fitting a parabola through the peak bin and its two neighbours recovers the fractional offset and typically improves the estimate by an order of magnitude — for essentially no cost.

δ = ½·(Ak−1 − Ak+1) / (Ak−1 − 2Ak + Ak+1)    f ≈ (k + δ)·fs/N
Ak magnitude at the peak bin, Ak±1 its neighbours  ·  δ fractional bin offset, in (−½, ½)  ·  works best on a smooth window such as Hann; on a rectangular window the peak is too sharp for a parabola to fit well
Sources
  • Smith, Spectral Audio Signal Processing, W3K, 2011 — quadratic peak interpolation
  • Unser, "Splines: a perfect fit for signal and image processing", IEEE Sig. Proc. Mag. 16(6), 1999
Multichannel · roadmap §57, §58

Cross-spectra, coherence and frequency response

With two channels you can measure a system rather than a signal — and coherence tells you, frequency by frequency, whether to believe the measurement.

H₁(f) = Sxy(f)/Sxx(f)    γ²(f) = |Sxy(f)|² / (Sxx(f)·Syy(f))
Sxy cross-spectral density between input and output  ·  Sxx, Syy auto-spectra  ·  H₁ the standard FRF estimator, which is unbiased when the noise is on the output  ·  γ² coherence, between 0 and 1

Coherence answers the question "how much of the output at this frequency is linearly caused by the input?" A value near 1 means the FRF estimate there is trustworthy. A value near 0 means it is not, and the reasons are worth distinguishing: noise on either channel, a nonlinearity, an additional unmeasured input, or a leakage or resolution problem in the estimate itself.

Coherence computed from a single block is always exactly 1

With one average, |Sxy|² = SxxSyy identically, regardless of the data — the formula is a normalised inner product of one vector with itself. Coherence is only meaningful after averaging several blocks, and its variance falls roughly as 1/√nd. If your coherence plot is a flat line at 1.0, you have not averaged.

H₁ and H₂

H₁ = Sxy/Sxx is biased low when the input measurement is noisy; H₂ = Syy/Syx is biased high in the same situation but is unbiased when only the input is noisy. In practice, H₁ near resonances and H₂ near anti-resonances are the more accurate choices, and the ratio H₁/H₂ equals the coherence — which gives you a quick check that the two estimators agree.

Sources
  • Bendat & Piersol, Engineering Applications of Correlation and Spectral Analysis, 2nd ed., Wiley, 1993
  • Ewins, Modal Testing: Theory, Practice and Application, 2nd ed., Research Studies Press, 2000
Multichannel · roadmap §59

Parametric spectral estimation

Instead of transforming the data, fit a model to it and derive the spectrum from the model. Much better resolution on short records — and much easier to fool yourself.

x[n] = −Σk=1p akx[n−k] + e[n]    S(f) = σe²/(fs·|1 + Σake−j2πfk/fs|²)
p model order  ·  ak autoregressive coefficients  ·  e[n] white driving noise  ·  the model says "this signal is white noise passed through an all-pole filter", and the filter's response is the estimated spectrum

Because the model is all-pole, it represents peaks very efficiently and needs no window, so there is no leakage and no 1/T resolution limit. On a 64-sample record containing two tones 3 bins apart, an AR model will separate them cleanly where a periodogram shows one lump. This is why it dominates in speech coding, where the vocal tract genuinely is an all-pole resonant system.

The order is the whole game

Too low and peaks merge or vanish. Too high and the model invents sharp peaks that fit noise — and they look entirely convincing, because a parametric spectrum is smooth and confident by construction. Use an information criterion (AIC, MDL) rather than eye, cross-check against a periodogram, and be suspicious of any peak that appears only above a certain order. Burg's method is generally preferred over Yule–Walker on short records, being less biased and always stable.

Sources
  • Burg, Maximum Entropy Spectral Analysis, PhD thesis, Stanford, 1975
  • Kay & Marple, "Spectrum analysis — a modern perspective", Proc. IEEE 69(11), 1981
Multichannel · roadmap §60

Adaptive filters

A filter that tunes its own coefficients from the data, continuously, without being told what the interference looks like.

y[n] = wᵀx[n]  ·  e[n] = d[n] − y[n]  ·  w ← w + μ·e[n]·x[n]
w coefficient vector  ·  d[n] desired signal  ·  e[n] error, which is what gets minimised  ·  μ step size — the single most important parameter  ·  this is LMS: three lines of code, and it works

Choosing μ

Convergence requires 0 < μ < 2/(L·Px), where L is the filter length and Px the input power. Too small and it never catches up with a changing environment; too large and it becomes unstable, often after working fine for hours. Normalised LMS divides by the running input power, which makes the effective step independent of signal level and is almost always the better choice in practice. RLS converges far faster — in about 2L samples rather than 20L — at roughly L× the computation, and with a genuine risk of numerical divergence in finite precision.

Where they are used

Noise cancellation needs a reference sensor measuring the interference alone: the classic case is a microphone near the engine in an active-noise-control system, or a second electrode measuring mains pickup. Echo cancellation in telephony identifies the echo path and subtracts its prediction. Channel equalisation inverts a distorting medium. All share one requirement: something must define what "desired" means.

Sources
  • Widrow & Stearns, Adaptive Signal Processing, Prentice-Hall, 1985
  • Haykin, Adaptive Filter Theory, 5th ed., Pearson, 2013
Multichannel · roadmap §61

Multichannel data, PCA and beamforming

Several sensors give you something one sensor cannot: the ability to separate sources by where they are, or by how they co-vary.

Principal component analysis

Take the covariance matrix across channels, find its eigenvectors, and you have a new set of axes ordered by how much variance each explains. In practice the first few components usually capture nearly everything, so PCA is a compression and a denoiser at once — and the components often correspond to physically meaningful modes, though nothing guarantees that.

C = (1/N)·XᵀX    C·vi = λi·vi    explained fraction = λi/Σλ
X data matrix, samples × channels, mean removed  ·  vi the i-th principal direction  ·  λi variance along it  ·  scale your channels first if they have different units, or the one measured in large numbers will dominate for no physical reason

Beamforming

An array of sensors can be steered without moving. Delaying each channel by the propagation time from a chosen direction and summing makes signals from that direction add coherently while everything else partly cancels. The array's resolution is set by its aperture in wavelengths, and its ability to reject other directions by the number and spacing of elements — with element spacing above half a wavelength producing grating lobes, which is spatial aliasing and behaves exactly like the temporal kind.

Sources
  • Jolliffe, Principal Component Analysis, 2nd ed., Springer, 2002
  • Van Trees, Optimum Array Processing, Wiley, 2002
Multichannel · roadmap §62

State estimation and sensor fusion

When you have a model of how something moves and noisy measurements of where it is, the Kalman filter combines them optimally — and tells you how much to trust the result.

predict: x̂⁻ = Fx̂,  P⁻ = FPFᵀ + Q    update: K = P⁻Hᵀ(HP⁻Hᵀ + R)⁻¹,  x̂ = x̂⁻ + K(z − Hx̂⁻)
x̂ state estimate  ·  P its covariance — the filter's own uncertainty  ·  F state transition  ·  H measurement model  ·  Q process noise: how much you distrust the model  ·  R measurement noise  ·  K Kalman gain, which balances the two automatically

The gain is the whole idea. When measurements are noisy relative to the model, K is small and the filter coasts on prediction; when the model is uncertain, K is large and it follows the data. It does this optimally and automatically, and it is recursive — it needs only the previous state, not the history, which is why it fits real-time systems and why it flew on Apollo.

Q and R are the design, and they are usually guessed

R can often be measured — record a stationary sensor and take the variance. Q rarely can: it encodes how wrong your motion model is. Too small a Q makes the filter overconfident and it will ignore genuine manoeuvres; too large and it becomes an expensive low-pass filter. Check the innovation z − Hx̂⁻: it should be white with the covariance the filter predicts. If it is correlated, the model is wrong and no amount of tuning will fix that.

Sources
  • Kalman, "A new approach to linear filtering and prediction problems", J. Basic Eng. 82(1), 1960
  • Bar-Shalom, Li & Kirubarajan, Estimation with Applications to Tracking and Navigation, Wiley, 2001
Systems · roadmap §63

Real-time processing

Offline you have the whole record and all the time you want. In real time you have a fragment, a deadline, and no ability to look ahead.

Block processing and the overlap methods

Fast convolution via the FFT is far cheaper than direct convolution for long filters, but the FFT assumes circular convolution, which wraps the end of each block onto its start. Overlap-add and overlap-save are the two standard ways to stitch blocks together so the result matches true linear convolution exactly.

FFT length N ≥ L + M − 1    cost per sample ≈ (2·N·log₂N)/(N − M + 1) vs M for direct
L block length  ·  M filter length  ·  the FFT wins for filters longer than roughly 30–60 taps  ·  overlap-add keeps the tails and adds them into the next block; overlap-save discards the first M−1 wrapped outputs of each block instead

Latency

Total latency is the sum of the acquisition block, the algorithmic delay, and the output buffer — and it is usually dominated by the block size rather than the arithmetic. A 1024-sample block at 48 kHz costs 21 ms of buffering before a single instruction executes, plus the same again on output. Halving the block halves the latency and roughly doubles the per-sample overhead. Linear-phase FIR filters add (N−1)/2 samples on top; minimum-phase or IIR designs give less delay for the same magnitude response, which is exactly why control loops use them despite the phase distortion.

The real-time constraint is about the worst case, not the average

A system that processes a block in 40 % of the available time on average but occasionally takes 130 % will glitch, and the glitch will be audible or destabilising. Budget for worst-case execution time, avoid dynamic memory allocation in the processing path, and treat garbage collection or page faults as design faults rather than surprises.

Sources
  • Oppenheim & Schafer, Discrete-Time Signal Processing, 3rd ed., 2010 — §8.7, overlap-add and overlap-save
  • Lyons, Understanding Digital Signal Processing, 3rd ed., Prentice-Hall, 2010 — chapter 13 on implementation
Systems · roadmap §64

Getting the data in correctly

Everything in this trainer assumes the numbers in your array faithfully represent the physical quantity. That assumption is where most real errors live.

The signal chain

1Transducerphysical → electrical; has its own frequency response and resonance
2Conditioninggain, excitation, coupling; sets the noise floor
3Anti-alias filteranalog, before the sampler, always
4Sample & holdfreezes the value; aperture jitter lives here
5ADCquantises; sets resolution and SNR
6Scalingcounts → volts → engineering units

Calibration

value = (counts − offset) × (Vref/2N) / (G · ksens)
ksens transducer sensitivity, e.g. 100 mV/g for an accelerometer  ·  G conditioning gain  ·  Vref ADC reference  ·  every one of these has a tolerance and a temperature coefficient, and an error in any of them scales your entire result

Things that quietly corrupt a measurement

Ground loops — two earth connections at different potentials drive current through the signal return, appearing as mains hum. AC coupling — a high-pass corner you forgot about, which removes real low-frequency content. Aperture jitter — uncertainty in when the sample was taken, which limits SNR at high frequencies to roughly −20log₁₀(2πf·tjitter) regardless of how many bits the ADC has. Channel skew — a multiplexed ADC does not sample its channels simultaneously, so phase and correlation between channels are wrong unless corrected.

Oversampling buys resolution, honestly

Sampling at 4× the rate you need and averaging groups of four gains 6 dB — one extra bit — because quantisation noise is spread over four times the bandwidth while the signal is not. Each factor of four buys another bit. It also relaxes the analog anti-alias filter enormously: at 4× the transition band is four times wider, so a gentle second-order analog filter plus a sharp digital one beats an expensive eighth-order analog design. This is why nearly every modern converter oversamples.

Sources
  • Kester (ed.), Data Conversion Handbook, Analog Devices / Newnes, 2005
  • Ott, Electromagnetic Compatibility Engineering, Wiley, 2009 — grounding and ground loops
Systems · roadmap §65

Bandpass sampling

The Nyquist rule you learned is a special case. What actually matters is the signal's bandwidth, not its highest frequency — and exploiting that lets you sample a 100 MHz signal at 25 MHz on purpose.

2fH/n ≤ fs ≤ 2fL/(n−1)    n = 1, 2, … ⌊fH/B⌋
fL, fH lower and upper band edges  ·  B = fH − fL, the bandwidth  ·  n the zone index; n = 1 recovers the familiar fs ≥ 2fH  ·  valid rates form disjoint bands, not a continuous range

Aliasing folds the band down to baseband, and provided the folded copies do not overlap each other, no information is lost — the process is reversible. This is undersampling or direct IF sampling, and it is how software-defined radios digitise high-frequency signals without impossibly fast converters.

Three conditions that are easy to forget

The anti-alias filter is now a band-pass, and it must be genuinely selective — anything outside the intended band folds in on top of your signal with no way to separate it. The track-and-hold bandwidth of the converter must reach fH, not merely fs/2, which many datasheets bury. And aperture jitter is now judged against the carrier frequency rather than the sample rate, so a clock that is fine at baseband may be hopeless here.

Sources
  • Vaughan, Scott & White, "The theory of bandpass sampling", IEEE Trans. Sig. Proc. 39(9), 1991
  • Kester (ed.), Data Conversion Handbook, Analog Devices, 2005 — undersampling in practice
Applications · roadmap §66–§70

Rotating machinery: order analysis and envelopes

The rig used throughout this trainer, treated properly. Two techniques carry most of the diagnostic weight, and both exist because machines do not run at a constant speed.

Order analysis

When shaft speed varies, every speed-related component smears across the spectrum while fixed-frequency components such as mains hum stay sharp. Order tracking resamples the signal at equal increments of shaft angle rather than of time, using a tachometer or an estimated speed. In the resampled domain every rotational component is at a fixed order — a multiple of shaft rotation — and becomes sharp again, while fixed-frequency components smear instead. That inversion is itself diagnostic.

order = f / fshaft    gear mesh order = number of teeth
Orders are dimensionless multiples of shaft speed  ·  the rig's 23-tooth pinion gives mesh at order 23 whatever the speed  ·  half-orders (0.5, 1.5, …) suggest a loose component; non-integer orders point to bearings, which do not roll in a fixed relationship to the shaft

Envelope analysis for bearings

Bearing defect frequencies are low — the rig's is 118.4 Hz — but a defect excites brief impacts that ring the structure at a high resonance, typically several kilohertz. The energy is at the resonance; the information is in the repetition rate. Band-pass around the resonance, take the analytic envelope, then take the spectrum of that envelope: the defect frequency appears clearly where the raw spectrum showed only a broad hump.

Bearing frequencies are not exact multiples

BPFO, BPFI, BSF and FTF depend on the bearing's geometry and involve the contact angle, so they are non-integer orders and they drift slightly as the rolling elements slip. That is why they cannot be removed by synchronous averaging — which is exactly how synchronous averaging is used to separate gear faults from bearing faults, since gear signals are locked to the shaft and bearing signals are not.

Sources
  • Randall & Antoni, "Rolling element bearing diagnostics — a tutorial", Mech. Syst. Signal Process. 25(2), 2011
  • Fyfe & Munck, "Analysis of computed order tracking", Mech. Syst. Signal Process. 11(2), 1997
Applications · roadmap §71

Transients, edge effects and causality

Every filter has a startup transient, every window has ends, and the first and last portions of any processed record are wrong. How wrong, and what to do about it.

How much to discard

FIR: exactly N − 1 samples    IIR: about 5τ, where τ ≈ −1/ln(rmax)
N FIR length  ·  rmax largest pole radius  ·  a pole at r = 0.99 gives τ ≈ 100 samples, so ~500 samples of contaminated output  ·  forward–backward filtering contaminates both ends

An FIR filter's transient is finite and exactly known: until N samples have entered, the output is a partial sum. An IIR filter's decays asymptotically, so "settled" is a tolerance you choose. Either way, the fix is the same — record more than you need, and trim.

Reducing rather than discarding

ApproachIdeaCaution
TrimDiscard the settling length from each endAlways correct. Costs data, which is why you record extra
Warm-up stateInitialise filter state to the steady-state response of the first sampleStandard in good filtfilt implementations; removes most of the step at the start
Reflect / mirrorExtend the record with a mirrored copy before filteringSmooth at the join but introduces a false symmetry; it can create or hide features at the ends
TaperWindow the ends to zeroFine for spectra, destructive if you need the actual values near the edges
Causal versus offline is a real design decision

Offline you may use future samples: zero-phase filtering, non-causal smoothers, and iterating over the whole record. In real time you may not, and every one of those techniques is unavailable. Deciding which regime you are in — before choosing an algorithm — avoids the common and expensive discovery that a prototype validated offline cannot be deployed.

Sources
  • Gustafsson, "Determining the initial states in forward–backward filtering", IEEE Trans. Sig. Proc. 44(4), 1996
  • Oppenheim & Schafer, Discrete-Time Signal Processing, 3rd ed., 2010 — §2.4 on causality
Applications · roadmap §72–§74

Audio and speech

The domain where perceptual limits matter as much as mathematical ones — and where the ear's own properties decide what processing is worth doing.

What the ear imposes

Hearing spans roughly 20 Hz to 20 kHz, so 44.1 kHz sampling is a modest margin above Nyquist. Loudness perception is approximately logarithmic, which is why audio works in decibels throughout. Frequency perception is also approximately logarithmic — an octave sounds like a constant interval whether it spans 100–200 Hz or 4–8 kHz — which is why audio analysis uses constant-Q, mel or third-octave scales rather than the FFT's linear bins.

Speech

speech = source × filter    pitch f₀ ≈ 85–180 Hz (male), 165–255 Hz (female)
The source is glottal pulses (voiced) or turbulent noise (unvoiced); the filter is the vocal tract, whose resonances are the formants that distinguish vowels  ·  the separation of source from filter is what makes speech coding, synthesis and recognition tractable

Because the vocal tract is genuinely an all-pole resonant cavity, linear prediction (module 47) models it almost exactly — which is why LPC underpins nearly all speech codecs. Pitch is estimated from the autocorrelation or cepstrum of a 20–40 ms frame, short enough that the signal is quasi-stationary and long enough to contain several pitch periods.

The cepstrum separates source from filter

Take the log of the magnitude spectrum and transform again. Multiplication becomes addition under the log, so the slowly varying spectral envelope (the vocal tract) and the rapidly varying harmonic comb (the pitch) separate into different quefrency regions and can be windowed apart. The same trick works on gearboxes, where the "source" is the mesh harmonics and the "filter" is the transmission path.

Sources
  • Rabiner & Schafer, Theory and Applications of Digital Speech Processing, Pearson, 2010
  • Bogert, Healy & Tukey, "The quefrency alanysis of time series for echoes", 1963 — the original cepstrum paper
Applications · roadmap §75–§78

Radar, sonar and communications

Where detection theory, matched filtering and modulation come together — and where range and velocity resolution turn out to be two faces of one trade-off.

R = c·τ/2  ·  ΔR = c/(2B)  ·  fd = 2v·fc/c  ·  Δfd = 1/T
τ round-trip delay  ·  c propagation speed (≈1500 m/s in water, 3×10⁸ m/s for radio)  ·  B signal bandwidth — range resolution depends on bandwidth alone  ·  T coherent integration time — velocity resolution depends on duration alone

Those last two are the key insight. A short pulse has wide bandwidth and gives fine range resolution but little energy and poor velocity discrimination. A long tone has fine velocity resolution and hopeless range resolution. A chirp has both a long duration and a wide bandwidth, so after pulse compression it delivers both — which is why coded waveforms replaced simple pulses everywhere.

Doppler

A moving target returns a frequency-shifted echo. The sign of the shift gives the direction of motion, which is why receivers work in IQ (module 38) — a real-valued sampler cannot distinguish approach from recession. In sonar the shift is proportionally much larger because the propagation speed is so much lower, which means a chirp's compression can be significantly degraded by target motion: the Doppler tolerance of the waveform becomes a design parameter in its own right.

Sources
  • Richards, Fundamentals of Radar Signal Processing, 2nd ed., McGraw-Hill, 2014
  • Woodward, Probability and Information Theory with Applications to Radar, Pergamon, 1953 — the ambiguity function
Applications · roadmap §79, §80

Two-dimensional signal processing

An image is a signal sampled on a grid. Nearly every concept so far carries over unchanged — convolution, filtering, the Fourier transform, aliasing — with one extra dimension and one extra idea.

y[m,n] = ΣiΣj h[i,j]·x[m−i, n−j]
Two-dimensional convolution  ·  a separable kernel factors as h[i,j] = h₁[i]·h₂[j], so a K×K filter costs 2K multiplies per pixel instead of K² — the Gaussian and the box filter are separable, which is most of why they are used

What changes in two dimensions

Frequency becomes a vector: spatial frequency has a direction as well as a magnitude, so an image of vertical stripes has energy along the horizontal frequency axis. Aliasing becomes visible as moiré patterns — the same folding, now spatial, which is why cameras have optical low-pass filters over the sensor and why resizing an image without filtering first produces shimmering artefacts.

Edge detection is differentiation, with all the noise amplification that implies (module 34), which is why Sobel and Canny smooth before differentiating. Compression exploits the fact that natural images have most of their energy at low spatial frequencies — JPEG transforms 8×8 blocks with a DCT and quantises the high-frequency coefficients heavily, since the eye barely notices.

Sources
  • Gonzalez & Woods, Digital Image Processing, 4th ed., Pearson, 2018
  • Wallace, "The JPEG still picture compression standard", Commun. ACM 34(4), 1991
Applications · roadmap §81–§83

Feeding signals to machine learning

Most of the value is in the signal processing, not the model. Good features from a modest classifier beat raw samples into a large one, almost every time, on the data volumes engineering problems actually have.

The pipeline

1Segmentwindows long enough to contain the phenomenon
2Conditiondetrend, filter, normalise — consistently
3Featurespectral, statistical, or a learned representation
4Splitby recording session, never randomly
5Trainsimplest model that could work, first
6Evaluatemetrics matched to the cost of each error
The two mistakes that invalidate most signal-ML results

Leakage through overlapping windows. If windows overlap and you split randomly, nearly identical windows land in both training and test sets, and your reported accuracy is close to meaningless. Split by recording, by machine, or by day — never by window.

Normalising before splitting. Computing a mean and standard deviation over the whole dataset and then splitting leaks test statistics into training. Fit the scaler on the training set alone and apply it to the test set.

Metrics

Accuracy is misleading whenever classes are imbalanced, which in condition monitoring they always are — a detector that never predicts a fault scores 99 % on a machine that fails 1 % of the time. Precision, recall and the confusion matrix say what actually happened, and the ROC and precision–recall curves show the whole threshold trade-off rather than one point on it. The choice between them is an engineering judgement about the relative cost of a missed fault and a false alarm — exactly the question module 41 posed for detection.

Sources
  • Kaufman et al., "Leakage in data mining", ACM TKDD 6(4), 2012
  • Saito & Rehmsmeier, "The precision–recall plot is more informative than the ROC plot on imbalanced datasets", PLoS ONE 10(3), 2015
Rigour · roadmap §84–§86

Estimating frequency, amplitude and delay well

Three measurements you will make constantly, each with a naive method that is needlessly poor and a better one that costs almost nothing.

Frequency

Taking the peak bin quantises the estimate to fs/N. Parabolic interpolation over three bins (module 45) improves it by an order of magnitude. Better still, when the tone is stable across the record, is to unwrap the phase at the peak bin across successive frames — phase advances linearly at a rate set by the frequency offset, so the slope gives a very precise correction.

σf ≥ √(6/(SNR·(2π)²·N³))·fs    (Cramér–Rao bound, single tone in white noise)
The N³ is the important part: doubling the record length improves frequency precision by eightfold in variance, far faster than the 1/N of the bin spacing. Good estimators approach this bound; the peak-bin method does not come close

Phase unwrapping

Computed phase is confined to (−π, π] and jumps by 2π whenever it crosses. Unwrapping adds the multiples of 2π back, and works reliably only when the true phase changes by less than π between samples. Noise near a zero of the envelope, or genuine steps larger than π, produce errors that propagate forwards through the entire remainder of the record — a single bad sample can corrupt everything after it.

Time delay

Cross-correlation with parabolic interpolation is the baseline. Generalised cross-correlation with phase transform weighting (GCC-PHAT) whitens both spectra before correlating, which sharpens the peak dramatically in reverberant or coloured-noise conditions — at the cost of poor behaviour at low SNR, since whitening amplifies the bands where there is no signal.

Sources
  • Rife & Boorstyn, "Single-tone parameter estimation from discrete-time observations", IEEE Trans. Inf. Theory 20(5), 1974
  • Knapp & Carter, "The generalized correlation method for estimation of time delay", IEEE Trans. ASSP 24(4), 1976
Rigour · roadmap §87–§90

Knowing whether your answer is right

The single most valuable habit in this field: test every processing chain on a signal whose answer you already know, before you point it at data you do not understand.

Synthetic signals are the test harness

If your pipeline cannot recover a 100 Hz sine of amplitude 2.0 to within a fraction of a percent, it will not tell you anything true about a gearbox. Build a synthetic signal with known amplitudes, frequencies, phases and noise level; run it through the exact chain you intend to use; and check the numbers that come out against the ones you put in. Nearly every scaling error, windowing error, and off-by-one is caught this way in minutes.

The errors that recur

SymptomUsual cause
Amplitudes wrong by a factor of about 2One-sided versus two-sided spectrum, or a missing factor of 2 on the positive-frequency bins
Amplitudes low by 30–60%No window amplitude correction — divide by the window's coherent gain
Amplitudes wrong by exactly N or 1/NFFT normalisation convention; check where your library puts the 1/N
Peak at the wrong frequency by 2×Confusing f and ω, or Hz and rad/s, somewhere in the chain
Spectrum mirrored or duplicatedPlotting the full two-sided spectrum where you meant one-sided
Everything smearedNon-stationary record, or an unremoved trend
Peaks at unexpected frequenciesAliasing from a missing anti-alias filter, or from decimation without filtering
Result changes with record lengthLeakage; or the estimate is not converged and needs more averages

Uncertainty

PSD estimate: σ/μ ≈ 1/√nd    normalised random error εr = 1/√(BeT)
nd number of independent averages  ·  Be effective resolution bandwidth  ·  T total record duration  ·  a single periodogram has 100% random error however long the record — length alone buys resolution, not stability. Only averaging buys stability
Sources
  • Bendat & Piersol, Random Data, 4th ed., 2010 — chapter 8, statistical errors in estimates
  • JCGM 100:2008, Guide to the Expression of Uncertainty in Measurement (the GUM)
Rigour · roadmap §91 and the closing exercise

Projects, and what mid-level competence looks like

Reading about signal processing produces recognition. Building something produces the judgement that this trainer has been aiming at throughout.

The capstone: analyse the rig properly

Everything needed is in the modules above. Take the accelerometer record — 2 kHz sampling, a 27.5 Hz shaft, a 23-tooth pinion, a bearing defect at 118.4 Hz, mains at 50 Hz, thermal drift and broadband noise — and produce a defensible condition assessment.

Other projects, roughly in order of difficulty

ProjectExercises
Guitar tunerWindowing, peak interpolation, pitch detection, real-time constraints
Mains hum removerNotch design, Q trade-offs, harmonic combs, before/after verification
Heart-rate from a pulse sensorBand-pass design, detrending, peak detection, artefact rejection
Room impulse responseChirp excitation, deconvolution, matched filtering, SNR budgeting
Speech pitch and formant trackerSTFT, LPC, cepstrum, voiced/unvoiced decisions
Two-microphone direction finderCross-correlation, GCC-PHAT, sub-sample delay, geometry
Order-tracking analyserResampling, tacho processing, spectrograms, synchronous averaging

What mid-level actually means

Not knowing more transforms. It means: choosing the window and record length from the measurement requirement rather than from habit; knowing what your filter does to phase and to the first samples of the record; recognising leakage, aliasing and non-stationarity from the shape of a plot; quantifying the uncertainty on the number you report; and testing every chain on a synthetic signal before trusting it. Those habits are worth more than any individual technique in this trainer.

One last principle

Every technique here trades something for something else. Resolution against variance, sharpness against ringing, speed against accuracy, sensitivity against false alarms. There is no setting that wins on every axis, and the mark of competence is being able to say which axis your application cares about — and defend it.

Sources
  • Smith, The Scientist and Engineer's Guide to Digital Signal Processing, California Technical Publishing, 1997 — free online, and excellent on intuition
  • Lyons, Understanding Digital Signal Processing, 3rd ed., Prentice-Hall, 2010
  • Harris, "On the use of windows for harmonic analysis with the DFT", Proc. IEEE 66(1), 1978 — still the definitive window reference
Reference

Formula reference

Every equation used in this trainer, with every symbol defined. Type to filter across titles, equations and descriptions.

Reference

Glossary

The vocabulary of signal processing, defined in the sense used here. Filtering searches the definitions as well as the terms, so you can look up a concept you cannot yet name.