Discrete-time signals x[n]
About this lesson
A discrete-time signal is a list of numbers x[n], one for each whole number n. Follow one short list, 1, 3, 2, −1, through a row of memory cells and a stem plot. You will build the unit impulse δ[n] and the unit step u[n], delay a signal with x[n − 2], rebuild any list from scaled, shifted impulses, and meet the exponential aⁿ·u[n] and the sinusoid cos(ω₀n), whose frequency is in radians per sample. Then you add up its energy and write it all in Python with numpy. It builds on the sampling module (x[n] = x(nT)) and the first module's lessons on signal types and operations.
A signal as a list of numbers
A discrete-time signal x[n] is a list of numbers, one for each whole number n. Ours is x[−1] = 1, x[0] = 3, x[1] = 2, x[2] = −1, and 0 everywhere else. Note that n can be negative.
x[n] = a sequence: one number per whole n n ... −3 −2 −1 0 1 2 3 4 ... x[n] ... 0 0 1 3 2 −1 0 0 ... n = 0 is just a chosen origin; n = −1, −2 ... are as real as n = 1, 2 plot: one stem per n (a stem plot), never a joined-up curve
Read the lesson step by step
A signal as a list of numbers
A discrete-time signal x[n] is a list of numbers, one for each whole number n. Ours is x[−1] = 1, x[0] = 3, x[1] = 2, x[2] = −1, and 0 everywhere else. Note that n can be negative.
x[n] = a sequence: one number per whole n n ... −3 −2 −1 0 1 2 3 4 ... x[n] ... 0 0 1 3 2 −1 0 0 ... n = 0 is just a chosen origin; n = −1, −2 ... are as real as n = 1, 2 plot: one stem per n (a stem plot), never a joined-up curven counts samples, not seconds
The index n is a position in the list, not a time in seconds. If the list came from sampling every T seconds, then x[n] = x(nT). Between whole numbers there is nothing: x[0.5] does not exist.
n = ..., −2, −1, 0, 1, 2, ... (integers only) from sampling (see "Sampling: taking snapshots"): x[n] = xa(n·T), T = sampling period the list itself does not know T: the same numbers could be 1 ms or 1 day apart x[0.5] -> not definedThe unit impulse δ[n]
The unit impulse δ[n] (say "delta of n") is the simplest signal: 1 at n = 0 and 0 everywhere else. It is a single sample. Watch it land in cell n = 0.
δ[n] = 1 if n = 0 0 otherwise n −3 −2 −1 0 1 2 3 4 δ[n] 0 0 0 1 0 0 0 0 also called the unit sample (a Kronecker delta: no infinite spike, just the number 1 in one place)The unit step u[n]
The unit step u[n] is 0 for negative n and 1 from n = 0 on, forever. It is a pile of impulses: u[n] = δ[n] + δ[n−1] + δ[n−2] + ... And back again: δ[n] = u[n] − u[n−1].
u[n] = 1 if n ≥ 0 0 if n < 0 u[n] = Σ δ[n − k], k = 0, 1, 2, ... (one impulse per cell from n = 0 on) δ[n] = u[n] − u[n − 1] n = 0: 1 − 0 = 1 n = 3: 1 − 1 = 0 the memory shows n up to 4; u[n] goes onShifting: x[n − 2] is a delay
Replace n by n − 2 and every value moves two places to the right: y[n] = x[n − 2]. Each sample now arrives two steps later, which is a delay. x[n + 2] would move left: an advance.
y[n] = x[n − 2] y[1] = x[−1] = 1 y[2] = x[0] = 3 y[3] = x[1] = 2 y[4] = x[2] = −1 x[n − n0], n0 > 0: moves right (delay) x[n + n0], n0 > 0: moves left (advance) flip: x[−n] mirrors the list about n = 0Every signal is a sum of impulses
Any list is a sum of scaled, shifted impulses: x[n] = 1·δ[n+1] + 3·δ[n] + 2·δ[n−1] − 1·δ[n−2]. Each impulse puts one value in one place. Later lessons take systems apart this way.
x[n] = Σ x[k]·δ[n − k] (sum over every k) k = −1: 1·δ[n + 1] -> 1 at n = −1 k = 0: 3·δ[n] -> 3 at n = 0 k = 1: 2·δ[n − 1] -> 2 at n = 1 k = 2: −1·δ[n − 2] -> −1 at n = 2 δ[n − k] is 1 only at n = k, so each term fills exactly one cellExponentials: aⁿ·u[n]
x[n] = aⁿ·u[n] multiplies by the same number a at every step. With a = 0.8 the list is 1, 0.8, 0.64, 0.512 ... It shrinks because |a| < 1. With |a| > 1 it grows; with a < 0 its sign flips each sample.
x[n] = aⁿ·u[n], a = 0.8 n = 0: 0.8⁰ = 1 n = 1: 0.8¹ = 0.8 n = 2: 0.8² = 0.64 n = 3: 0.8³ = 0.512 x[n + 1] = a·x[n] (one multiply per step) |a| < 1 decays, |a| > 1 grows, a < 0 alternates: + − + − ... cells show 2 decimals (0.512 -> 0.51)Sinusoids: radians per sample
x[n] = cos(ω₀n) with ω₀ = π/4 turns by π/4 radians every sample, so it repeats every 2π ÷ (π/4) = 8 samples. In discrete time, frequency ω₀ is measured in radians per sample.
x[n] = cos(ω0·n), ω0 = π/4 rad/sample n = 0: cos(0) = 1.00 n = 1: cos(π/4) = 0.71 n = 2: cos(π/2) = 0.00 n = 3: cos(3π/4) = −0.71 n = 4: cos(π) = −1.00 periodic with period N only if ω0·N = 2πk (k a whole number): here N = 8 cos(n) (ω0 = 1) never repeats exactlyTwo frequencies, the same samples
Now take ω₀ = 7π/4, a much faster cosine (the thin curve). At every whole n it hits the same values: cos(7πn/4) = cos(2πn − πn/4) = cos(πn/4). The samples cannot tell these two apart.
cos(7π/4 · n) = cos(2π·n − π/4 · n) = cos(−π/4 · n) (2π·n: whole turns) = cos(π/4 · n) (cos is even) in discrete time: ω0 and ω0 + 2π give identical sequences for cosines, ω0 and 2π − ω0 match too ω0 = π is the fastest: (−1)ⁿ this is aliasing, seen from the list's sideEnergy: add up the squares
The energy of a signal is the sum of its squared values: E = Σ x[n]². Walk the list and square each value. The zeros add nothing, so E = 1 + 9 + 4 + 1 = 15.
E = Σ |x[n]|² (sum over every n) x[−1]² = 1 x[0]² = 9 x[1]² = 4 x[2]² = 1 --- E = 15 finite list -> finite energy 0.8ⁿ·u[n]: E = 1 / (1 − 0.64) = 2.78 u[n]: E is infinite (1 + 1 + 1 + ...)In Python: an array and its n
In Python with numpy, keep the values in one array and their indexes n in another. Python counts from 0, so Python's x[0] holds x[−1] of the maths. np.sum(x**2) gives the energy, 15.
import numpy as np n = np.arange(-1, 3) x = np.array([1, 3, 2, -1]) E = np.sum(x**2) # 15 >>> print(n) [-1 0 1 2] >>> print(x[0]) # first item = maths x[−1] 1 >>> print(x[-1]) # Python −1 = LAST item -1 >>> print(E) 15 (Python 3 with numpy; arange stops before 3)
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01x[n] is 1, 3, 2, −1 at n = −1, 0, 1, 2 and 0 elsewhere. What is y[3] if y[n] = x[n − 2]?
y[3] = x[3 − 2] = x[1] = 2. Replacing n by n − 2 moves every value two places to the right (a delay).
02Which expression equals the unit impulse δ[n]?
u[n] and u[n − 1] are both 1 for n ≥ 1 and both 0 for n < 0; only at n = 0 is u[n] = 1 while u[n − 1] = 0. So the difference is 1 at n = 0 and 0 everywhere else.
03What is the period of x[n] = cos(πn/6)?
A period N needs ω₀·N = 2πk for a whole number k. With ω₀ = π/6, the smallest is N = 2π ÷ (π/6) = 12 samples.
04What is the energy E = Σ x[n]² of the list 2, −2, 1 (zero elsewhere)?
E = 2² + (−2)² + 1² = 4 + 4 + 1 = 9. Squaring makes negative values count too.
05Which statement about discrete-time sinusoids is true?
Adding 2π·n to the angle adds whole turns, so the samples are identical. cos(n) never repeats exactly, ω₀ = π is already the fastest (−1)ⁿ, and ω₀ is in radians per sample.
Glossary
- Discrete-time signal x[n]
- A sequence of numbers indexed by a whole number n (which may be negative); written with square brackets. Often the samples x(nT) of a continuous-time signal.
- Stem plot
- The usual picture of x[n]: one vertical line with a dot on top for each whole n, never a joined-up curve.
- Unit impulse δ[n]
- Also called the unit sample: 1 at n = 0 and 0 at every other n.
- Unit step u[n]
- 0 for n < 0 and 1 for n ≥ 0. It is the running sum of δ[n], and δ[n] = u[n] − u[n − 1].
- Time shift (delay)
- y[n] = x[n − n₀] with n₀ > 0 moves the sequence n₀ places to the right; x[n + n₀] moves it left (an advance).
- Exponential sequence
- x[n] = aⁿ·u[n]: each value is a times the one before. It decays when |a| < 1 and grows when |a| > 1.
- Radians per sample (ω₀)
- The frequency of a discrete-time sinusoid cos(ω₀n): how far its angle turns from one sample to the next.
- Energy
- E = Σ |x[n]|², the sum of the squared values over every n.
Notes and sources
- The list 1, 3, 2, −1 is a made-up example; a = 0.8 and ω₀ = π/4 are chosen values. Every value, stem and sum in the figure is computed from this model.
- The memory row only has room for n = −3 to 4. The signals go on in both directions: u[n] stays 1 and 0.8ⁿ keeps shrinking past n = 4.
- Python's x[-1] means "the last item" (here −1, which is the maths x[2]), not the maths x[−1]. Keep an index array n beside the values to avoid that trap.
- A. V. Oppenheim, R. W. Schafer, J. R. Buck, Discrete-Time Signal Processing, 2nd ed., Prentice Hall, 1999, §2.1 (course text listed on MIT OCW 6.341 readings)
- A. V. Oppenheim, A. S. Willsky, S. H. Nawab, Signals and Systems, 2nd ed., Pearson, 1997, ch. 1 (energy, time shift, the discrete-time impulse and step)
- MIT OpenCourseWare 6.341 Discrete-Time Signal Processing (A. V. Oppenheim)
- MIT OpenCourseWare 6.003 Signals and Systems (D. Freeman, Fall 2011)
- MIT OpenCourseWare RES.6-007 Signals and Systems (A. V. Oppenheim)
- Kronecker delta (Wikipedia): the unit sample function δ[n] in digital signal processing
- Heaviside step function (Wikipedia), discrete form: δ[n] = H[n] − H[n − 1] and H[n] as the running sum of δ
- NumPy documentation: numpy.arange (half-open interval [start, stop))
- NumPy documentation: numpy.sum
- The Python Tutorial, §3.1: negative indices count from the right
Quiz Unlocks after the last step.