# Expectation of Continuous Uniform Distribution

## Theorem

Let $X \sim \ContinuousUniform a b$ for some $a, b \in \R$, $a \ne b$, where $\operatorname U$ is the continuous uniform distribution.

Then:

$\expect X = \dfrac {a + b} 2$

## Proof

From the definition of the continuous uniform distribution, $X$ has probability density function:

$\map {f_X} x = \begin {cases} \dfrac 1 {b - a} & : a \le x \le b \\ 0 & : \text {otherwise} \end {cases}$

From the definition of the expected value of a continuous random variable:

$\ds \expect X = \int_{-\infty}^\infty x \map {f_X} x \rd x$

So:

 $\ds \expect X$ $=$ $\ds \int_{-\infty}^a 0 x \rd x + \int_a^b \frac x {b - a} \rd x + \int_b^\infty 0 x \rd x$ $\ds$ $=$ $\ds \intlimits {\frac {x^2} {2 \paren {b - a} } } a b$ Primitive of Power, Fundamental Theorem of Calculus $\ds$ $=$ $\ds \frac {b^2 - a^2} {2 \paren {b - a} }$ $\ds$ $=$ $\ds \frac {\paren {b - a} \paren {b + a} } {2 \paren {b - a} }$ Difference of Two Squares $\ds$ $=$ $\ds \frac {a + b} 2$

$\blacksquare$