← Computational Mathematical Biology

Random-number generation

Stochastic simulation requires computer-generated random values from specified probability distributions. In practice these are pseudorandom: a deterministic algorithm produces a sequence designed to behave statistically like random draws.

NumPy generator

import numpy as np
rng = np.random.default_rng(12345)

u = rng.uniform(0, 1)
z = rng.normal(0, 1)
tau = rng.exponential(scale=2.0)

Seeds

A fixed seed makes a simulation reproducible. Different seeds produce different pseudorandom sequences.

Distribution matters

Uniform, normal, exponential, Poisson and binomial draws represent different stochastic mechanisms and should not be interchanged merely because each produces random numbers.

Key idea. Random-number generation is the computational bridge between probability distributions and simulated stochastic trajectories.