x[−1]–x[0]–x[1]–x[2]–x[3]–x[4]–x[5]–THE SYSTEMx[n]·0.50x[n−1]·0.30x[n−2]·0.20Σaddy[−1]–y[0]–y[1]–y[2]–y[3]–y[4]–y[5]–1import numpy as np2import scipy.signal as sg3d = np.zeros(7); d[0] = 14b = [0.5, 0.3, 0.2]5h = sg.lfilter(b, [1], d)n000
0246012nx[n]INPUT x[n]δ[n]2δ[n−1]δ[n] + 2δ[n−1]024600.511.5ny[n]OUTPUT y[n]h[n]2h[n−1]h[n] + 2h[n−1]0.5ⁿ·u[n] (IIR)
Coloured parts: what the current step is about; everything else rests in whiteBlocks: the input list x[n], the system (a delay line and an adder Σ), the output list y[n], and a Python code cardPlots: stem plots of the input and the output, one stem per whole nTokens carry each sample into the delay line and each sum into the outputThe system y[n] = 0.5·x[n] + 0.3·x[n−1] + 0.2·x[n−2] probed with δ[n]: h[n] = 0.5, 0.3, 0.2 (FIR). Then 2δ[n−1] -> 2h[n−1], δ[n] + 2δ[n−1] -> 0.5, 1.3, 0.8, 0.4, the feedback system y[n] = x[n] + 0.5·y[n−1] with h[n] = 0.5ⁿ·u[n] (IIR), and stability from Σ|h[n]|. "h[n] tells you everything" holds only for linear, time-invariant (LTI) systems. A system such as y[n] = x[n]² has an impulse response too, but it does not predict other outputs.

Probing a system

  1. 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.

Reading h[n]

Why h[n] is enough

Feedback and stability

In Python

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.