A from-scratch computational companion to the RES.6-007 problem sets — an independent implementation of RES.6-007 (6.007) — Signals and Systems (MIT, Alan V. Oppenheim), part of a csdiy.wiki full-catalog build.
RES.6-007 is the classic MIT signals-and-systems course: LTI systems and
convolution, continuous- and discrete-time Fourier analysis, the Laplace and
z-transforms, sampling, filtering, modulation, and feedback. This repo turns
that syllabus into a small, tested Python library (ss) plus ten runnable
demos and six solution write-ups. Every quantitative claim is verified: the
code reconstructs signals from their Fourier coefficients, predicts exactly where
tones alias, matches step-response overshoot to its closed form, stabilises an
inverted pendulum, and checks each result against an analytic value in a
64-case pytest suite. Nothing is a stub and no number is hand-typed — the tables
below are produced by the code in results/.
pytest tests/ -q → 64 passed in ~25 s. Ten demos regenerate the figures
and JSON metrics under results/.
| Topic (problem sets) | What it verifies | Result (measured) |
|---|---|---|
| Convolution & LTI (HW04–06) | from-scratch conv = direct sum; rect∗rect=triangle; diff-eq h[n]=lfilter | conv err 2.7e-15; triangle err 1e-3; diff-eq err 0.0 |
| CT Fourier series (HW07) | coeffs = sin(kω₀T₁)/(kπ); Gibbs overshoot; Parseval |
coeff err 5e-5; overshoot 8.95 %; Parseval rel err 1e-4 |
| CT Fourier transform (HW08–09) | rect↔sinc; time-shift; convolution theorem | rect 4e-3; time-shift 3e-15; conv-thm 5.5e-13 |
| DT Fourier (HW10–11) | DTFS exact synthesis; rect DTFT = Dirichlet kernel | recon 4e-16; DTFT err 2e-15 |
| Filtering (HW12) | moving-avg H=freqz; pull 5 Hz tone from 60 Hz + noise |
freqz err 5e-16; 60 Hz cut 56.5 dB |
| Modulation (HW13–15) | DSB coherent demod; AM envelope; SSB half-bandwidth | DSB NRMSE 0.0027; AM corr 0.999; SSB 80 vs DSB 280 Hz |
| Sampling & aliasing (HW16–19) | folding formula predicts FFT peak; sinc reconstruction | alias err 0.0 Hz; sinc RMSE 0.0036 |
| Laplace & 2nd-order (HW20–21) | poles −ζω_n±jω_d; overshoot & peak-time vs theory |
overshoot err 9e-7; peak-time err 9e-4 |
| z-transform & Butterworth (HW22–24) | maximally-flat ` | H |
| Feedback & inverted pendulum (HW25–26) | open-loop RHP pole → PD moves poles to LHP; stabilise from 14° tilt | OL poles ±3.50; CL −2.53, −9.97; θ(8 s) < 1e-3 rad, settle 1.66 s |
Featured figure — sampling & aliasing (results/figures/07_sampling_aliasing.png).
The folding rule predicts the observed FFT peak with zero error across a
sweep spanning three Nyquist zones; a 42 Hz tone sampled at 50 Hz reconstructs
as its 8 Hz alias.
Grounded from the OCW assignments page (26 problem sets HW01–HW26). Covered here across the course's core topics:
- HW01–03 — Signals & systems: transformations, energy/power, system properties
- HW04 — Convolution (CT & DT), closed forms
- HW05 — Properties of LTI systems (impulse/step response, cascade/parallel)
- HW06 — Systems from differential/difference equations
- HW07 — Continuous-time Fourier series (synthesis/analysis, Gibbs, Parseval)
- HW08–09 — Continuous-time Fourier transform & properties
- HW10–11 — Discrete-time Fourier series & transform
- HW12 — Filtering & frequency response
- HW13–15 — Continuous- & discrete-time modulation (DSB / AM / SSB)
- HW16–19 — Sampling, interpolation, DT processing, aliasing
- HW20–21 — Laplace transform & second-order systems
- HW22–24 — z-transform, CT→DT filter mapping, Butterworth
- HW25–26 — Feedback & the inverted pendulum
Full worked solutions are in writeups/.
mit-6007-signals/
├── src/ss/ # the library: one module per topic
│ ├── signals.py convolution.py fourier_series.py fourier_transform.py
│ ├── sampling.py modulation.py laplace.py ztransform.py feedback.py
├── demos/ # 10 runnable scripts -> figures + JSON metrics
├── writeups/ # 6 solution write-ups (HW01-06, 07-11, 12-15, 16-19, 20-24, 25-26)
├── tests/ # pytest suite (64 cases) asserting analytic values
└── results/ # figures/, *.json metrics, run_log.txt (evidence)
# Python repos use the shared csdiy env (Python 3.11):
# D:\Project\_csdiy\.venv-ml\Scripts\python.exe
python -m pip install -r requirements.txt # or reuse the shared venv
# 1) run the full test suite (asserts every analytic value)
python -m pytest tests/ -q
# 2) regenerate figures + metrics under results/ (run demos from the demos dir)
cd demos
python 07_sampling_aliasing.py # one demo
for f in [0-9]*.py; do python "$f"; done # all ten (bash); each writes results/- Tests:
python -m pytest tests/ -q→64 passed in ~25s(results/run_log.txtcaptures the full run). - Demos: each
demos/NN_*.pyprints its measured metrics, writes aresults/NN_*.json, and savesresults/figures/NN_*.png. - The three checks the course cares about most all hold: Fourier reconstruction error is small (DTFS 4e-16, CTFS RMS ↓ to 7e-3), sampling/aliasing predictions match the FFT peak (0.0 Hz error), and from-scratch convolution matches the direct sum (2.7e-15).
Python 3.11 · NumPy · SciPy (signal, integrate) · Matplotlib · pytest.
- An LTI system is its impulse response; everything downstream (filtering, modulation, sampling) is convolution and its frequency-domain dual.
- Truncated Fourier series minimise energy error but always overshoot jumps by ~9 % (Gibbs); the DT Fourier series, being finite, has no such artefact.
- Aliasing is exactly predictable by a folding rule — the reconstruction of an under-sampled tone is its alias, not noise.
- Poles tell the whole stability story: LHP for CT, inside the unit circle for DT, and the bilinear transform preserves this while warping frequency.
- Feedback relocates poles; a right-half-plane (unstable) plant like the inverted pendulum becomes stable once a PD loop drags both poles into the LHP.
Based on the problem sets of RES.6-007 (6.007) Signals and Systems by Prof. Alan V. Oppenheim, MIT OpenCourseWare (Spring 2011). This repository is an independent educational reimplementation; all course materials, problem statements, and specifications belong to their original authors — please consult the official OCW course for the assignments and solutions. Original code in this repo is released under the MIT License.
