Predictable Randomness: Using Chaos for Number Generation


Order in the Chaos

At first glance, chaos and predictability sound like opposites. But in dynamical systems, chaos doesn’t mean pure randomness—it means sensitivity. Small differences in initial conditions lead to drastically different results. That makes chaotic systems ideal for pseudo-random-number-like generation: repeatable sequences that still feel unpredictable.


🎲 Why Chaos?

Most built-in random number generators (RNGs) in programming languages produce sequences that only appear random. Internally, they’re deterministic—given a starting value (a seed), they always return the same sequence.

Chaotic systems do something similar. They’re governed by mathematical equations, so the outcome is repeatable. But the output isn’t obvious or easy to reverse-engineer without knowing the equations and the initial state.


🔄 Turning Attractors Into Numbers

Chaotic systems like Lorentz or Rossler output a continuous stream of values over time. Here’s how we can use that stream:

  1. Start with Initial Conditions: Choose a starting point for the system—x0, y0, z0. These act as your “seed.”

  2. Run the System: Use numerical integration (e.g., Euler’s method) to simulate the system step-by-step.

  3. Sample the Output: Pick a variable (like x) and sample it at regular intervals. Normalize the value to a target range (e.g., 0 to 1 or an integer range).

  4. Repeat: Advance the system and collect more values as needed.

This produces a stream of numbers that:

  • Vary smoothly but unpredictably
  • Are reproducible from the same seed
  • Have some control over the “randomness” depending on parameters and sampling

🔢 Example: Lorentz Number Stream

Here’s a sketch of using the Lorentz system to generate numbers:

let x = 0.1,
  y = 0,
  z = 0;
let sigma = 10,
  rho = 28,
  beta = 8 / 3;

function step() {
  let dx = sigma * (y - x);
  let dy = x * (rho - z) - y;
  let dz = x * y - beta * z;

  x += dx * 0.01;
  y += dy * 0.01;
  z += dz * 0.01;

  return ((x % 1) + 1) % 1; // normalized to [0, 1)
}

Calling step() repeatedly gives you a stream of values between 0 and 1 that appear random, but are entirely deterministic from the initial setup.


🧠 Predictable Randomness: Why It Matters

Using chaos as a number generator has a few interesting properties:

  • Repeatability: You can regenerate the same sequence with the same starting values—great for procedural art, testing, or games.
  • Variability: Tiny changes in the seed create radically different outputs.
  • Aesthetic Noise: The smooth but irregular patterns are well-suited for audio, animation, or generative visuals.

⚠️ Things to Watch Out For

  • Chaotic systems aren’t cryptographically secure. Anyone who knows the equations and seed can reproduce your sequence.
  • Long-term precision errors can accumulate unless handled carefully—especially in floating-point environments.
  • Not all attractors work well as RNGs; some converge or repeat. Choose systems with sustained aperiodic behavior.

Wrapping Up

Chaos offers a surprising way to generate numbers that are both structured and unpredictable. It’s math-based randomness with a memory—perfect when you want randomness that you can control, study, or replicate.

It’s also a reminder that the line between order and disorder isn’t always sharp. Sometimes, randomness lives inside structure—you just have to know where to look.

You can see the behaviour of some of these system on the Chaos Lines post.

Let the numbers flow.