Skip to content
Oakfield Operator Calculus Function Reference Site

Uniform Random Variables

Uniform random variables assign equal probability to any value within a closed interval, often used as the base source for transformed distributions.

For XU(a,b)X\sim U(a,b), the density is

f(x)={1ba,axb,0,otherwisef(x) = \begin{cases} \frac{1}{b-a}, & a \le x \le b,\\ 0, & \text{otherwise} \end{cases}

Inputs are random seeds or generator states; outputs lie within the interval ([a,b]) with constant density.


E[X]=a+b2,Var(X)=(ba)212\mathbb{E}[X] = \tfrac{a+b}{2}, \qquad \operatorname{Var}(X) = \tfrac{(b-a)^2}{12}

Independent uniforms are standard primitives for Monte Carlo sampling and for inverse-transform samplers.


U(0,1)U(0,1) is the canonical base distribution. If a=ba=b, the distribution collapses to a deterministic constant. Affine maps c+dU(0,1)c + d\,U(0,1) generate any U(a,b)U(a,b); applying log\log or trigonometric maps seeds Box–Muller and inverse-transform samplers.


  • U(0,1)U(0,1) is the canonical base distribution.
  • a=ba=b collapses to a point mass.

Box–Muller Gaussian transforms and Laplace inverse-CDF sampling start from uniforms; Bernoulli or categorical variables arise from thresholding uniforms; low-discrepancy sequences provide quasi-uniform alternatives.


Oakfield uses uniform RNG streams as the base for several higher-level stochastic features:

  • Integrator noise hooks use integrator_rng_uniform() as the base RNG in integrators/integrator.c, with integrator_noise_uniform() / Box–Muller Gaussian / inverse-CDF Laplace built on top.
  • Distribution selection is exposed by name ("uniform", "gaussian", "laplace") and mapped onto the integrator noise function pointers.
  • Seeded stochastic operators like stimulus_white_noise, stimulus_fbm, and stimulus_random_fourier carry a seed parameter to produce reproducible realizations.

Uniform sampling is the standard starting point for pseudorandom generation and for transforming randomness into other distributions.

Uniform(0,1) variates are the common interface exposed by RNG libraries and underpin a wide range of stochastic simulation pipelines.


  • Devroye, Non-Uniform Random Variate Generation
  • Knuth, The Art of Computer Programming, Vol. 2: Seminumerical Algorithms