A pure function produces the same result from the same explicit inputs without relying on hidden global state or externally observable side effects. Random-number generation makes the idea concrete: a global random seed can change results between calls, while explicit seed arguments or JAX PRNG keys make the random state part of the function's inputs. section 3.5.3
Explicit seeds make noise generation repeatable
apply_noise <- function(x, seed) { set.seed(seed) x + array(runif(length(x), -1, 1)) } identical(apply_noise(x, 1337), apply_noise(x, 1337)) # [1] TRUE Changing the seed produces a different deterministic result. In R, restoring the original global seed is also necessary for the function to be truly pure; withr::local_seed() handles that detail. section 3.5.3
JAX makes purity and statelessness operational through explicit PRNG keys:
- Stateless operations support determinism and automatic vectorization. section 3.5.3


















