# Continuous Random Variables

A continuous random variable can take any value within an interval and is generally a measured (rather than a counted) quantity.

# Probability Density Functions

A probability density function, or a continuous probability function, describes the distribution of a continuous random variable. Unlike the discrete (unconnected) points for discrete random variables, the graph of a probability density function is a curve. The probability that $$X$$ takes a value in the interval $$[a,b]$$ is equal to the area under the graph of $$y = f(x)$$ between $$x = a$$ and $$x = b$$. Mathematically: $\Pr(a \leqslant X \leqslant b) = \int_{a}^{b} f(x) \, dx\\$ For continuous probability we must think of ranges, in fact, the probability of $$X$$ taking any exact value is zero:
$$Pr(X = a) = 0$$
Thus, $$\Pr(a \leqslant X \leqslant b) = \Pr(a < X \leqslant) = \Pr(a \leqslant X < b) = \Pr(a < X < b) = \int_{a}^{b} f(x) \, dx$$
For all continuous probability functions, $$f(x) \geqslant 0$$ for all values of $$x$$ and $$\int_{-\infty}^{\infty} f(x) \, dx =1$$

\text{Example 11.1: A continuous random variable, } X \text{, has the probability density function:}\\ f(x) = \begin{cases} k(x-5)^2 & 0 \leqslant x \leqslant 5 \\ 0 & \text{otherwise}\\ \end{cases}\\ \text{Find the value of } k \text{ and hence find } \Pr(1 < x <3)\\ \text{} \\ \text{} \\ \text{The area under the curve must equal 1} \\ \begin{aligned} \int_{0}^{5} f(x) \, dx &= 1\\ \int_{0}^{5} k(x-5)^2 \, dx &= 1\\ k [\frac{(x-5)^3}{3}]_{0}^{5} &= 1\\ k ( \frac{(5-5)^3}{3} - \frac{(0-5)^3}{3} )&= 1\\ k (0 - (-\frac{125}{3})) &= 1\\ k &= \frac{3}{125}\\ \text{ }\\ \text{ }\\ \Pr(1 < x <3) &= \int_{1}^{3} f(x) \,dx\\ &= \frac{3}{125} [\frac{(x-5)^3}{3}]_{1}^{3}\\ &= \frac{3}{125} (\frac{(3-5)^3}{3} - \frac{(1-5)^3}{3})\\ &= \frac{3}{125} (-\frac{8}{3} - (-\frac{64}{3}))\\ &= \frac{3}{125} \times \frac{56}{3} \\ &= \frac{56}{125}\\ \end{aligned}\\

Sometimes, one of the bounds is infinity. An example on how to deal with this is given below.

\text{Example 11.2: Show that }f(x)\text{ is a probability density function.}\\ f(x) = \begin{cases} \frac{1}{(x+1)^2} & 0 \leqslant x \\ 0 & \text{ otherwise }\\ \end{cases}\\ \text{ }\\ \text{ }\\ \frac{1}{(x+1)^2} = (\frac{1}{x+1})^2\\ \text{Thus, } f(x) \geqslant 0 , \, x \in \mathbb{R}\\ \text{ }\\ \begin{aligned} \int_{0}^{\infty} f(x) \,dx &= \int_{0}^{\infty} (x+1)^{-2} \,dx\\ &= \lim_{k \to \infty} [-(x+1)^{-1}]_{0}^{k}\\ &= \lim_{k \to \infty} (-(k+1)^{-1} - (-(0+1)^{-1}))\\ &= \lim_{k \to \infty} (-(k+1)^{-1} + 1)\\ &= 1 \text{ (with CAS)} \\ \end{aligned}\\ \text{Because } f(x) \geqslant 0 \text{ for all values of } x \text{ and } \int_{-\infty}^{\infty} f(x) \, dx =1 \\ \text{Therefore, } f(x) \text{ is a probability density function.}

# Mean, Variance and Standard Deviation

The mean, variance and standard deviations are calculated in the same way as we did for discrete random variables (even though they may look different as we are dealing with integrals).

\begin{aligned} E(X) &= \int_{-\infty}^{\infty} x \cdot f(x) \, dx \\ Var(X) &= E(X^2) - [E(X)]^2 = \int_{-\infty}^{\infty} x^2 \cdot f(x) \, dx - (\int_{-\infty}^{\infty} x \cdot f(x) \, dx)^2 \\ sd(X) &= \sqrt{Var(X)} \end{aligned}

