Visualizations
028 / 500

028 · Machine learning

Echo State Oracle

A never-trained random reservoir forecasts chaos on a green phosphor oscilloscope.

An echo state network is a fixed, random recurrent network of 300 tanh neurons, sparsely wired and scaled to a chosen spectral radius. While it listens to a chaotic signal (the Mackey-Glass delay equation or the Lorenz system), only a linear readout is fitted: the ridge regression normal equations are accumulated step by step and solved once by Cholesky decomposition. Then the teacher lets go and the prediction is fed back as the next input, so the network runs free and continues the chaos on its own: the bright trace is the oracle, the dim one the true future, and the X/Y tube draws the attractor it is tracing. The autopilot sweeps the spectral radius knob while an invisible twin of the same experiment trains and free-runs the remaining radii a few milliseconds per frame, plotting how many steps each setting stays within tolerance: short for a reservoir that forgets too fast, longest near a radius of one, collapsing once the reservoir's own dynamics turn chaotic.

Try it. Drag the Spectral Radius or Leak Rate knob up and down and release to retrain, or click the chart to try a radius. Signal switches between Mackey-Glass and Lorenz (S), Retrain refits (T or Space), the arrow keys nudge the radius, and L steps the leak rate.

  • Reservoir computing
  • Ridge regression
  • Cholesky decomposition
  • Chaotic time series

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build an echo state network that learns to forecast a chaotic signal, using JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window. Use a near-black background.
- Generate the Mackey-Glass series: dx/dt = 0.2 x(t-17) / (1 + x(t-17)^10) - 0.1 x, integrated with Euler steps of 0.1 and a history buffer for the delay, sampled every 1 time unit. Use tanh(x - 1) as the signal.
- Build a reservoir of 200 tanh neurons with a sparse random weight matrix (about 5% nonzero) scaled to a spectral radius near 1, plus random input and bias weights. Estimate the spectral radius by repeatedly multiplying a vector by the matrix and measuring how fast its length grows.
- Drive the reservoir with 2,000 samples (state = tanh(W state + W_in input + bias)), skip the first 100, and collect the states. Fit a linear readout that predicts the next sample with ridge regression: solve (X^T X + lambda I) w = X^T y with a small Cholesky or Gaussian elimination routine.
- Then switch to free run: feed each prediction back in as the next input. Plot the true continuation and the prediction as two scrolling lines.

Once that works, make it beautiful:
- Style it as a green phosphor oscilloscope with a graticule, glow and faint scanlines.
- Add an X/Y display plotting x(t) against x(t - 17) with slowly fading persistence, so the attractor draws itself.
- Add a slider for the spectral radius that retrains on release, and show how many steps the prediction stays close to the truth.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as forecasting the Lorenz system, sweeping the spectral radius to chart the edge of chaos, or showing the reservoir neurons as a glowing grid.
PreviousCRT MonitorAn emulated electron beam, decaying phosphors and a shadow mask, under a 7x loupe. NextCircuit SimulatorA SPICE-style solver runs a live schematic: LEDs blink, capacitors charge, current flows.

Related visualizations

  • Spiking RasterMachine learning A thousand Izhikevich neurons learn by spike timing and ripple with travelling waves.
  • Hopfield MemoryMachine learning A lamp panel of 400 neurons that repairs scribbled glyphs, until it stores too many.
  • ReLU Stained GlassMachine learning A ReLU network's exact linear regions, drawn as a stained glass window.
  • Ghost RacersMachine learning Sixty neural-net cars evolve to race a track, then face one you draw.
  • Symbolic RegressionMachine learning Genetic programming breeds formulas until it rediscovers the law behind the data.
  • Oscilloscope MusicRetro A phosphor XY scope draws a 4D tesseract, knots and text from the stereo sound you hear.
  • Diffusion SketchpadMachine learning A diffusion model trains live and condenses pure noise into whatever shape you draw.
  • Deep Q SnakeMachine learning A deep Q-network learns snake from scratch, live, on a retro dot-matrix LCD.
  • Lorenz AttractorMath Hundreds of trajectories swirl around the famous butterfly.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs