# Uniform Distribution Calculator

By Anna Szczepanek, PhD
Last updated: Oct 12, 2021

Welcome to Omni's uniform distribution calculator! Here you'll be able to quickly and easily compute probabilities, generate samples, and determine various measures related to the uniform distribution. In particular, it can serve as a calculator of the mean of uniform distribution. Also, if you need to learn how to calculate a uniform distribution probability by hand, or what various formulae (e.g., the pdf and cdf of uniform distribution) look like, then you're in the right place!

We will start by discussing the definition of a uniform distribution. Keep in mind that this article is, for the most part, dedicated to the continuous uniform distribution. Go directly to the last section to learn about the discrete uniform distribution.

## What is the uniform distribution?

The uniform distribution is a probability distribution in which the possible outcomes form an interval and all sub-intervals contained in this interval that have the same length are equally likely. If the minimum and maximum possible outcomes are `a` and `b`, respectively, we have the uniform distribution on `[a,b]`. We denote this distribution as `U(a, b)`.

We can define a continuous uniform distribution on any interval we want. If we use the `[0,1]` interval, we then obtain the standard uniform distribution, `U(0,1)`. Interestingly, the standard uniform distribution is a special case of the beta distribution with parameters `(1,1)`:

`U(0,1) = B(1,1)`.

Intuitively, we can say that the uniform distribution models the situation where all outcomes are equally likely, though we have to remember that, formally, in the case of continuous distributions, the probability of a particular outcome `x` is always equal to zero: `P(X = x) = 0`.

The uniform distribution pops up repeatedly in statistics. It is most useful when we need to generate random numbers. Virtually every random number generator produces numbers following the standard uniform distribution. Then, if we demand another distribution, these numbers undergo some transformation to ensure that they follow the desired distribution.

We now understand intuitively what the uniform distribution is all about, yet to grasp it fully, we need to look at some graphs and formulas. So, let us now discuss the mathematical definition of the uniform distribution.

## Uniform distribution formulas

#### The pdf of uniform distribution

The formula for the probability density function (pdf) of the uniform distribution `U(a,b)` is the following:

`f(x) = 1 / (b - a)` for `a ≤ x ≤ b`.

For the standard uniform distribution we have an even simpler formula:

`f(x) = 1 ` for ` 0 ≤ x ≤ 1`.

Outside of the interval `[a,b]`, the value of `f` is, of course, zero.

The graph of this pdf is a straight horizontal line. It has the same height for each potential outcome, and this height is equal to `1 / (b - a)`, i.e., to the reciprocal of the length of the interval `[a,b]` over which the distribution is defined. Therefore, the graph of uniform distribution looks like a rectangle. It's therefore not surprising that we sometimes call the uniform distribution the rectangular distribution.

#### The cdf of uniform distribution

The formula for the cumulative distribution function of the uniform distribution `U(a,b)` reads

`F(x) = (x - a) / (b - a)` for `a ≤ x ≤ b`.

For the standard uniform distribution it takes a particularly simple form:

`F(x) = x` for `0 ≤ x ≤ 1`.

Outside of the interval `[a,b]` the values are `F(x) = 0` for `x ≤ a` and `F(x) = 1` for `b ≥ x`.

#### Quantile function of uniform distribution

Recall that the quantile function is the inverse of the cdf. For the uniform distribution, we can compute it very easily, obtaining the following formula:

`Q(p) = (b - a) * p + a`.

## How to use this uniform distribution calculator?

As you've seen above, the uniform distribution is not a complicated concept at all, yet there are a few formulas you'd have to remember to perform any calculations. Thankfully, our uniform distribution calculator knows them all very well and can do the hard work for you! To use the calculator efficiently, follow these steps:

1. Choose the mode of the calculator, that is, tell the calculator what exactly you want to compute. The available options are:
• Probability calculator;
• Sample generator;
• Probability density function;
• Cumulative distribution function;
• Quantile function; or
• Common measures (mean, median, variance, standard deviation, skewness).
2. If you've chosen the Probability calculator mode, select the probability type.
3. Enter the parameters `a` and `b` of the uniform distribution you want the calculator to consider.
4. In the case of probability, cdf, pdf, and quantile, enter the argument.
5. In the case of the sample generator, enter the sample length.
6. The output of the uniform distribution calculator depends on the mode. A graph may even appear!

