Skip to content

xorshift32

xorshift32(seed): RandomFn

Defined in: xorshift32.ts:18

Creates a seeded pseudo-random number generator function using the xorshift32 algorithm by George Marsaglia (2003). 32-bit state, 32-bit output.

Note: Fails some PractRand tests at large sample sizes, so prefer sfc32/xoshiro128p for statistical work; fine for non-adversarial deterministic fixtures, and simple enough to reproduce bit-for-bit in another language (C, Python, Rust, …) when a fixture must match across an FFI or subprocess boundary.

number

The seed value to initialize the 32-bit state. Must be nonzero (an all-zero state never changes).

RandomFn

A function that generates pseudo-random numbers in the range [0, 1) when called.