API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classRandom

@codexo/exojs / math / stable

Seedable pseudo-random number generator using the xoshiro128** algorithm. xoshiro128** (Blackman & Vigna, 2018) keeps a compact 128-bit state - four 32-bit words - and produces high-quality 32-bit outputs that clear the full BigCrush / PractRand test batteries. It replaces the previous Mersenne Twister: ~16 bytes of state instead of ~2.5 KB, faster, and entirely 32-bit (no 64-bit arithmetic), which suits JavaScript well. The generator is deterministic: calling `setSeed(s)` followed by the same sequence of `next()` calls always produces the same output. Use `reset()` to replay from the current seed without changing it.

2
props
4
methods
0
events
Import
import { Random } from '@codexo/exojs'

Seedable pseudo-random number generator using the xoshiro128** algorithm.

xoshiro128** (Blackman & Vigna, 2018) keeps a compact 128-bit state - four 32-bit words - and produces high-quality 32-bit outputs that clear the full BigCrush / PractRand test batteries. It replaces the previous Mersenne Twister: ~16 bytes of state instead of ~2.5 KB, faster, and entirely 32-bit (no 64-bit arithmetic), which suits JavaScript well.

The generator is deterministic: calling `setSeed(s)` followed by the same sequence of `next()` calls always produces the same output. Use `reset()` to replay from the current seed without changing it.

Constructors1
new(seed: number): Random
Methods4
destroy(): void
next(min: number, max: number): number
Advance the generator and return a uniformly-distributed float in the half-open interval [min, max). Defaults to [0, 1).
reset(): this
Reinitialise the generator from the current seed without changing it - equivalent to rewinding to the start of the sequence. Returns this for chaining.
setSeed(seed: number): this
Set a new seed and reset the generator state. Returns this for chaining.
Properties2
seed: number
The seed value currently in use.
value: number
The last value produced by next, normalised to its requested range.
Source