Signals as lists
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.
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.
Two building blocks
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.
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].
Moving and building
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.
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.
Exponentials and sinusoids
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] = 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.
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.
Measuring and coding
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.
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.
The working
# step 1/11 · sequence 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
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.