Uniform distribution may refer to discrete uniform distribution or continuous uniform distribution. It is a distribution that has constant probability and is known as a rectangular distribution. The distribution is abbreviated as U(a, b).
When the distribution is equally spaced and when the probability density is same at any point, the uniform distribution is called ‘discrete uniform distribution’. The other type of continuous distribution is a case where the variable can be assigned with infinite number of values known as continuous uniform distribution.
Examples : Generation of random numbers, time of occurrence in a particular interval etc.,

Listed below are few properties of uniform distribution:
1) Let a and b are the two parameters of the distribution. The distribution is called uniform distribution on (a, b) since it assumes a constant value for all x in (a, b).

2) The distribution is also known as rectangular distribution, since the curve y = f(x) describes a rectangle over the x axis and between the ordinates at x = a and x = b.

3) A uniform or rectangular variate X on the interval (a, b) is written as :

X $\sim$ U[a, b]  or X $\sim$ R [a, b]

4) The cumulative distribution function $F(x)$ is given by:

$F(x)$ = $\left\{\begin{matrix}
0, x \leq a\\
\frac{x-a}{b-a}, a < x < b\\
1, x \geq b
\end{matrix}\right.$

Since $F(x)$ is not continuous at x = a and x = b, it is not differentiable at these points.

$\frac{d}{dx}$ $F(x)$ = $f(x)$ = $\frac{1}{b - a }$ $\neq$ 0, exists everywhere except at the points x = a and x = b and the pdf $f(x)$ is

$f(x ; a, b)$= $\left\{\begin{matrix}
\frac{1}{b - a }, if\ a < x < b\\

0, otherwise\end{matrix}\right.$

5) For a uniform variate X in (-a, a) the pdf is given by
$f(x)$ = $\left\{\begin{matrix}
\frac{1}{2a}, -a < x < a\\

0, otherwise\end{matrix}\right.$
The formula for mean and variance of continuous uniform distribution are described below:
Mean value of this distribution is $\frac{(a + b)}{2}$

The variance of this distribution is $\frac{(b - a)^{2}}{12}$
Where a and b are the two parameters of the distribution.
Probability density function of uniform distribution  is defined as :

$f(x)$ = $\left\{\begin{matrix}
\frac{1}{b-a} & a<x<b \\
0 & otherwise
\end{matrix}\right.$

a and b are the parameters of the uniform distribution.

If a random variable X admits a uniform density function, then X is said to be uniformly distributed or X has the uniform distribution.
A probability density function is a function f defined on an interval (a, b) and should have the following properties.
a) $f(x)$  $\geq$ 0 for every x

b) $\int_{a}^{b}$ f(x)dx = 1
A discrete uniform is the simplest type of all the probability distributions.
Discrete uniform distribution is known as the equally likely outcomes distribution and the shorthand X $\sim$ discrete U(a, b) is used to indicate that the random variable X has the discrete uniform distribution with integer parameters a and b, where a < b. A discrete uniform random variable X with parameters a and b has probability mass function $f(x)$ = $\frac{1}{b - a + 1}$     for x = a, a + 1, ............., b

Here each of the n values in its range say x$_{1}$, x$_{2}$,........, x$_{n}$ has equal probability.

Then f(x$_{i}$) = $\frac{1}{n}$

Here n is known as the parameter of the distribution and lies in the set of all positive integers.
f(x) represents the probability mass function. This distribution is appropriate for a die experiment and for an experiment with a deck of cards.

Example : Suppose we throw a die. Let X be the random variable denoting what number is thrown.

Then we have output like, P(X = 1) = $\frac{1}{6}$, P(X = 2) = $\frac{1}{6}$ etc.

In fact, P(X = x) = $\frac{1}{6}$  for all x between 1 and 6. Hence we have a uniform distribution.
The continuous uniform distribution is the probability distribution of random numbers from the continuous interval between a and b.
Its density function is defined by the following.
When a $\leq$ x $\leq$ b

=> $f(x)$ = $\frac{1}{b - a}$

when x < a or x > b

=> f(x) = 0
If a continuous random variable X can assume any value in the interval a $\leq$ x $\leq$ b and only these values, and if its probability density function f(x) is constant over that interval and equal to zero, then X is said to be uniformely distributed and its distribution is called a continuous uniform probability distribution.

The pdf of continuous uniform distribution is shown in the graph below:
Continous Uniform Distribution
Examples of uniform distribution is given below :
Example 1 : If X is uniformly distributed with mean 1 and variance $\frac{4}{3}$, find P(X < 0)

Solution : Let X $\sim$ U[a, b] so that

$p(x)$ = $\frac{1}{b - a}$, a < x < b

Given : Mean = $\frac{1}{2}$(b + a) = 1
b + a = 2

Var (X) = $\frac{1}{12}$ (b - a)$^{2}$ = $\frac{4}{3}$

b - a = $\pm$ 4

On solving we get a = -1 and b = 3 => (a < b)

p(x) = $\frac{1}{4}$; -1 < x < 3

P(X < 0) =  $\int_{-1}^{0}$ p(x) dx 

= $\frac{1}{4}$ |x|$_{-1}^{0}$  

= $\frac{1}{4}$


Example 2 : If X is a random variable with a continuous distribution function F, then prove that F(X) has a uniform distribution on [0, 1].
Prove that P[ a $\leq$ F(x) $\leq$ b] = b - a, 0 $\leq$ (a, b) $\leq$ 1


Solution : Since F is a distribution function, it is non-decreasing. Let Y = F(X)

Then the distribution function G of Y is given by:

G$_{Y}$(y) = P(Y $\leq$ y)

= P [F(X) $\leq$ y]

= P [ X $\leq$  F$^{-1}$(y)]

Inverse of function exists since F is non decreasing and given to be continuous.

G$_{Y}$(y) = F[F$^{-1}$(y)]

since F is the distribution function of X.

Thus G$_{Y}$(y) = y

Therefore the pdf of Y = F(X) is given by ;

g$_{Y}$(y) = $\frac{d}{dy}$[G$_{Y}$(y)] =  1

Since F is a distribution function Y = F(X) takes the value in the range [0, 1].

Hence g$_{Y}$(y) = 1, 0 $\leq$ y $\leq$ 1

Y is a uniform variate on [0, 1].

Since Y = F(X)  $\sim$ U[0, 1]

P[ a $\leq$ F(X) $\leq$ b] = P(a $\leq$ Y $\leq$ b]

= $\int_{a}^{b}$ g(y) dy

= $\int_{a}^{b}$ 1. dy

= |y|$_{a}^{b}$

= b - a