Linear Systems and Convolution¶
Signals rarely travel unaltered from source to sensor, because rooms echo, cables blur crisp edges, neural membranes integrate incoming currents, and filters carve away unwanted noise. This section introduces Linear Time-Invariant (LTI) systems, reveals why one single impulse response captures a system's entire behaviour via convolution, and shows how reversing that operation creates the optimal matched filter for plucking faint targets out of heavy noise.
Systems as Signal Operators¶
- Picture singing a single note inside a tiled bathroom versus singing that same note outdoors in an open meadow. Your vocal cords produced the exact same input sound wave \(x[n]\), yet what reaches a friend's ears is a completely different output wave \(y[n]\). The room acted as a system, an operator \(\mathcal{H}\) that transforms an entire input sequence into a corresponding output sequence.
-
Notice the curly braces around \(x[n]\). A system does not merely plug one isolated number into a formula like \(f(x) = x^2\). It can remember past inputs, combine neighbouring samples, stretch sharp peaks into lingering tails, or average out jitter. Moving-average smoothers on stock prices, low-pass anti-aliasing circuits, photographic camera lenses, acoustic concert halls, and even the dendritic trees of cortical neurons (Chapter 12) are all signal-processing systems.
-
Arbitrary non-linear, time-varying systems can behave wildly and unpredictably. Fortunately, an enormous slice of physics and engineering obeys two clean, remarkably powerful symmetries that make analysis transparent and exact.
Linearity and Time-Invariance¶
- The first symmetry is linearity, which bundles two everyday intuitions called additivity (superposition) and homogeneity (scaling). Suppose you drop two pebbles into a calm pond and watch their circular ripples cross one another without distorting each other, simply adding their heights wherever they meet. And if you drop a pebble twice as heavy, the resulting wave grows twice as tall. Formally, for any two input signals \(x_1[n]\) and \(x_2[n]\) and any scalar weights \(a\) and \(b\), a linear system satisfies the superposition equation.
- The second symmetry is time-invariance (or shift-invariance). If you clap your hands inside a cathedral today at noon and listen to the reverberation, then clap identically five seconds later, you expect the exact same reverberation shifted five seconds later. The laws of physics inside the room did not suddenly mutate between claps. Formally, shifting the input by \(n_0\) samples produces the exact same output shifted by \(n_0\) samples.
- Any system that satisfies both properties is called a Linear Time-Invariant (LTI) system. LTI systems form the backbone of signal processing, audio engineering, wireless communications, and control theory for one breathtaking reason. You never need to test an LTI system on every possible song, radar pulse, or stock chart. Testing it just once tells you everything it will ever do!
The Unit Impulse and Impulse Response¶
-
Imagine walking into a grand historic cathedral with an audio recorder, hoping to capture its exact acoustic character so you can later make a dry studio cello sound as though it was recorded beneath those vaulted stone arches. Instead of dragging a full orchestra inside, an acoustic engineer simply pops a single balloon (or fires one sharp starter pistol) and records the decaying wash of echoes that follows.
-
In discrete-time mathematics, that razor-sharp balloon pop is the unit impulse (or Kronecker delta) \(\delta[n]\), a sequence equal to \(1\) strictly at \(n = 0\) and \(0\) everywhere else.
- When you feed \(\delta[n]\) into an LTI system \(\mathcal{H}\), the output sequence that rings out is called the impulse response, always denoted \(h[n] = \mathcal{H}\{\delta[n]\}\). Why does this single fingerprint completely determine the system? Because any discrete signal \(x[n]\) can be sliced into a sum of shifted, scaled impulses! Every sample \(x[k]\) sitting at time index \(k\) is literally a spike of height \(x[k]\) placed at location \(k\).
- Now watch what happens when we pass this decomposition through our LTI system \(\mathcal{H}\). By linearity, we pull the sum and the scalar weights \(x[k]\) outside the operator. By time-invariance, each shifted impulse \(\delta[n - k]\) produces the shifted impulse response \(h[n - k]\). Out drops the master equation of LTI systems, discrete convolution.
Discrete Convolution, Toeplitz Matrices, and CNNs¶
-
There are two equally valuable ways to picture convolution in your head, and switching between them makes every problem easier. The input-side view (which we just derived) imagines each input sample \(x[k]\) launching its own miniature echo \(x[k]\,h[n - k]\) that overlaps and adds onto the tails of earlier samples. The output-side view asks what determines a single output sample \(y[n]\) right now. Rewriting the sum shows that you flip \(h[k]\) backwards in time to get \(h[-k]\), slide it across to position \(n\), multiply overlapping entries pairwise, and add them up.
-
Because multiplying two polynomials follows the exact same cross-term sum, discrete convolution is commutative (\(x * h = h * x\)), associative (\((x * h_1) * h_2 = x * (h_1 * h_2)\)), and distributive over addition. Chaining two filters one after the other in series is mathematically identical to running a single combined filter whose impulse response is \(h_1 * h_2\).
-
Notice also how cleanly this links back to linear algebra from Chapter 02! Because convolution is a linear map from a finite input vector \(\mathbf{x} \in \mathbb{R}^M\) to an output vector \(\mathbf{y} \in \mathbb{R}^{M+L-1}\), it can be written as a plain matrix-vector product \(\mathbf{y} = \mathbf{H}\mathbf{x}\), where every descending diagonal of \(\mathbf{H}\) repeats the exact same entry of \(h[n]\). A matrix with constant diagonals is called a Toeplitz matrix, visually expressing time-invariance because every column is simply the previous column shifted down by one row.
-
And if you have already read Chapter 08 on Computer Vision, you have seen this exact sliding inner product before! A 1D or 2D Convolutional Neural Network (CNN) slides a small learned kernel across an audio track or an image grid, sharing identical weights across every spatial or temporal position so the layer automatically obeys shift-equivariance. (Technically deep learning libraries skip the time-reversal flip and compute cross-correlation, which merely flips the order in which the learned weights are stored.)
-
When working with finite digital buffers of length \(M\) and a kernel of length \(L\), you will routinely encounter three practical boundary modes. Full convolution returns all \(M + L - 1\) samples from the first overlapping entry to the last trailing echo, same convolution trims the edges back to length \(M\) so input and output grids match one-to-one, and valid convolution keeps only the \(M - L + 1\) interior positions where the kernel fits completely inside the signal without zero-padding.
Causality and BIBO Stability¶
-
Just because you can write down a mathematical impulse response \(h[n]\) on a chalkboard does not mean you can build it into a real-time circuit or trust it not to blow up your speakers. Two physical guardrails separate well-behaved real-world systems from broken ones.
-
The first guardrail is causality. A real-time system cannot react to a clap before your hands touch. Its output at time \(n\) may depend on present and past inputs (\(k \le n\)), never on future inputs (\(k > n\)). Inspecting the convolution sum \(y[n] = \sum_k h[k]\,x[n - k]\) reveals a crisp test. An LTI system is causal if and only if its impulse response is completely silent before time zero.
-
Offline systems processing pre-recorded files (such as smoothing an already saved photo, sharpening a completed EEG recording, or running bidirectional audio restoration) are completely allowed to be non-causal, peeking smoothly both backwards and forwards around each sample. Live hearing aids, microphone processors, and rocket autopilots must stay strictly causal.
-
The second guardrail is Bounded-Input Bounded-Output (BIBO) stability. Imagine nudging a marble resting at the bottom of a smooth ceramic bowl versus balancing that marble on top of an upside-down salad bowl. A system is BIBO stable if every bounded input (\(|x[n]| \le M_x < \infty\) for all \(n\)) guarantees a bounded output (\(|y[n]| \le M_y < \infty\)) rather than spiralling off to infinity. For any LTI system, BIBO stability holds if and only if the impulse response is absolutely summable.
-
Every finite-length filter (called a Finite Impulse Response, or FIR, filter) is automatically BIBO stable because adding finitely many finite numbers can never diverge. A classic five-point moving-average smoother \(h[n] = \frac{1}{5}\) for \(0 \le n \le 4\) simply averages the five most recent readings to calm sensor jitter, and its response always stops dead four steps after the input falls silent.
-
Infinite-tail feedback systems (Infinite Impulse Response, or IIR, filters) recycle a fraction of their own previous output back into the present, as in the simple leaky integrator \(y[n] = x[n] + r\,y[n - 1]\) whose impulse response is \(h[n] = r^n\) for \(n \ge 0\). Such systems stay BIBO stable only when the decay factor satisfies \(|r| < 1\), because the geometric series \(\sum_{n=0}^{\infty} |r|^n = 1 / (1 - |r|)\) converges cleanly. Set \(r = 1\) (an ideal running accumulator) or \(r = 1.05\) (positive microphone feedback near a loudspeaker) and even a tiny constant input drives the output straight into deafening saturation.
Cross-Correlation, Autocorrelation, and Matched Filtering¶
-
Now let us turn convolution slightly sideways to solve one of the most dramatic detective problems in science. Suppose a radar dish transmits a known sweeping pulse \(s[n]\) toward the night sky, and milliseconds later the antenna records a noisy hiss \(r[n] = s[n - n_0] + w[n]\) where the returning echo is ten times quieter than the background thermal noise \(w[n]\). Looking at \(r[n]\) on an oscilloscope shows nothing but static. How on earth can you spot the exact instant \(n_0\) when the echo arrived?
-
Rather than flipping the template backwards, slide the unflipped target shape \(s[n]\) across the noisy recording \(r[n]\) and compute the dot product at every possible lag \(m\). This sliding similarity score is the cross-correlation \(R_{rs}[m]\).
-
When you correlate a signal with shifted versions of itself, \(R_{xx}[m] = \sum_n x[n]\,x[n - m]\), you get its autocorrelation, which peaks right at lag \(m = 0\) (where it equals total signal energy) and stays perfectly symmetric (\(R_{xx}[-m] = R_{xx}[m]\)). Secondary autocorrelation peaks reveal hidden periodicities cleanly even under heavy noise, making autocorrelation a classic tool for tracking the vocal pitch period of human speech (Chapter 10), spotting rhythmic cardiac intervals (Chapter 24), and detecting seasonal cycles in climate records.
-
Notice a neat geometric link between correlation and the cosine similarity you met in Chapter 01. Dividing \(R_{rs}[m]\) by the product of the two local Euclidean norms \(\sqrt{\sum r^2}\sqrt{\sum s^2}\) yields normalised cross-correlation, always bounded strictly between \(-1\) and \(+1\) so bright amplitude spikes cannot fool a template matcher into false alarms.
-
Remarkably, cross-correlation with a known template \(s[n]\) of length \(L\) is completely equivalent to running \(r[n]\) through an LTI filter whose impulse response is the time-reversed template \(h[n] = s[L - 1 - n]\)! This special LTI system is called the matched filter.
-
Why does the matched filter perform such uncanny magic against heavy noise? At the exact sample where the reversed filter aligns squarely over the hidden echo, every positive crest of \(s[n]\) multiplies a positive crest in \(r[n]\) and every negative trough multiplies a negative trough, so all \(L\) samples add constructively to produce the full pulse energy \(E_s = \sum_k s[k]^2\). Meanwhile, random zero-mean white Gaussian noise \(w[n]\) fluctuates wildly in sign, so its contributions largely cancel out and its standard deviation grows only with \(\sqrt{E_s}\).
-
In fact, applying the Cauchy-Schwarz inequality from Chapter 01 proves that among all possible linear filters \(h[n]\), no filter on earth can beat the matched filter's output Signal-to-Noise Ratio in white Gaussian noise! Its peak SNR depends only on total pulse energy \(E_s\) divided by noise variance \(\sigma_w^2\), giving \(\text{SNR}_{\text{out}} = E_s / \sigma_w^2\). That single theorem powers air-traffic radar, underwater sonar, GPS satellite locking, Wi-Fi preamble sync, gravitational-wave chirp detection at LIGO, and template-based neural spike sorting in brain-machine interfaces (Chapter 12).
Take-Home¶
- LTI systems obey superposition and shift-invariance, meaning scaling, summing, or delaying inputs scales, sums, or delays outputs in lockstep.
- The impulse response \(h[n]\) completely characterises any LTI system, because every discrete signal is a weighted sum of shifted unit impulses \(\delta[n - k]\).
- Discrete convolution \(y[n] = \sum_k x[k]\,h[n - k]\) unifies acoustic reverberation, sensor filtering, Toeplitz matrix-vector products, and the sliding weight-shared kernels of CNNs.
- Causality requires \(h[n] = 0\) for \(n < 0\), while BIBO stability requires \(\sum_n |h[n]| < \infty\), guaranteeing bounded inputs never explode into unbounded outputs.
- The matched filter \(h[n] = s[L - 1 - n]\) implements cross-correlation as an LTI filter and provably maximises output SNR against white Gaussian noise via the Cauchy-Schwarz inequality.
Coding Tasks (use CoLab or notebook)¶
-
Construct the Toeplitz convolution matrix \(\mathbf{H}\) for a decaying acoustic echo impulse response \(h[n]\), verify that \(\mathbf{H}\mathbf{x}\) matches
jnp.convolve(x, h)to machine precision, and confirm linearity and time-invariance numerically.import jax import jax.numpy as jnp import matplotlib.pyplot as plt # Simple room echo impulse response h[n] and two test input pulses h = jnp.array([1.0, 0.55, 0.30, 0.16, 0.08], dtype=jnp.float32) x1 = jnp.array([0.0, 1.0, 0.4, -0.8, 0.2, 0.0, 0.5, 0.0], dtype=jnp.float32) x2 = jnp.array([0.3, -0.5, 0.9, 0.0, -0.4, 0.7, 0.0, 0.1], dtype=jnp.float32) # Build explicit (M + L - 1) x M Toeplitz convolution matrix using pure Python list + jnp.array M, L = len(x1), len(h) out_len = M + L - 1 rows = [] for row_idx in range(out_len): row = [] for col_idx in range(M): k = row_idx - col_idx row.append(float(h[k]) if 0 <= k < L else 0.0) rows.append(row) H_toeplitz = jnp.array(rows, dtype=jnp.float32) y_mat = jnp.dot(H_toeplitz, x1) y_conv = jnp.convolve(x1, h) print(f"Max |H @ x1 - convolve(x1, h)|: {float(jnp.max(jnp.abs(y_mat - y_conv))):.2e}") # Verify Linearity: H(2*x1 - 3*x2) == 2*H(x1) - 3*H(x2) y_comb = jnp.convolve(2.0 * x1 - 3.0 * x2, h) y_lin = 2.0 * jnp.convolve(x1, h) - 3.0 * jnp.convolve(x2, h) print(f"Linearity error: {float(jnp.max(jnp.abs(y_comb - y_lin))):.2e}") # Verify Time-Invariance: shift input by 2 samples -> output shifts by 2 samples x1_shifted = jnp.concatenate([jnp.zeros(2), x1]) y_shifted_in = jnp.convolve(x1_shifted, h) y_shifted_out = jnp.concatenate([jnp.zeros(2), y_conv]) print(f"Time-invariance error: {float(jnp.max(jnp.abs(y_shifted_in - y_shifted_out))):.2e}") fig, axes = plt.subplots(1, 2, figsize=(11, 4.0)) im = axes[0].imshow(H_toeplitz, cmap="Blues", aspect="auto") fig.colorbar(im, ax=axes[0], label="Weight h[row - col]") axes[0].set_xlabel("Input Index k") axes[0].set_ylabel("Output Index n") axes[0].set_title("Toeplitz Matrix Representation of Convolution") axes[1].stem(jnp.arange(M), x1, linefmt="#3498db", markerfmt="bo", basefmt=" ", label="Input x1[n]") axes[1].stem(jnp.arange(out_len) + 0.18, y_conv, linefmt="#e74c3c", markerfmt="rs", basefmt=" ", label="Output y[n] = (x1 * h)[n]") axes[1].set_xlabel("Sample Index n") axes[1].set_ylabel("Amplitude") axes[1].set_title("Room Echo Convolution Output") axes[1].legend() axes[1].grid(alpha=0.3) plt.tight_layout() plt.show() -
Test BIBO stability by driving three exponential LTI systems \(h[n] = r^n u[n]\) (\(r = 0.85\) stable, \(r = 1.00\) marginally unstable accumulator, \(r = 1.06\) unstable) with a bounded constant unit step input \(x[n] = 1\), and inspect both \(\sum |h[n]|\) and the output growth.
import jax import jax.numpy as jnp import matplotlib.pyplot as plt N = 60 n = jnp.arange(N, dtype=jnp.float32) x_bounded = jnp.ones(N, dtype=jnp.float32) # Bounded input |x[n]| <= 1 r_values = [0.85, 1.00, 1.06] colours = ["#27ae60", "#f39c12", "#e74c3c"] labels = ["Stable (r = 0.85)", "Marginal Accumulator (r = 1.00)", "Unstable Explosion (r = 1.06)"] fig, axes = plt.subplots(1, 2, figsize=(11.5, 4.0)) for r, col, lab in zip(r_values, colours, labels): h = r ** n y = jnp.convolve(x_bounded, h)[:N] l1_sum = float(jnp.sum(jnp.abs(h))) print(f"{lab:32s} | Partial L1 sum (N={N}): {l1_sum:8.2f} | Final y[59]: {float(y[-1]):8.2f}") axes[0].plot(n, h, color=col, lw=2, label=lab) axes[1].plot(n, y, color=col, lw=2, label=lab) axes[0].set_xlabel("Sample Index n") axes[0].set_ylabel("Impulse Response h[n]") axes[0].set_title("Impulse Responses h[n] = r^n") axes[0].legend(fontsize=8.5) axes[0].grid(alpha=0.3) axes[1].set_xlabel("Sample Index n") axes[1].set_ylabel("Output y[n]") axes[1].set_title("Response to Bounded Step Input x[n] = 1") axes[1].legend(fontsize=8.5) axes[1].grid(alpha=0.3) plt.tight_layout() plt.show() -
Build a matched filter to recover a linear frequency-modulated radar chirp buried at arrival time \(n_0 = 260\) inside heavy white Gaussian noise (input SNR around \(-10\,\text{dB}\)), verify the exact Cauchy-Schwarz output SNR gain, and detect \(n_0\) automatically.
import jax import jax.numpy as jnp import matplotlib.pyplot as plt key = jax.random.PRNGKey(42) # Build a known 80-sample linear chirp pulse s[n] L = 80 t_chirp = jnp.linspace(0.0, 1.0, L) chirp = jnp.sin(2.0 * jnp.pi * (3.0 * t_chirp + 12.0 * (t_chirp ** 2))) # Smooth tapered envelope win = 0.5 * (1.0 - jnp.cos(2.0 * jnp.pi * t_chirp)) s = chirp * win # Place the chirp at true arrival n0 = 260 inside a 500-sample recording N_total = 500 n0_true = 260 clean_sig = jnp.concatenate([jnp.zeros(n0_true), s, jnp.zeros(N_total - n0_true - L)]) # Add heavy white Gaussian noise (sigma_w = 1.6 -> chirp invisible to the eye!) sigma_w = 1.6 noise = sigma_w * jax.random.normal(key, shape=(N_total,)) received = clean_sig + noise # Matched filter: time-reversed template h[n] = s[L - 1 - n] h_matched = s[::-1] y_mf = jnp.convolve(received, h_matched, mode="valid") detected_n0 = int(jnp.argmax(y_mf)) pulse_energy = float(jnp.sum(s ** 2)) input_snr_db = 10.0 * float(jnp.log10(float(jnp.mean(s ** 2)) / (sigma_w ** 2))) theo_out_snr_db = 10.0 * float(jnp.log10(pulse_energy / (sigma_w ** 2))) print(f"True arrival n0: {n0_true} | Matched filter detected n0: {detected_n0}") print(f"Input sample SNR: {input_snr_db:.2f} dB | Matched filter peak SNR: +{theo_out_snr_db:.2f} dB") fig, axes = plt.subplots(3, 1, figsize=(10.5, 6.5), sharex=False) axes[0].plot(s, color="#3498db", lw=2) axes[0].set_title("Known Radar Chirp Template s[n]") axes[0].set_ylabel("Amp") axes[0].grid(alpha=0.3) axes[1].plot(received, color="#e74c3c", lw=1.0, alpha=0.85, label="Noisy recording r[n]") axes[1].axvspan(n0_true, n0_true + L, color="#f39c12", alpha=0.22, label="True hidden chirp window") axes[1].set_title(f"Received Noisy Recording (Input SNR = {input_snr_db:.1f} dB)") axes[1].set_ylabel("Amp") axes[1].legend(loc="upper right", fontsize=8.5) axes[1].grid(alpha=0.3) axes[2].plot(y_mf, color="#27ae60", lw=1.8, label="Matched filter output") axes[2].axvline(detected_n0, color="#9b59b6", ls="--", lw=1.8, label=f"Detected peak at n0 = {detected_n0}") axes[2].set_title(f"Matched Filter Correlation Output (Peak SNR = +{theo_out_snr_db:.1f} dB)") axes[2].set_xlabel("Lag / Candidate Arrival Sample n") axes[2].set_ylabel("Score") axes[2].legend(loc="upper right", fontsize=8.5) axes[2].grid(alpha=0.3) plt.tight_layout() plt.show()