Convolution, animated.
Slide one function under another, multiply where they overlap, add it all up — and you've just modeled how a system responds to an input, blurred an image, smoothed a time series, and run one layer of a convolutional network. This page walks through all four, with the animation running the whole time.
A continuous signal is, in the limit, a train of impulses.
Every real measurement — a voltage, a sound wave, a sensor reading — starts out continuous. A computer can't store a continuous function, so the first move in any signal-processing pipeline is always the same: chop it into samples spaced \(\Delta t\) apart. Watch what that actually does to the curve.
Sample too coarsely (drag \(N\) down toward 4) and the blocks miss what the curve does between samples — the oscillation itself can vanish. Exactly how finely you need to sample to avoid that is its own question (the sampling theorem), covered in full in Notebook 5. Here we only need the picture: sampling turns a function into a sequence, and sequences are exactly what the sum below operates on.
Two units of measure for the same operation
Continuous convolution replaces a sum with an integral. Discrete convolution replaces the integral with a sum over samples. On a computer they're the same computation — the "continuous" plot below is just the discrete sum evaluated at a much finer step size, exactly like shrinking \(\Delta t\) above.
Why convolution predicts a system's output at all.
You just watched a continuous signal get chopped into impulses in §01. Here's the payoff: under one specific assumption about the system, that same decomposition is exactly what you need to predict what the system does to any input, once you know how it reacts to a single sharp poke.
The assumption: linear & time-invariant (LTI)
- Linear: scale the input, the output scales the same way; add two inputs, the outputs add. No saturation, no cross-terms.
- Time-invariant: the system doesn't change its behavior over time — poke it now or poke it later, you get the same response, just shifted.
Neither is exactly true of any real system, but an RC filter, a room's acoustics, or a camera lens's blur are all close enough to be useful.
The consequence: superposition of impulses
Every one of the little blocks from §01 is a weighted, time-shifted impulse. LTI says the system's response to that whole train is just the sum of its response to each impulse separately — each one scaled and delayed exactly like the piece that produced it. If \(h(t)\) is the response to one unit impulse, the response to all of them together is:
The output of an LTI system is fully determined by its impulse response — measure \(h\) once, and you can predict the response to any input by convolving.— the working assumption behind circuit analysis, room acoustics, and control theory alike
Three everyday versions of the same slide-multiply-sum.
Every kernel below is really just somebody's impulse response — a room's, a smoothing rule's, a lens's. Once you can see the mechanism from §01–02, it starts showing up everywhere. Three concrete cases:
The echo machine
A short "clap" \(x\) meets an echo kernel \(h\) with copies of itself at increasing delay and decreasing loudness. The output is literally the sound of the room.
The moving average
\(h = [\tfrac{1}{3}, \tfrac{1}{3}, \tfrac{1}{3}]\) is a box that just averages its 3 neighbors. Convolving a noisy reading with it is exactly a rolling mean — smoothing is convolution with a flat kernel.
Image blur, in one dimension
Treat a row of pixel brightness as a signal and slide a 5-tap averaging kernel across it. The bright block softens at both edges exactly where the kernel window straddles the boundary.
The kernel is a learned impulse response.
Swap the physics for statistics and nothing about the mechanism changes. A convolutional filter still slides across data, multiplies, and sums — the only difference is that instead of deriving \(h\) from circuit equations, you let gradient descent choose it.
Impulse response as feature
In signals-and-systems, \(h(t)\) is the system's fingerprint — everything worth knowing about how it reacts. In a CNN, a trained kernel plays exactly that role for a pattern: it's the "impulse response" of a detector for edges, textures, or motifs, discovered by fitting instead of by measuring a circuit. Stacking layers of these detectors grows the receptive field the same way cascading two physical filters combines their impulse responses.
A technical footnote worth knowing
Strictly, a "true" convolution flips the kernel before sliding (as in every widget on this page); most deep-learning frameworks implement Conv1d/Conv2d as cross-correlation — no flip. It makes no practical difference, because the kernel is learned: if flipping would have helped, training just learns the flipped version instead.
Four lenses, one operation.
| Lens | "Convolving" means | \(x\) plays | \(h\) plays | \(y\) plays |
|---|---|---|---|---|
| Pure math | Sliding integral / sum of a product | any function or sequence | any function or sequence | the resulting function |
| Signals & systems | Predicting an LTI system's output | the input signal | the impulse response | the system's output |
| Image processing | Sliding a small weighted window over pixels | the image / a row | a hand-designed kernel | the filtered image |
| Data science & AI | Sliding a learned weighted window to extract features | the input tensor | a trained filter | a feature map |
Every widget on this page is the same eight lines of code: flip, slide, multiply, sum. What changes is only what you decide to call \(x\), \(h\), and \(y\).
- See Notebook 4 — circular vs. linear convolution, and computing convolution via the DFT.
- See Notebook 9 — the multiplication ↔ convolution duality, verified numerically.
- Oppenheim & Willsky, Signals and Systems — the standard LTI / impulse-response treatment.
- Goodfellow, Bengio & Courville, Deep Learning, ch. 9 — convolution as used in neural networks.