## How do I calculate the uniform distribution probability?

In the uniform distribution `U(a,b)`, the probability of an interval `[c,d]` (we assume it is fully contained in the interval `[a,b]`) is proportional to the length of this interval. That is, the uniform distribution formula reads:

`P(c ≤ x ≤ d) = (d - c) / (b - a)`.

Alternatively, we can compute `P(c ≤ x ≤ d)` as the area over `[c,d]` that fits under the pdf of the uniform distribution `U(a,b)`. The shape in question is a rectangle, so its area is height times width.

• The height of the rectangle is the pdf value, which is `1 / (b - a)`.
• The rectangle's width is the length of `[c,d]`, that is `d - c`.

Consequently:

`P(c ≤ x ≤ d) = (d - c) * 1 / (b - a)`,

so we've ended up with the same formula as before.

## Mean and variance of uniform distribution

We hope you'll never find yourself in a situation where you cannot use Omni's uniform distribution calculator, but it's better to be safe. This section contains the formulas for the common measures of the uniform distribution, so that, in case of emergency, you can compute them quickly by hand.

1. The mean of the uniform distribution `U(a,b)`:

`μ = (a + b) / 2`

2. The variance of the uniform distribution `U(a,b)`:

`σ² = (b - a)² / 12`

As you're well aware, the standard deviation is simply the square root of the variance, so you can easily transform one into the other.

3. The skewness of the uniform distribution `U(a,b)` is equal to zero because this distribution is symmetric!

## Discrete uniform distribution

If there are finitely many outcomes and every one of them has the same probability of occurring, then we deal with the discrete uniform distribution. Formally, the probability of getting the outcome `x` reads:

`P(x) = 1 / n`,

where `n` is the number of possible outcomes.

Here are some examples:

• Tossing a (fair) coin has two possible outcomes: `heads` or `tails`. The probability of each outcome is `1/2` (or 50%).
• Drawing a particular suit from a deck of cards has four possible outcomes: ♣ ♦ ♥ ♠. The probability of each is `1/4` (or 25%).
• Rolling a (fair) die 🎲 can produce the following outcomes: ⚀, ⚁, ⚂, ⚃, ⚄, or ⚅. The probability of each outcome is `1/6` (or 16.67%).

The plot of the discrete uniform distribution consists of bars of the same height for each potential outcome.

## FAQ

### How do I calculate the expected value of uniform distribution?

The expected value of the uniform distribution `U(a,b)` is the same as its mean and is given by the following formula:

`μ = (a + b) / 2`.

Note, that this is precisely the midpoint of the interval `[a,b]`.

### How do I calculate the median of uniform distribution?

The median and mean of uniform distribution are equal because this distribution is symmetric. Thus, we have the following formula:

`median = (a + b) / 2`.

### How do I calculate the standard deviation of uniform distribution?

To obtain the standard deviation of the uniform distribution `U(a,b)`, you need to take the square root of its variance. Consequently, the formula for standard deviation reads:

`σ = (b - a) / √12`

### Is uniform distribution the same as normal distribution?

No, these are different distributions! In the normal distribution, the outcomes closer to the average are more likely to occur than those farther from the average. Its graph is shaped like a bell. In the uniform distribution, all outcomes are equally likely. The graph of uniform distribution is a rectangle.

### Is uniform distribution the same as rectangular distribution?

Yes, the uniform distribution is sometimes called the rectangular distribution. This is because the graph of uniform distribution `U(a,b)` (more precisely, of its pdf) is a rectangle drawn over the interval `[a,b]` with area equal to `1`. Hence, the height of this rectangle is equal to `1 / (b - a)`.

Anna Szczepanek, PhD
Mode
Probability calculator
Probability type
P(X ≤ x)
Parameter (a)
Parameter (b)
x
P(X ≤ x)
People also viewed…

### Linear regression

The linear regression calculator determines the coefficients of linear regression model for any set of data points.

### Meat footprint

Check out the meat impact - on the environment and your health.

### Plastic Footprint

Find out how much plastic you use throughout a year with this plastic footprint calculator. Rethink your habits, reduce your plastic waste, and make your life a little greener.

### Shannon entropy

Check out this Shannon entropy calculator to find out how to calculate entropy in information theory.