01

A tiny state machine

A PRNG stores an internal state. Each request transforms that state and returns part of it as the next number. Because the transition is mathematical, the entire stream is determined by the starting state.

Good generators make the stream hard to distinguish from independent samples for the intended use. They distribute values evenly, avoid obvious correlations, run quickly, and have a period long enough that repetition is practically unreachable.

THE LITTLE FORMULAstateₙ₊₁ = transition(stateₙ) · outputₙ = extract(stateₙ)
02

From integers to useful choices

A generator usually produces fixed-width integers. Divide by the range to obtain a value in [0, 1), then scale it for positions or sizes. To select from a list, map an integer to an index carefully.

Using remainder directly can introduce modulo bias when the generator range is not divisible by the number of choices. The effect may be tiny for artwork but matters in simulations and any fairness-sensitive draw.

THE LITTLE FORMULAx = integer / 2ʷ · value = min + x(max − min)
  • Float in [0,1): scale continuous parameters.
  • Integer index: use rejection sampling when bias matters.
  • Shuffle: use Fisher–Yates with a correct random index.
03

Three well-known families

Xorshift generators update state with bit shifts and exclusive-or operations. They are compact and fast, which makes them common in visual sketches, though basic variants have statistical weaknesses.

PCG combines a simple state transition with a strong output permutation. It is small, fast, and offers multiple independent streams. Mersenne Twister has a famously huge period and is common in scientific software, but its large state and predictable outputs make it unsuitable for secrets.

  • Xorshift — tiny and fast; choose a modern variant.
  • PCG — good statistical quality with compact state.
  • Mersenne Twister — huge period, large state, not cryptographic.
Repeated images demonstrating that a PRNG recreates the same output from the same seed
FIG. 03Determinism is a feature for art, tests, and simulations.
04

Simulation random is not secret random

A cryptographically secure PRNG must remain unpredictable even when an attacker sees many outputs. It is seeded from operating-system entropy and designed so observers cannot feasibly reconstruct past or future state.

Use the browser’s crypto.getRandomValues() for tokens, passwords, session identifiers, keys, or security decisions. A fast art PRNG is the wrong tool for those jobs, however random its output looks.

05

Choose by the consequence of being wrong

For a visual sketch, speed, portability, and repeatable seeds may matter most. For a scientific simulation, test statistical properties and document the generator. For parallel workloads, select a design with independent streams. For security, use the platform CSPRNG.

There is no single “most random” generator. There are generators whose guarantees match a task. Naming the task first is the most important selection step.

Crystalline abstract art generated deterministically from seed 99999
FIG. 05For creative work, a compact reproducible generator can be exactly the right choice.
NOW MAKE IT MOVE

Turn the idea into an experiment.

The quickest way to understand a pattern is to change it and watch what happens.

See a seed in action