Hand Calculations logo Hand Calculations All help pages ▾

Sample Uniform⚠ unverified

General Calculations / Monte Carlo · Draw a sample from a uniform distribution on the interval [a, b]

Parameters

InputSymbolUnitDefaultDescription
aa1.0Lower bound of the interval
bb1.0Upper bound of the interval
OutputSymbolUnitDescription
resultxA single random sample uniformly distributed on [a, b]

The science & history

Understanding the Parameters

Derivation (Approaching a Proof)

The transform is the simplest case of inverse-transform sampling. A standard uniform variable $U$ has cumulative distribution $F_U(u) = u$ on $[0,1]$. We want $X$ uniform on $[a,b]$, whose CDF is the linear ramp

$$F_X(x) = \frac{x - a}{b - a}, \qquad a \le x \le b.$$

Inverse-transform sampling sets $F_X(x) = U$ and solves for $x$:

$$\frac{x - a}{b - a} = U \quad\Longrightarrow\quad x = a + (b - a)\,U. \qquad\blacksquare$$

Because the target CDF is linear, the inverse is a simple affine map — no transcendental functions needed. This is why the uniform is the foundation: draw $U$, then apply the inverse CDF $F^{-1}$ of any target distribution to get a sample from it. The Weibull sampler (Sample Weibull) is exactly this with $F^{-1}(u) = \eta(-\ln(1-u))^{1/\beta}$; the normal needs the Box–Muller trick (Sample Normal) only because its inverse CDF has no closed form.

Dimensional check. $U$ is dimensionless; $a$ and $b$ share units, so $x = a + (b-a)U$ carries the units of $a$. $\checkmark$

History and Development

Related Concepts: Sample Normal, Sample Weibull, Normal Distribution PDF, Weibull Distribution PDF, Expanded Uncertainty

Notes: Registry calculator sample-uniform (unverified). Stochastic sampler — new random draw each call (not reproducible); needs $a<b$ and many draws. $x = a + (b-a)U$ is inverse-transform sampling of the flat CDF — the seed for all other distributions. Rectangular Type B uncertainty $= a/\sqrt3$. Defaults $a=b=1$ degenerate.

← Back to the workspace  ·  All help pages  ·  Getting started