A filter and its impulse response
Our filter follows y[n] = 0.5·y[n−1] + 0.25·x[n] + 0.25·x[n−1]. Two delay boxes remember the last input and the last output. Three weights scale the values, and the adder sums them into the new output.
Send in a single 1, then zeros: the impulse δ[n]. Out come 1/4, 3/8, 3/16, 3/32 ... This list is the impulse response h[n]. It describes the system completely, but it never ends.
From the equation to H(z)
The Z-transform turns a list x[n] into a function X(z). Its shift rule says x[n−1] becomes z⁻¹X(z). So each delay box is simply "multiply by z⁻¹". That is why books label delays z⁻¹.
Apply the Z-transform to both sides. Each list becomes a function of z, each delay becomes z⁻¹, and the weights stay as they are: Y = 0.5z⁻¹Y + 0.25X + 0.25z⁻¹X. No more sample-by-sample loop.
Move the Y terms left and factor: (1 − 0.5z⁻¹)Y = 0.25(1 + z⁻¹)X. Divide output by input. The ratio H(z) = 0.25(1 + z⁻¹)/(1 − 0.5z⁻¹) is the transfer function. It no longer depends on the input.
For the impulse, X(z) = 1, so Y(z) = H(z): the transfer function is the Z-transform of h[n]. Partial fractions give back h[0] = 1/4 and h[n] = 0.75·0.5ⁿ: 3/8, 3/16, 3/32, as the cells show.
Poles, zeros and frequency
Multiply top and bottom by z: H(z) = 0.25(z + 1)/(z − 0.5). The top is 0 at z = −1: a zero. The bottom is 0 at z = 0.5: a pole, where H grows without limit. Plot them on the z-plane.
The pole 0.5 is the feedback weight. After n = 1 each output is 0.5 times the last: 3/8, 3/16, 3/32. The pole sits inside the unit circle (|0.5| < 1), so the response dies away: the filter is stable.
Put z = e^jω, a point on the unit circle at angle ω. Then H(e^jω) is the frequency response. Its size is 0.25 × (distance to the zero) ÷ (distance to the pole). From ω = 0 to π it falls from 1 to 0.
At ω = π/2 the distances are 1.414 and 1.118, so |H| = 0.25 × 1.414 ÷ 1.118 = 0.316. Near the pole the gain is high; at the zero it is 0. Slow wiggles pass, fast ones are blocked: a low-pass filter.
In code
In Python 3 with scipy, b and a are the top and bottom of H(z). signal.tf2zpk finds the zero −1 and pole 0.5, signal.freqz computes H(e^jω), and signal.lfilter runs the filter, giving h[n] again.
The working
# step 1/11 · system
y[n] = 0.5·y[n−1] + 0.25·x[n] + 0.25·x[n−1]
x[n] input, sample number n
y[n] output, sample number n
x[n−1] the input one sample ago (input delay)
y[n−1] the output one sample ago (output delay)
weights: 0.25 and 0.25 on the inputs
0.5 on the old output (feedback)
start at rest: both delays hold 0
The weights 0.25, 0.25 and 0.5 are chosen so every impulse-response value is a short exact fraction and the gain at ω = 0 is exactly 1. Every number in the figure is computed from this model; the Python output was checked with scipy 1.18. H(z) here is causal with region of convergence |z| > 0.5. Because that region contains the unit circle, the frequency response is H(z) evaluated at z = e^jω (Oppenheim and Schafer, ch. 5).