\text{Example 11.3: A continuous random variable, } X \text{, has the probability density function:}\\ \text{ }\\ f(x) = \begin{cases} \frac{3}{125}(x-5)^2 & 0 \leqslant x \leqslant 5 \\ 0 & \text{otherwise}\\ \end{cases}\\ \text{ }\\ \text{Find the mean, variance and standard deviation of the probability density function}\\ \text{ }\\ \begin{aligned} E(X) &=\int_{-\infty}^{\infty} x \cdot \ f(x) \, dx \\ &= \int_{0}^{5} \frac{3}{125} x \cdot (x-5)^2 \, dx\\ &= \int_{0}^{5} \frac{3}{125}(x^3-10x^2+25x), dx\\ &= \frac{3}{125} [\frac{x^4}{4}-\frac{10x^3}{3}+\frac{25x^2}{2}]_{0}^{5}\\ &= \frac{3}{125} (\frac{5^4}{4}-\frac{10 \cdot 5^3}{3}+\frac{25 \cdot 5^2}{2} - ( \frac{0^4}{4}-\frac{10 \cdot 0^3}{3}+\frac{25 \cdot 0^2}{2}))\\ &= \frac{3}{125} \cdot \frac{625}{12}\\ &=\frac{5}{4}\\ \text{ }\\ E(X^2) &=\int_{-\infty}^{\infty} x^2 \cdot \ f(x) \, dx \\ &= \int_{0}^{5} \frac{3}{125} x^2 \cdot (x-5)^2 \, dx\\ &= \int_{0}^{5} \frac{3}{125}(x^4-10x^3+25x^2), dx\\ &= \frac{3}{125} [\frac{x^5}{5}-\frac{10x^4}{4}+\frac{25x^3}{3}]_{0}^{5}\\ &= \frac{3}{125} (\frac{5^5}{5}-\frac{10 \cdot 5^4}{4}+\frac{25 \cdot 5^3}{3} - ( \frac{0^5}{5}-\frac{10 \cdot 0^4}{4}+\frac{25 \cdot 0^3}{3}))\\ &= \frac{3}{125} \cdot \frac{625}{6}\\ &= \frac{5}{2}\\ \text{ }\\ Var(X) &= E(X^2) - [E(X)]^2\\ &= \frac{5}{2} - (\frac{5}{4})^2\\ &= \frac{5}{2} - \frac{25}{16}\\ &= \frac{15}{16}\\ \text{ }\\ sd(X) &= \sqrt{Var(X)}\\ &= \sqrt{\frac{15}{16}}\\ &= \frac{\sqrt{15}}{4}\\ \end{aligned}\\

# Percentiles

The median, m, is the value of X such that: $\int_{-\infty}^{m} f(x) \,dx = 0.5$ To find other percentiles, such as the 25th percentile, or 75th percentile (25th to 75th percentile represents the interquartile range - IQR) simply change what the integral equals to reflect the percentile we are interested in. That is, if we are after the 25th percentile, set the integral equal to 0.25 and solve for $$m$$.

\text{Example 11.3 A continuous random variable, } X \text{, has the probability density function:}\\ \text{ }\\ f(x) = \begin{cases} \frac{3}{125}(x-5)^2 & 0 \leqslant x \leqslant 5 \\ 0 & \text{otherwise} \end{cases}\\ \text{ }\\ \text{Find the interquartile range, correct to 2 decimal points}\\ \text{ }\\ \begin{aligned} 0.25 &= \int_{-\infty}^{a} f(x) \,dx\\ &= \int_{0}^{a} \frac{3}{125}(x-5)^2 \,dx \\ &= \frac{3}{125} [ \frac{(x-5)^3}{3} ]_{0}^{a}\\ &= \frac{3}{125} (\frac{(a-5)^3}{3} - \frac{(0-5)^3}{3}) \\ a &= 0.46\\ \text{ }\\ 0.75 &= \int_{0}^{b} \frac{3}{125}(x-5)^2 \,dx \\ &= \frac{3}{125} [ \frac{(x-5)^3}{3} ]_{0}^{b}\\ &= \frac{3}{125} (\frac{(b-5)^3}{3} - \frac{(0-5)^3}{3}) \\ b &= 1.85\\ \text{ }\\ \text{IQR } &= [0.46, 1.85]\\ \end{aligned}\\ \text{ }\\