TExcelTAD
Home › Fourier Analysis & Signals › Impulse Response

Impulse Response

The impulse response hh is the fingerprint of an LTI system. Its length says how long the system remembers, its sign pattern whether it smooths or sharpens, and two simple tests on it decide causality and stability. This lesson reads those properties off hh and measures an impulse response from input-output data.

Causality and stability

  • Causal: the output never depends on future inputs. For an LTI system this means h[n]=0h[n] = 0 for n<0n < 0. Real-time systems must be causal; offline processing (editing a recording) need not be.
  • BIBO stable: every bounded input gives a bounded output. For an LTI system this holds exactly when ∑n∣h[n]∣<∞\sum_n \lvert h[n] \rvert < \infty.
python · try it yourself
import numpy as np

n = np.arange(0, 2000)
candidates = {
    "h = 0.9^n u[n]":      0.9 ** n,
    "h = 1.01^n u[n]":     1.01 ** n,
    "h = u[n] (summer)":   np.ones_like(n, dtype=float),
    "h = 1/(n+1) u[n]":    1 / (n + 1.0),
    "h = 1/(n+1)^2 u[n]":  1 / (n + 1.0) ** 2,
}
for name, h in candidates.items():
    partial = [np.sum(np.abs(h[:m])) for m in (100, 1000, 2000)]
    print(f"{name:20s} sum|h| over 100, 1000, 2000 terms: {[f'{p:.4g}' for p in partial]}")
h = 0.9^n u[n]       sum|h| over 100, 1000, 2000 terms: ['10', '10', '10']
h = 1.01^n u[n]      sum|h| over 100, 1000, 2000 terms: ['170.5', '2.096e+06', '4.393e+10']
h = u[n] (summer)    sum|h| over 100, 1000, 2000 terms: ['100', '1000', '2000']
h = 1/(n+1) u[n]     sum|h| over 100, 1000, 2000 terms: ['5.187', '7.485', '8.178']
h = 1/(n+1)^2 u[n]   sum|h| over 100, 1000, 2000 terms: ['1.635', '1.644', '1.644']

Only 0.9n0.9^n and 1/(n+1)21/(n+1)^2 have converging sums: those systems are stable. The accumulator h=uh = u is unstable (a constant input makes its output grow forever), and so is 1/(n+1)1/(n+1), whose sum grows like ln⁡n\ln n.

FIR and IIR

  • FIR (finite impulse response): hh has finitely many nonzero values. Always stable. Moving averages and most audio equalizer designs in software.
  • IIR (infinite impulse response): hh goes on forever, typically from feedback, as in y[n]=a y[n−1]+x[n]y[n] = a\,y[n-1] + x[n], whose h[n]=anu[n]h[n] = a^n u[n]. Stable when ∣a∣<1\lvert a \rvert < 1 (IIR Filters and Feedback).

Step response

The response to a unit step u[n]u[n] is the running sum of hh, s[n]=∑k≤nh[k]s[n] = \sum_{k \le n} h[k]. It shows how quickly a system settles after "switching on", which is how control engineers specify systems (rise time, overshoot, settling time).

python · try it yourself
import numpy as np

a = 0.8
n = np.arange(15)
h = (1 - a) * a ** n                          # a normalized one-pole smoother, sum of h = 1
step = np.cumsum(h)
print("h:   ", np.round(h, 3).tolist())
print("step:", np.round(step, 3).tolist())
print("samples to reach 90 %:", int(np.argmax(step >= 0.9)) + 1)
h:    [0.2, 0.16, 0.128, 0.102, 0.082, 0.066, 0.052, 0.042, 0.034, 0.027, 0.021, 0.017, 0.014, 0.011, 0.009]
step: [0.2, 0.36, 0.488, 0.59, 0.672, 0.738, 0.79, 0.832, 0.866, 0.893, 0.914, 0.931, 0.945, 0.956, 0.965]
samples to reach 90 %: 11

Measuring an impulse response

You cannot always apply a perfect impulse, but with a known noise-like input and the recorded output you can solve for hh: cross-correlating the output with white noise input returns hh scaled by the input power. This is how room and loudspeaker responses are measured.

python · try it yourself
import numpy as np

rng = np.random.default_rng(7)
h_true = np.array([0.0, 1.0, 0.6, 0.0, -0.3, 0.1])
x = rng.normal(size=20000)                         # white noise test signal
y = np.convolve(x, h_true)[:x.size] + 0.05 * rng.normal(size=x.size)   # measured with noise

h_est = np.array([np.dot(y[k:], x[:x.size - k]) for k in range(8)]) / np.dot(x, x)
print("true h:     ", h_true.tolist() + [0.0, 0.0])
print("estimated h:", (np.round(h_est, 2) + 0.0).tolist())
true h:      [0.0, 1.0, 0.6, 0.0, -0.3, 0.1, 0.0, 0.0]
estimated h: [0.0, 1.0, 0.59, 0.01, -0.29, 0.12, 0.0, -0.01]

In software

  • Convolution reverbs in audio software store measured impulse responses of concert halls and apply them by (fast) convolution.
  • scipy.signal.impulse and dimpulse compute impulse responses of continuous and discrete models.

Exercises

Exercise 1: Causal or not?

Is h[n]=δ[n+1]+δ[n]h[n] = \delta[n + 1] + \delta[n] causal?

Answer

No.

Solution

h[−1]=1≠0h[-1] = 1 \ne 0: the output y[n]=x[n+1]+x[n]y[n] = x[n + 1] + x[n] needs the next input sample.

Exercise 2: Stability

For which aa is h[n]=anu[n]h[n] = a^n u[n] stable?

Answer

∣a∣<1\lvert a \rvert < 1.

Solution

∑n≥0∣a∣n\sum_{n \ge 0} \lvert a \rvert^n is a geometric series, finite exactly when ∣a∣<1\lvert a \rvert < 1, with sum 1/(1−∣a∣)1/(1 - \lvert a \rvert).

Exercise 3: Settling time (code)

For the smoother h[n]=(1−a)anh[n] = (1 - a)a^n with a=0.95a = 0.95, how many samples does the step response need to reach 90 %?

Answer

45 samples.

Solution

The step response is 1−an+11 - a^{n+1}, which reaches 0.9 when an+1≤0.1a^{n+1} \le 0.1, that is n+1≥ln⁡0.1/ln⁡0.95≈44.9n + 1 \ge \ln 0.1/\ln 0.95 \approx 44.9.

python · try it yourself
import numpy as np
a = 0.95
step = np.cumsum((1 - a) * a ** np.arange(200))
print(int(np.argmax(step >= 0.9)) + 1)
45

Test yourself

An LTI system is causal when…

  1. h[n]=0h[n] = 0 for n<0n < 0
  2. hh is finite
  3. ∑∣h∣<∞\sum |h| < \infty
  4. h[0]=1h[0] = 1

An LTI system is BIBO stable when…

  1. hh is causal
  2. ∑n∣h[n]∣<∞\sum_n |h[n]| < \infty
  3. h[0]≠0h[0] \ne 0
  4. hh is periodic

Which filter type is always stable?

  1. IIR
  2. FIR
  3. any filter with feedback
  4. the accumulator