The impulse response of a digital system
لم يُترجم بعد؛ يُعرض باللغة الإنجليزية
عن هذا الدرس
A digital system is a small program that turns one list of numbers into another. Feed it the unit impulse δ[n] and run it one sample at a time: what comes out is its impulse response h[n]. For the three-tap system y[n] = 0.5·x[n] + 0.3·x[n−1] + 0.2·x[n−2], h[n] is just its multipliers 0.5, 0.3, 0.2 (a finite impulse response). Because the system is linear and time-invariant, scaled and delayed impulses give scaled and delayed copies of h[n], so h[n] predicts the output for any input. Add feedback and h[n] goes on forever (an infinite impulse response); h[n] also tells you whether the system is stable. It builds on "Discrete-time signals x[n]" (δ[n] and sums of shifted impulses) and "System properties: linear, time-invariant, causal and stable".
A system is a small program
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.
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
اقرأ الدرس خطوة بخطوة
A system is a small program
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.
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 sampleProbe it with an impulse
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].
x[n] = δ[n] n −1 0 1 2 3 4 5 δ[n] 0 1 0 0 0 0 0 h[n] = the output when the input is δ[n] (the system starts at rest: all memory 0) like tapping a bell once and listeningRun it one sample at a time
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.
n = −1: 0.5·0 + 0.3·0 + 0.2·0 = 0 n = 0: 0.5·1 + 0.3·0 + 0.2·0 = 0.5 n = 1: 0.5·0 + 0.3·1 + 0.2·0 = 0.3 n = 2: 0.5·0 + 0.3·0 + 0.2·1 = 0.2 n = 3: 0.5·0 + 0.3·0 + 0.2·0 = 0 ... 0 from here on the single 1 visits each multiplier onceh[n] is the list of multipliers
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).
h[n] = 0.5·δ[n] + 0.3·δ[n−1] + 0.2·δ[n−2] n −1 0 1 2 3 ... h[n] 0 0.5 0.3 0.2 0 ... FIR: h[n] is zero after a finite length (3 taps -> 3 samples) causal: h[n] = 0 for every n < 0 (output never comes before input)Scale and delay pass straight through
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).
x[n] = 2·δ[n−1] n = 0: 0.5·0 + 0.3·0 + 0.2·0 = 0 n = 1: 0.5·2 + 0.3·0 + 0.2·0 = 1 n = 2: 0.5·0 + 0.3·2 + 0.2·0 = 0.6 n = 3: 0.5·0 + 0.3·0 + 0.2·2 = 0.4 y[n] = 2·h[n − 1] linear: a·δ[n] -> a·h[n] time-invariant: δ[n − k] -> h[n − k] (see "System properties")Any input: add up shifted copies
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.
x[n] = 1·δ[n] + 2·δ[n−1] n: 0 1 2 3 1·h[n] : 0.5 0.3 0.2 0 2·h[n−1] : 0 1 0.6 0.4 --- --- --- --- y[n] : 0.5 1.3 0.8 0.4 y[n] = Σ x[k]·h[n − k] (convolution) so h[n] tells you the output for ANY inputFeedback: an infinite response
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).
y[n] = x[n] + 0.5·y[n−1] (feedback) n = 0: 1 + 0.5·0 = 1 n = 1: 0 + 0.5·1 = 0.5 n = 2: 0 + 0.5·0.5 = 0.25 n = 3: 0 + 0.5·0.25 = 0.125 h[n] = 0.5ⁿ·u[n] (an exponential) IIR: never exactly 0, however long you wait cells show 3 decimals (0.0625 -> 0.063)Stable if Σ|h[n]| is finite
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.
BIBO stable <=> Σ |h[n]| < ∞ FIR: 0.5 + 0.3 + 0.2 = 1 (every FIR is stable: finite sum) IIR: 1 + 0.5 + 0.25 + ... = 1/(1 − 0.5) = 2 y[n] = x[n] + 1.5·y[n−1]: h[n] = 1.5ⁿ = 1, 1.5, 2.25, 3.375 ... Σ grows without limit: unstable rule for this IIR: |feedback| < 1In Python: lfilter
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.
import numpy as np import scipy.signal as sg d = np.zeros(7); d[0] = 1 b = [0.5, 0.3, 0.2] h = sg.lfilter(b, [1], d) >>> print(h) [0.5 0.3 0.2 0. 0. 0. 0. ] lfilter(b, a, x): a[0]·y[n] = b[0]·x[n] + b[1]·x[n−1] + ... − a[1]·y[n−1] − ... >>> print(sg.lfilter([1], [1, -0.5], d)) # IIR [1. 0.5 0.25 0.125 0.0625 0.03125 0.015625] (Python 3, numpy + scipy)
أسئلة سريعة: 5
اختر إجابة واحدة لكل سؤال. يمكنك تغيير اختياراتك قبل التحقق منها.
01What is the impulse response of y[n] = 2·x[n] − x[n−1] (starting at rest)?
Put x = δ: y[0] = 2·1 − 0 = 2, y[1] = 2·0 − 1 = −1, and every later output is 0. For a system like this, h[n] is its list of multipliers in order.
02A linear, time-invariant system has h[n] = 0.5, 0.3, 0.2. What is its output for x[n] = 3δ[n−2]?
Linearity scales the response by 3 and time invariance delays it by 2: y[n] = 3h[n − 2], so 1.5, 0.9, 0.6 at n = 2, 3, 4.
03Which system has an infinite impulse response (IIR)?
Feeding the output back means the impulse keeps echoing: h[n] = 0.9ⁿ for n ≥ 0, which never becomes exactly zero. The others only use a finite number of past inputs.
04An LTI system has h[n] = 1.2ⁿ for n ≥ 0 (and 0 for n < 0). What can you say?
h[n] = 0 for n < 0, so it is causal. But Σ|h[n]| = 1 + 1.2 + 1.44 + ... grows without limit, so a bounded input can give an unbounded output.
05In Python, lfilter([0.5, 0.3, 0.2], [1], d) with d = [1, 0, 0, 0, 0] returns what?
With a = [1] there is no feedback, so lfilter computes y[n] = 0.5·x[n] + 0.3·x[n−1] + 0.2·x[n−2]. An impulse in gives the coefficients out, in order.
المسرد
- System
- A rule (here a small program) that turns an input list x[n] into an output list y[n].
- Impulse response h[n]
- The output of a system that starts at rest when the input is the unit impulse δ[n].
- Delay line
- Memory cells holding the last few input (or output) samples, x[n−1], x[n−2], ..., so the program can use them.
- LTI system
- Linear (scaled and summed inputs give scaled and summed outputs) and time-invariant (a delayed input gives the same output, delayed). For LTI systems h[n] determines the output for every input.
- FIR
- Finite impulse response: h[n] is zero after a finite number of samples. Every FIR system is stable.
- IIR
- Infinite impulse response: h[n] never becomes exactly zero for good, usually because the output is fed back.
- Causal
- The output never depends on future inputs; for an LTI system, h[n] = 0 for all n < 0.
- BIBO stable
- Bounded input gives bounded output. An LTI system is BIBO stable exactly when Σ|h[n]| is finite.
الملاحظات والمصادر
- 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.
- "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.
- A. V. Oppenheim, R. W. Schafer, J. R. Buck, Discrete-Time Signal Processing, 2nd ed., Prentice Hall, 1999, §2.2-2.4 (required text of MIT OCW 6.341)
- A. V. Oppenheim, A. S. Willsky, S. H. Nawab, Signals and Systems, 2nd ed., Pearson, 1997, §2.1 (the discrete-time convolution sum)
- MIT OpenCourseWare 6.003 Signals and Systems (D. Freeman, Fall 2011): convolution, impulse and step responses
- SciPy documentation: scipy.signal.lfilter (the difference equation it runs)
- NumPy documentation: numpy.convolve (discrete linear convolution, 'full' length N + M − 1)
- NumPy documentation: numpy.zeros (default dtype float64)
- Impulse response (Wikipedia): an LTI system is completely characterised by its impulse response
- Finite impulse response (Wikipedia): an Nth-order FIR response lasts N + 1 samples; FIR filters are inherently stable
- Infinite impulse response (Wikipedia): feedback, response that continues indefinitely
- BIBO stability (Wikipedia): discrete-time LTI stable iff h[n] is absolutely summable
اختبار يتاح بعد الخطوة الأخيرة.