ArticlesProjectsWeeklyCredentialsAbout

TMC #0011: Cybernetics: Feedback Control & Wiener Predictor

A pure-Python simulation of Norbert Wiener's cybernetics (1948): PID feedback control of a thermal plant, open-loop vs closed-loop comparison, and a causal Wiener-Hopf optimal predictor on a random walk.

cyberneticsfeedbackpid-controlwiener-filtercontrol-theorypythonsimulation

Wiener's 1948 Cybernetics proposed that negative feedback is the common mechanism behind thermostats, nervous systems, and anti-aircraft gun predictors alike. This simulator demonstrates both of the core mathematical results Wiener derived: the PID feedback control loop and the Wiener-Hopf optimal predictor.

What It Includes

ThermalPlant: A first-order discrete-time thermal system: dT/dt=(TambientT+Q)/τdT/dt = (T_{\text{ambient}} - T + Q) / \tau. Euler-integrated with configurable time constant and ambient temperature.

PIDController: Full proportional–integral–derivative controller: u(t)=Kpe(t)+Kiedt+Kde˙(t)u(t) = K_p e(t) + K_i \int e\, dt + K_d \dot{e}(t). Includes integral windup and output clamping.

Open-loop vs closed-loop demo: Simulates 300 timesteps of a thermal system targeting 70°C with a fixed heat input (open-loop) versus a PID controller. Shows steady-state offset, overshoot, and settling time side by side.

Wiener-Hopf predictor: Discrete causal optimal predictor using the Yule-Walker autocorrelation equations, solved via pure-Python Gaussian elimination (no NumPy). Compares Wiener predictor MSE against naive last-value prediction on a 200-step random walk.

Running It

python cybernetics_sim.py                      # all demos
python cybernetics_sim.py --demo thermal -v    # thermal system with time series
python cybernetics_sim.py --demo prediction    # Wiener-Hopf predictor only

No external dependencies: pure Python 3.10+.

Source code
# TMC #0011 — Cybernetics: Feedback Control & Wiener Predictor

Companion code for [The Thinking Machine Chronicles #0011](/articles/tmc-0011-wiener-cybernetics).

Demonstrates two core results from Norbert Wiener's _Cybernetics_ (1948):
1. PID closed-loop control vs open-loop on a first-order thermal plant
2. Causal Wiener-Hopf optimal predictor using the Yule-Walker equations

## Usage

```bash
python cybernetics_sim.py                      # all demos
python cybernetics_sim.py --demo thermal -v    # thermal with time series
python cybernetics_sim.py --demo prediction    # Wiener predictor only
```

Pure Python 3.10+, no external dependencies.