Skip to content
Tutorials Center
My learning

Topics

Lesson 5 of 38 ยท Discrete Signals

Sequences and Basic Signals

Meet the discrete-time sequences of DSP: the unit impulse, unit step, ramp, exponentials and sinusoids, and why any signal is a sum of shifted impulses. Python examples.

A discrete-time signal is a sequence: a list of numbers x[n] indexed by an integer n (..., -2, -1, 0, 1, 2, ...). The index is a count of samples, not seconds; the link to time is t = n/fs. A few standard sequences act as the "alphabet" of DSP. Test a system with them, build bigger signals from them, and later you will meet the same shapes inside filters and transforms.

The unit impulse

The unit impulse (or delta) d[n] is 1 at n = 0 and 0 everywhere else. It is the discrete counterpart of an instantaneous tap, and it is easy to realize on a computer because it is a perfectly ordinary finite number (unlike the continuous delta function).

d[n] = 1 if n = 0, else 0

Its power is that any sequence can be written as a sum of scaled, shifted impulses:

x[n] = sum over k of x[k] * d[n - k]

This is the key to convolution: to know how a system reacts to any input, it is enough to know how it reacts to one impulse.

Python Impulses, shifts and the sifting sum

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The unit step and the ramp

The unit step u[n] is 0 for negative n and 1 from n = 0 on. It models "switch on at time 0". The step is the running total of the impulse, and the impulse is the difference of the step:

d[n] = u[n] - u[n-1]

The ramp r[n] = n * u[n] grows linearly after switching on. A rectangular pulse of length L is u[n] - u[n-L].

Python Step, ramp, pulse

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real exponentials

x[n] = a^n with a real number a:

  • 0 < a < 1: decays smoothly to zero (a capacitor discharging, an echo fading).
  • a > 1: grows without bound (an unstable system will show this).
  • -1 < a < 0: decays while flipping sign every sample.
  • a = 1: constant; a = -1: alternates +1, -1, ....

Exponentials are the natural answers of simple filters, as the lesson on difference equations shows.

Python Exponentials with different bases

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Sinusoids and complex exponentials

The discrete sinusoid is

x[n] = A * cos(w*n + phi)

with amplitude A, digital frequency w in radians per sample, and phase phi. The link to physical frequency is w = 2*pi*f/fs. Two facts are different from continuous time:

  1. Frequencies repeat: w and w + 2*pi give identical sequences. Only w in -pi ... pi (or 0 ... pi for real signals) is distinct. This is aliasing seen from the other side.
  2. A discrete sinusoid is periodic only if w/(2*pi) is a ratio of integers. With w/(2*pi) = p/q in lowest terms, the period is q samples. A sine with w = 1 radian per sample never exactly repeats.

The complex exponential e^(j*w*n) = cos(w*n) + j*sin(w*n) is the building block that the Fourier transform uses; it carries amplitude and phase in a single number.

Python Periodic or not?

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Combining and classifying signals

Real signals are sums and products of the basic ones:

  • A damped sinusoid a^n * cos(w*n) rings and fades, like a struck bell.
  • An amplitude-modulated wave multiplies a slow sinusoid by a fast one.
  • A chirp has a frequency that changes with n.

Classifying signals helps pick the right tool:

Property Meaning
Finite or infinite length A finite sequence is nonzero only on a limited range of n
Causal x[n] = 0 for n < 0
Real or complex Complex signals appear in radio (I/Q)
Deterministic or random Random signals (noise) are described by statistics
Periodic or aperiodic Repeats every N samples or not
Python A damped sinusoid

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is d[n-3]?

    d[n-3] is nonzero when n - 3 = 0, that is at n = 3: the impulse delayed by 3 samples.
  2. 2. Which sequence is periodic?

    w/(2 pi) = 0.2 = 1/5 is a ratio of integers, so the period is 5 samples. cos(n) has w/(2 pi) irrational.
  3. 3. How are the unit step u[n] and unit impulse d[n] related?

    The difference of a step and its one-sample delay is nonzero only at n = 0.
  4. 4. Which base a makes a^n grow without bound?

    When |a| > 1 the magnitude increases every sample.

Summary

  • A discrete signal is a sequence x[n]; n counts samples, with t = n/fs.
  • The unit impulse d[n] builds every signal as a sum of scaled shifts: x[n] = sum x[k] d[n-k].
  • The step is a running sum of the impulse; the ramp and pulse follow from it.
  • a^n decays for |a| < 1 and explodes for |a| > 1.
  • A sinusoid cos(w n + phi) is periodic only if w/(2 pi) is rational; w and w + 2 pi are indistinguishable.

Next: Signal Operations, Energy and Symmetry