manyspikes

More continuous random variables

Initialising environment...

In the previous section, we introduced continuous random variables and the most pervasive probability distribution: the Gaussian distribution. In this section, we will look at other commonly used continuous probability distributions: the Uniform, Exponential and Laplace distributions.

Uniform distribution

The uniform distribution is a distribution that assigns equal density to all values in an interval (a,b)(a, b). Its probability density function is given by:

f(xa,b)={1baif axb0otherwise\begin{equation} f(x|a,b) = \left\{ \begin{array}{ll} \frac{1}{b-a} & \textrm{if }\, a \le x \le b \\ 0 & \textrm{otherwise} \\ \end{array} \right. \end{equation}

The CDF for the uniform distribution can be analytically derived by integrating f(x)f(x):

F(xa,b)={0if x<axabaif axb1if x>b\begin{equation} F(x|a,b) = \left\{ \begin{array}{ll} 0 & \textrm{if }\, x \lt a \\ \frac{x-a}{b-a} & \textrm{if }\, a \le x \le b \\ 1 & \textrm{if }\, x \gt b \\ \end{array} \right. \end{equation}

Let's visualise the PDF and CDF:

Play around with the values of aa and bb to see how the distribution changes. Pay attention to the values of the PDF: how do they change as you change the width of the interval (a,b)(a, b). For instance, set a=1.25a=1.25 and b=1.75b=1.75 and visualise the PDF. Do the values of the PDF make sense to you? If not, remember that the PDF expresses probability density and not probability itself!

The uniform distribution has the following properties:

  • Mean: ba2\frac{b-a}{2}
  • Median: ba2\frac{b-a}{2}
  • Mode: All values in (a,b)(a, b), since all of them are equiprobable and greater than 0
  • Variance: 112(ba)2\frac{1}{12}(b-a)^2

Exponential distribution

The exponential distribution is a single parameter distribution with the following PDF:

f(xλ)={λeλxif x00otherwise\begin{equation} f(x|\lambda) = \left\{ \begin{array}{ll} \lambda e^{-\lambda x} & \textrm{if }\, x \ge 0 \\ 0 & \textrm{otherwise} \\ \end{array} \right. \end{equation}

Just like the uniform distribution, we can easily arrive at the CDF by integrating the PDF. For x0x \ge 0:

F(xλ)=xf(yλ)dy=0xf(yλ)dy=0xλeλydy=λ(0xeλydy)=λ(1λeλx(1λeλ×0))=1eλx\begin{align} F(x|\lambda) &= \int_{-\infty}^x f(y|\lambda)\,\text{d}y = \int_0^x f(y|\lambda)\,\text{d}y\\[3 ex] &= \int_0^x \lambda e^{-\lambda y}\,\text{d}y\\[3 ex] &= \lambda \left(\int_0^x e^{-\lambda y}\,\text{d}y \right)\\[3 ex] &= \lambda \left( -\frac{1}{\lambda} e^{-\lambda x} - \left( -\frac{1}{\lambda} e^{\lambda \times 0} \right) \right)\\[3 ex] &= 1 - e^{-\lambda x} \end{align}

For x<0x<0, F(x)=0F(x) = 0 so the full CDF can be represented as:

F(xλ)={0if x<a1eλxif x0\begin{equation} F(x|\lambda) = \left\{ \begin{array}{ll} 0 & \textrm{if }\, x \lt a \\ 1 - e^{-\lambda x} & \textrm{if }\, x \ge 0 \\ \end{array} \right. \end{equation}

Let's visualise:

The exponential distribution has the following properties:

  • Mean: 1λ\frac{1}{\lambda}
  • Median: ln2λ\frac{\ln 2}{\lambda}
  • Mode: 0
  • Variance: 1λ2\frac{1}{\lambda^2}

Laplace distribution

The Laplace distribution is a double-sided version of the exponential distribution. Its PDF is defined as follows:

f(xμ,b)=12bexp(xμb)\begin{equation} f(x|\mu, b) = \frac{1}{2b} \exp \left(- \frac{|x-\mu|}{b} \right) \end{equation}

Relative to the exponential distribution, you can see that:

  • A new parameter μ\mu has been introduced to offset the values of xx. This allows us to shift the distribution along the xx axis
  • The parameter λ\lambda has been replaced by the inverse of the parameter bb
  • The exponential is applied to absolute values of xμx - \mu. This causes the distribution to be mirrored relative to μ\mu.

Let's quickly visualise its PDF:

Its main properties are:

  • Mean: μ\mu
  • Median: μ\mu
  • Mode: μ\mu
  • Variance: 2b22b^2