The Continuous Uniform Distribution

The continuous uniform distribution can be used to model [to be supplied]

The uniform distribution has two parameters: the minimum value and the maximum value. The traditional types of parameters (location, scale, shape) don't have an obvious meaning for the uniform distribution. The probability density function is:

Probability density of the continuous uniform distribution.

The (continuous) uniform distribution is sometimes called the (continuous) rectangular distribution.

The uniform distribution is implemented by the ContinuousUniformDistribution class. It has three constructors. The first constructor takes no arguments. It creates the standard uniform distribution over the interval [0, 1]. The second constructor takes one argument: the maximum value. The minimum value defaults to 0. Finally, the third constructor takes two arguments: the minimum and the maximum value.

The following constructs the uniform distribution over the interval [0, 1] using each of the constructors:

C#
var uniform1 = new ContinuousUniformDistribution();
var uniform2 = new ContinuousUniformDistribution(1.0);
var uniform3 = new ContinuousUniformDistribution(0.0, 1.0);

The ContinuousUniformDistribution class has two specific properties, LowerBound and UpperBound, which return the lower and upper limits of the distribution.

ContinuousUniformDistribution has one static (Shared in Visual Basic) method, Sample, which generates a random sample using a user-supplied uniform random number generator. The second and third parameters are the minimum and maximum values of the distribution.

C#
var random = new MersenneTwister();
double sample = ContinuousUniformDistribution.Sample(random, 0.0, 1.0);

The above example uses the MersenneTwister class to generate uniform random numbers.

For details of the properties and methods common to all continuous distribution classes, see the topic on continuous distributions..