Random Module

import rand, randn, randint from random
import srand, srandn, srandint from random

Non-Deterministic

Uniform: rand() / rand(n) / rand(m,n) — scalar/1D/2D in [0,1)

Normal: randn() / randn(n) / randn(m,n) — standard normal (mean=0, std=1)

Integer: randint(lo, hi) / randint(lo, hi, n) — random int in [lo, hi)

Sampling: choice(arr), choice(arr, n) (with replacement), shuffle(arr), sample(arr, k) (without replacement)

Seeded (Deterministic)

Same seed always produces the same output. Seed is always the first argument. These are pure functions — no global state.

Uniform: srand(seed) / srand(seed, n) / srand(seed, m, n) — deterministic floats in [0,1)

Normal: srandn(seed) / srandn(seed, n) / srandn(seed, m, n) — deterministic normal values

Integer: srandint(seed, lo, hi) / srandint(seed, lo, hi, n) — deterministic integers in [lo, hi)

import srand from random

// Always produces the same 5 values
a = srand(42, 5)
b = srand(42, 5)
// a and b are identical