Global state is mutable information maintained outside a function and implicitly shared across calls. In R, random-number functions consult hidden global state, including .Random.seed, so repeated calls can produce different values. section 3.5.3
Randomness through hidden state
Calling runif(3) twice produces different results because the first call changes the random-number state used by the second. set.seed() can set that state, while keras3::set_random_seed() coordinates seeds across R, NumPy, Python, TensorFlow, and Torch. section 3.5.3
JAX avoids hidden global state. Its random operations receive explicit PRNG key objects, making identical calls with identical keys reproducible; jax$random$split() creates a new key for new values. section 3.5.3
