A continuous r.v. $U$ has the **Uniform distribution** on interval $(a,b)$ if the PDF of $U$ is constant over $(a,b)$ and equals $b−a1 $. We write $U∼Unif(a,b)$.

- The PDF is zero for any other intervals outside of $(a,b)$.
- We know the PDF has to integrate to 1, so this is one way we can calculate the PDF in case we forget.

Finding the CDF is also easy since the PDF is uniform over its interval. We have three cases:

$F_{U}(u)=⎩⎨⎧ 0b−a1 (u−a)=b−ax−a 1 ifu≤aifa<u<bifu≥b $## Showing the general expectation and variance

While we could integrate over the PDF to find the variance and then use LOTUS to help get the variance, we can also perform a *location-scale transformation*: if $U∼Unif(a,b)$, then let $W=a+(b−a)U$. We can show that $W∼Unif(a,b)$ as well because it has the same CDF.

By LOE, the Expectation is given by $E(W)=a+(b−a)⋅E(U)=a+2b−a =2a+b $.

Using the definition of Variance, we have $Var(W)=(b−a)_{2}Var(U)=12(b−a)_{2} $.

## MGF

To calculate the MGF, apply LOTUS. We have

$M_{U}(t)=E(e_{tU})=b−a1 ∫_{a}e_{tu}du=t(b−a)e_{tb}−e_{ta} $for $t=0$. Notice that $M_{U}(0)=1$.

## Standard Uniform distribution

Suppose $U∼Unif(0,1)$. Then we have the following properties.

- The PDF is given by $1−01 =1$. In other words, $f_{U}=1$ for all $(a,b)=(0,1)$.
- Then the expectation is given by $E(U)=∫_{−∞}u⋅f_{U}(u)du=∫_{0}udu=21 $
- Using LOTUS, we have $E(U_{2})=∫_{0}u_{2}⋅f_{U}(u)du=31 $, and by the definition of variance, we have $Var(U)=121 $.

## Universality of the Uniform

The fact that standard Uniform distributions are defined so nicely between $(0,1)$ gives us two nice results (given we meet some requirements, see below).

- We can start with a $U∼Unif(0,1)$ and
*transform*$U$ into a r.v. $X$ that has any continuous distribution. This is called**inverse transform sampling**and is commonly use to generate pseudorandom numbers (e.g. sampling rays to calculate the LTE). - We can also start with any continuous r.v. $X$ and transform it into a $Unif(0,1)$ r.v. $U$. This is called the
**probability integral transform**.

In particular, let $F$ be a CDF that is *strictly increasing* on the support of its r.v.

- Then, $F$ is a 1-to-1 function that maps the support to a value between $(0,1)$. Furthermore, $F_{−1}$ maps $(0,1)$ to $R$.
- This allows us to create a r.v. $X=F_{−1}(U)$ that has a CDF $F$.

We can also do it in reverse: let $X$ be a r.v. with a continuous CDF $F$ that is *strictly increasing* on the support of $X$. Then, the r.v. $Y=F(X)$ has the $Unif(0,1)$ distribution.

- Remember that $F(X)$ is a transformation of random variables. We map the support of $X$ to $F(X)$ using function $F$, which is
*also*the CDF of $X$.