## Continuous Uniform Distributions

A random variable has a uniform distribution when each value of the random variable is equally likely, and values are uniformly distributed throughout some interval.

### The Formulas

If $X$ is uniformly distributed over the interval   $[a,b]$,   then the following formulas will apply.

 \begin{align} f(x) &= \dfrac{1}{b-a} \\ F_X (x) &= \dfrac{x-a}{b-a} \\ M(t) &= \dfrac{e^{tb} - e^{ta}}{t(b-a)} \\ E(X) &= \dfrac{a+b}{2} \\ Var(X) &= \dfrac{(b-a)^2}{12} \end{align}

### An Example

Consider the function   $f(x)=\dfrac19$   on the interval   $[6,15]$.   We note the following about this distribution.

• The function $f(x)$ does meet the requirements to be a PDF, since it is nonnegative everywhere, and $\int_6^{15} \dfrac19 \mathrm{d}x = \left. \dfrac19 x \right|_6^{15} = \dfrac19 (15-6) = 1$.
• The CDF is $F_X (x)=\dfrac{x-6}{15-6} = \dfrac{x-6}{9}$.
• The expected value $E(X)$ of the distribution is   $\dfrac{a+b}{2} = \dfrac{15+6}{2} = \dfrac{21}{2}$.
• The variance $Var(X)$ of the distribution is   $\dfrac{(b-a)^2}{12} = \dfrac{(15-6)^2}{12} = \dfrac{27}{4}$,   and the standard deviation is $\sigma_X = \dfrac32 \sqrt{3} \approx 2.598$.

The CDF makes it quite easy to find probabilities for this continuous uniform distribution.

• $P(x < 10) = F_X (10) = \dfrac{10-6}{9} = \dfrac49$.
• $P(7 < x < 12) = F_X(12) - F_X(7) = \dfrac{12-6}{9} - \dfrac{7-6}{9} = \dfrac59$.
• $P(x \ge 13) = 1 - F_X (13) = 1 - \dfrac{13-6}{9} = \dfrac29$.

Since the PDF of a continuous uniform distribution is a constant function, and probabilities of continuous distributions are areas under the PDF, these results could also have been found very easily with a geometric argument.

### Derivation of the Formulas

Suppose $f(x)$ is the PDF of a continuous uniform distribution on the interval   $[a,b]$.   Since a uniform distribution requires that each value of the random variable be equally likely, $f(x)$ will be a constant function. Therefore, suppose   $f(x)=c$   on the interval   $[a,b]$.   Since the definite integral of the PDF over the interval must be equal to $1$, we can solve the equation   $\int_a^b c \, \mathrm{d}x = 1$   for $c$. Working with the integral, we have

$$\int_a^b c \, \mathrm{d}x = \left. cx \right|_a^b = c(b-a) = 1$$

which gives   $c = \dfrac{1}{b-a}$.   In other words, the PDF is   $f(x) = \dfrac{1}{b-a}$.

The CDF is simply the integral of the PDF.

$$\int_a^x \dfrac{1}{b-a} \mathrm{d}t = \left. \dfrac{1}{b-a} t \right|_a^x = \dfrac{x-a}{b-a}$$

The moment generating function is the value of $E(e^{tX})$.

$$M(t) = E(e^{tX}) = \int_a^b \dfrac{e^{tx}}{b-a} \, \mathrm{d}x = \left. \dfrac{1}{(b-a)} \dfrac{e^{tx}}{t} \right|_{x=a}^b = \dfrac{e^{tb}-e^{ta}}{t(b-a)}$$

When using the moment generating function to find the expected value and the variance, quantities having the indeterminate form $\dfrac00$ are produced, which would require L'Hopital's Rule. Therefore, we obtain these directly from the algebra, beginning with the expected value.

$$\int_a^b \dfrac{1}{b-a} x \, \mathrm{d}x = \left. \dfrac{1}{2(b-a)} x^2 \right|_a^b = \dfrac{b^2-a^2}{2(b-a)} = \dfrac{(b-a)(b+a)}{2(b-a)} = \dfrac{a+b}{2}$$

We next produce a value for $E(X^2)$.

$$\int_a^b \dfrac{1}{b-a} x^2 \mathrm{d}x = \left. \dfrac{1}{3(b-a)} x^3 \right|_a^b = \dfrac{b^3-a^3}{3(b-a)} = \dfrac{(b-a)(b^2+ab+a^2)}{3(b-a)} = \dfrac{b^2+ab+a^2}{3}$$

We can then find the variance.

\begin{align} Var(X) &= E(X^2) - (E(X))^2 \\ &= \dfrac{b^2+ab+a^2}{3} - \left( \dfrac{a+b}{2} \right)^2 \\ &= \dfrac{4(b^2+ab+a^2)}{12} - \dfrac{3(a^2+2ab+b^2)}{12} \\ &= \dfrac{b^2-2ab+a^2}{12} \\ &= \dfrac{(b-a)^2}{12} \end{align}

Therefore, the standard deviation is   $\sigma_X = \dfrac{b-a}{\sqrt{12}}$.