Probing a system
A digital system is a small program. It reads a list x[n] and writes a list y[n], one sample at a time. Ours is y[n] = 0.5·x[n] + 0.3·x[n−1] + 0.2·x[n−2]: it mixes the newest sample with the two before it.
To learn what a system does, feed it the simplest input: the unit impulse δ[n], a single 1 at n = 0 and 0 everywhere else. Whatever comes out is called the impulse response, written h[n].
Each tick, the delay line (cells that remember past samples) shifts right and the new sample enters. At n = 0 the 1 sits under ×0.5, so y[0] = 0.5. Next it moves under ×0.3, then ×0.2, then it falls off the end.
Reading h[n]
So h[n] = 0.5, 0.3, 0.2, then zeros: exactly the three multipliers, in order. It ends after three samples, so this is a finite impulse response (FIR) system. And h[n] = 0 for n < 0: it never answers early (causal).
Why h[n] is enough
Now feed 2δ[n−1]: twice as big, one step later. Out comes 2h[n−1] = 0, 1, 0.6, 0.4. Scaling passes through because the system is linear; the delay passes through because it is time-invariant (LTI).
Any input is a sum of scaled, shifted impulses, so the output is the same sum of shifted copies of h[n]. For x = 1, 2: y = h[n] + 2h[n−1] = 0.5, 1.3, 0.8, 0.4. That sum is convolution, the next lesson.
Feedback and stability
Change the program to feed its own output back into the delay line: y[n] = x[n] + 0.5·y[n−1]. Now h[n] = 1, 0.5, 0.25, 0.125 ... = 0.5ⁿ for n ≥ 0. It shrinks but never becomes exactly zero: an infinite impulse response (IIR).
h[n] also shows stability: bounded inputs give bounded outputs exactly when Σ|h[n]| is finite. The FIR gives 0.5 + 0.3 + 0.2 = 1. The IIR gives 1 + 0.5 + 0.25 + ... = 2. Feedback 1.5 gives 1.5ⁿ: unstable.
In Python
In Python with numpy and scipy, make δ[n] as zeros with a 1 first, list the multipliers b, then run the system with scipy.signal.lfilter. It prints 0.5, 0.3, 0.2 and then zeros: the impulse response, as an array.
The working
# step 1/9 · system system: a rule that turns one list into another y[n] = 0.5·x[n] + 0.3·x[n−1] + 0.2·x[n−2] x[n−1], x[n−2]: the last two inputs, kept in a delay line (two memory cells) it only ever looks at now and the past, so it can run live, sample by sample
The multipliers 0.5, 0.3, 0.2 and the feedback 0.5 are chosen values. Every cell, stem and sum in the figure is computed from this model and matches scipy.signal.lfilter. The rows only have room for n = −1 to 5; the signals go on. Cells round to 3 decimals, so 0.0625 shows as 0.063.