Documentation Center

  • Trial Software
  • Product Updates

Contents

Uniform Distribution (Continuous)

Overview

The uniform distribution (also called the rectangular distribution) is notable because it has a constant probability distribution function (pdf) between its two bounding parameters. It is appropriate for representing the distribution of round-off errors in values tabulated to a particular number of decimal places, and is used in random number generating techniques such as the inversion method.

Parameters

The uniform distribution uses the following parameters.

ParameterDescriptionConstraints
lowerLower limit
upperUpper limit

Parameter Estimation

The maximum likelihood estimator (MLE) for lower is the sample minimum. The MLE for upper is the sample maximum.

Probability Density Function

The probability density function (pdf) of the continuous uniform distribution is

The pdf is constant between lower and upper.

This plot illustrates how changing the value of the parameters lower and upper affects the shape of the pdf.

% Create three distribution objects with different parameters
pd1 = makedist('Uniform');
pd2 = makedist('Uniform','lower',-2,'upper',2);
pd3 = makedist('Uniform','lower',-2,'upper',1);

% Compute the pdfs
x = -3:.01:3;
pdf1 = pdf(pd1,x);
pdf2 = pdf(pd2,x);
pdf3 = pdf(pd3,x);

% Plot the pdfs
figure;
stairs(x,pdf1,'r','LineWidth',2);
hold on;
stairs(x,pdf2,'k:','LineWidth',2);
stairs(x,pdf3,'b-.','LineWidth',2);
ylim([0 1.1]);
legend({'lower = 0, upper = 1','lower = -2, upper = 2',...
    'lower = -2, upper = 1'},'Location','NW');
hold off;

As the distance between lower and upper increases, the density at any particular value within the distribution boundaries decreases. Because the density function integrates to 1, the height of the pdf plot decreases as its width increases.

Cumulative Distribution Function

The cumulative distribution function (cdf) of the continuous uniform distribution is

This plot illustrates how changing the value of the parameters lower and upper affects the shape of the cdf.

% Create three distribution objects with different parameters
pd1 = makedist('Uniform');
pd2 = makedist('Uniform','lower',-2,'upper',2);
pd3 = makedist('Uniform','lower',-2,'upper',1);

% Compute the cdfs
x = -3:.01:3;
cdf1 = cdf(pd1,x);
cdf2 = cdf(pd2,x);
cdf3 = cdf(pd3,x);

% Plot the cdfs
figure;
plot(x,cdf1,'r','LineWidth',2);
hold on;
plot(x,cdf2,'k:','LineWidth',2);
plot(x,cdf3,'b-.','LineWidth',2);
ylim([0 1.1]);
legend({'lower = 0, upper = 1','lower = -2, upper = 2',...
    'lower = -2, upper = 1'},'Location','NW');
hold off;

Descriptive Statistics

The mean and variance of the continuous uniform distribution are related to the parameters lower and upper.

The mean is

The variance is

Relationship to Other Distributions

The standard uniform distribution (lower = 0 and upper = 1) is a special case of the beta distribution obtained by setting the beta distribution parameters a = 1 and b = 1.

The inversion method uses the continuous standard uniform distribution to generate random numbers for any other continuous distribution. The inversion method relies on the principle that continuous cumulative distribution functions (cdfs) range uniformly over the open interval (0,1). If u is a uniform random number on (0,1), then x = F–1(u) generates a random number x from any continuous distribution with the specified cdf F.

Related Examples

More About

Was this topic helpful?