UniformDistribution
class UniformDistribution(val min: Double = 0.0, val max: Double = 1.0) : ContinuousDistribution(source)
Represents the continuous uniform distribution, where all values in the interval [min, max] are equally likely.
The uniform distribution assigns constant probability density to every point within its support and zero density outside it. It is the simplest continuous distribution and is often used as a baseline or "uninformative" prior in Bayesian statistics, for random number generation, and in simulation when every outcome in a range should be equally probable.
The distribution is parameterized by min and max, which define the lower and upper bounds of the support. The probability density is constant and equal to 1 / (max - min) throughout the interval. The CDF increases linearly from 0 at min to 1 at max.
Example:
// Model a random arrival time uniformly distributed between 0 and 60 minutes
val dist = UniformDistribution(min = 0.0, max = 60.0)
dist.mean // 30.0
dist.variance // 300.0
dist.pdf(30.0) // 0.0167 (constant density across the interval)
dist.cdf(15.0) // 0.25 (25% chance of arriving in the first quarter)
dist.quantile(0.5) // 30.0 (the median equals the mean for a symmetric distribution)
dist.sample(Random(42)) // a single random arrival time in [0, 60]
// Standard uniform on [0, 1]
val standard = UniformDistribution.STANDARD
standard.cdf(0.5) // 0.5Content copied to clipboard