Skip to main content

random

Generates a deterministic random number between 0 (inclusive) and 1 (exclusive) based on a seed. This function is stateless: passing the same seed always returns the same value. To generate a sequence of random numbers, vary the seed (e.g., random(seed + index)).
number | string
required
A number or string to seed the random number generator. The same seed always produces the same result.
number
A deterministic pseudo-random number between 0 (inclusive) and 1 (exclusive)

Example

Implementation details

The function uses:
  • DJB2 hash for converting strings to 32-bit integers
  • Mulberry32 PRNG for high-quality pseudo-random number generation with a period of approximately 4 billion
This ensures deterministic, reproducible randomness suitable for video rendering where the same seed must always produce identical output.