AI Testing platform: Stone-Mackey-Glass Chaos Simulation
- travisrcstone1984
- Aug 2
- 4 min read
Updated: Aug 20
How to Run
Open the HTML file in any modern browser (Chrome, Firefox, etc.).
The simulation runs automatically on load.
Adjust the parameters:
β: Feedback strength (e.g. 0.2)
γ: Decay rate (e.g. 0.1)
n: Nonlinearity (e.g. 10)
τ: Delay in steps (e.g. 25)
Steps: Simulation length (e.g. 1200)
dt: Time step (e.g. 0.1)
Click “Simulate” to update the graph.
Features
Example Use Cases
Tips
Use larger τ (delay) for more chaotic behavior.
Keep β around 0.2, γ around 0.1, n at 10 for canonical results.
Use phase plot (x(t) vs x(t - τ)) to explore attractors.
User Guide for AI Engineers
Mackey-Glass Time Series Simulator (HTML/JS)
Chaos Modeling | Delay Differential Equation | Dynamic Systems Analysis
Overview
This simulator implements the Mackey-Glass delay differential equation, a classical chaotic system frequently used in:
Time series forecasting
Nonlinear systems modeling
Chaos theory experimentation
Recurrent Neural Network training
Echo State Networks (ESNs) and Reservoir Computing
Equation Implemented
dtdx(t)=β⋅1+x(t−τ)nx(t−τ)−γ⋅x(t)
β (beta): Feedback strength
γ (gamma): Decay rate
n: Nonlinearity exponent
τ (tau): Delay (memory)
dt: Time step (Euler integration)
⚙️ Parameters and UI Controls
📊 Visualization Modes
1. Time Series Plot
X-axis: time (t)
Y-axis: x(t)
Interprets how system evolves over time.
2. Phase-Space Plot
X-axis: x(t - τ)
Y-axis: x(t)
Visualizes strange attractors and system memory behavior.
🛠️ How It Works Internally
Uses Euler integration to simulate delay differential dynamics.
Uses JavaScript arrays to simulate delayed memory x(t - τ).
Uses Plotly.js to dynamically draw charts (responsive, zoomable).
📈 Extension Ideas for AI Engineers
✅ 1. Data Export
Export simulated x(t) values as CSV/JSON for ML training.
jsCopyEdit
function exportData(x, dt) { const data = x.map((val, i) => `${(i * dt).toFixed(3)},${val.toFixed(5)}`).join('\n'); const blob = new Blob([`time,x\n${data}`], { type: 'text/csv' }); const url = URL.createObjectURL(blob); const link = document.createElement('a'); link.href = url; link.download = 'mackey_glass_data.csv'; link.click(); }
✅ 2. Training Dataset Generator
Use different τ, β, γ values to generate diverse time series for:
RNN training
ESN state evolution
GAN-based synthetic data
✅ 3. Real-Time Dynamic System Training
Embed into a TensorFlow.js or Pyodide frontend for in-browser training:
Train a model to predict future x(t + Δt)
Use past x(t - τ)...x(t) as input
✅ 4. 3D Attractor Visualization
Use Plotly’s 3D scatter mode:
js
CopyEdit
trace3D = { x: x.slice(0, steps - 2 tau), y: x.slice(tau, steps - tau), z: x.slice(2 tau, steps), mode: 'lines', type: 'scatter3d' }
✅ 5. Noise Injection & Robustness Testing
Add Gaussian or uniform noise:
js
CopyEdit
const noise = (Math.random() - 0.5) noiseFactor; x.push(xt + dt dx + noise);
🤖 Use Cases in AI
🧠 Tips for Advanced AI Engineers
Perform Lyapunov exponent estimation using trajectory divergence.
Test sequence prediction robustness under parameter drift.
Study bifurcation diagrams by sweeping τ from 0–100.
Use multiple τ-lagged values as state vectors for LSTM inputs:
xt=[x(t),x(t−τ),x(t−2τ)]
📎 Integration Ready
No frameworks required — native JavaScript.
Copy-paste into any browser-based platform.
Easily extendable into React, Vue, or JupyterLite.
💡 Final Notes
The Mackey-Glass system is a gateway into chaos theory, time delay systems, and AI robustness.
It gives rich, nonlinear, dynamic behavior ideal for testing how well ML models adapt to real-world chaotic systems.
Works cited:
https://www.stonesshop.org/post/mackey-glass-chaos-simulation. Zenodo. https://doi.org/10.5281/zenodo.16729672
Stone, T. Mackey-Glass Time Series Simulator [computer program]. Independent developer; 2025. Available from: https://www.stonesshop.org/post/mackey-glass-chaos-simulation
Mackey, M. C., & Glass, L. (1977). Oscillation and chaos in physiological control systems. Science, 197(4300), 287–289. https://doi.org/10.1126/science.267326
Auxilary Editions:

Mackey-Glass Chaos Simulation – User Guide
Overview
This interactive simulation visualizes the Mackey-Glass time series — a famous example of a chaotic system. It includes a 3D-like field representation where the circumference (field strength) modulates based on the system’s state. Use input sliders to tweak system parameters and observe how chaos emerges in real-time.
Interface Overview
Graph: Displays x(t) over time with modulated radius (field effect).
Input Controls:
β (beta): Controls the growth rate.
γ (gamma): Damping coefficient.
n: Power term, affecting nonlinearity.
τ (tau): Delay, introduces memory into the system.
Steps: Number of iterations.
π Multiplier: Scalar applied to third axis (field representation).
Simulate Button: Runs the model with the current parameters.
How to Use
Launch the Page – The graph runs automatically with default values.
Adjust Parameters – Use input boxes to change β, γ, n, τ, steps, and π.
Click “Simulate” – Graph will update dynamically.
Interpret the Field – Radius grows/shrinks based on x(t) magnitude.
Example Usage Scenarios
Educational: Teach chaotic systems and delay differential equations.
AI/ML Engineering: Use as time-series test data for prediction models.
Signal Processing: Analyze frequency/field patterns in nonlinear systems.
Art/Design: Generate unique chaotic field-based patterns.
Notes
Changing tau to higher values often leads to more chaos.
The π field modulation is optional but enables richer visual structure.
The model does not use real-time differential equations (discrete approximation).
Troubleshooting
No graph? Ensure JavaScript is enabled in your browser.
Unexpected output? Try reducing steps or setting more stable β, γ
Above and below:


Comments