3.8 Continous Random Variables
A random variable is continuous when it takes on any value in a uncountable set.
Example 3.31 (Continuous random variable) From Example 2.9, \(\Omega = \lbrace t \in \mathbb{R} : 0 < t \le T \rbrace\). Suppose you are interested in evaluating \(T\): ‘age of adults between 18 and 35 years old’. One can represent \(R_{T} = \lbrace t \in \mathbb{R}: 18 \le t \le 35 \rbrace\), with \(T\) being a continuous random variable since \(|R_{T}| = + \infty\). \(\\\)
Let \(X\) be a continuous random variable. As it is not possible to list all the elements of \(R_{X}\), the notation \(p(x)\) loses its meaning, since \(p(x)\) is zero for all \(x\). Thus, to deal with the calculation of probabilities with continuous random variables, \(f(x)\) will be used instead of \(p(x)\). Thus, for each point of \(R_{X}\) there is associated a probability density function (pdf) \(f(x)\), satisfying
\[\begin{equation} f(x) \ge 0, \forall \; x \tag{3.66} \end{equation}\]
\[\begin{equation} \int_{x} f(x)\;dx = 1 \tag{3.67} \end{equation}\]
\[\begin{equation} Pr(a \leq X \leq b) = \int_{a}^{b} f(x)\;dx \tag{3.68} \end{equation}\]
The cumulative distribution function (cdf) \(F\) of a continuous r.v., is defined as
\[\begin{equation} F(x) = Pr(X \leq x) = \int_{-\infty}^x f(t) \;dt \tag{3.69} \end{equation}\]
Note that \(f(x)=F'(x)\), \(Pr(X=x)=0\) and \(Pr(X \le x) = Pr(X < x)\).
Example 3.32 (cdf) Suppose a r.v. \(X\): ‘height of PUCRS students’ with pdf \[ f(x) = -\dfrac{46875}{19652} (x^{2} - 3.36x + 2.36), \;\; x \in \left[ 1.00,2.36 \right]. \] By (3.69), the cumulative distribution function of \(X\) is
\[\begin{align*} F(x) =& Pr(X \leq x) \nonumber \\ =& -\dfrac{46875}{19652} \int_{1}^{x} (t^{2} - 3.36t + 2.36) \;dt \nonumber \\ =& -\dfrac{46875}{19652} \left[ \frac{t^{3}}{3} - \frac{3.36t^{2}}{2} + 2.36t \right] \bigg\rvert_{1}^{x} \nonumber \\ =& -\dfrac{46875}{19652} \left( \left[ \frac{x^{3}}{3} - 1.68x^{2} + 2.36x \right] - \left[ \frac{1^{3}}{3} - 1.68 \times 1^{2} + 2.36 \times 1 \right] \right) \nonumber \\ F(x) =& -\dfrac{46875}{19652} \left[ \frac{x^{3}}{3} - 1.68x^{2} + 2.36x - \frac{76}{75} \right] \nonumber \end{align*}\]
Example 3.33 (Probability with continuous r.v.) Suppose again the r.v. from Example 3.32. Applying (3.68), \[ Pr(1.45 \leq X \leq 1.72) = -\dfrac{46875}{19652} \int_{1.45}^{1.72} (x^{2} - 3.36x + 2.36) \;dx = F(1.72) - F(1.45) \approx 0.2881. \]
Exercise 3.18 What property is being checked in the code below? What does it indicate?
## 1 with absolute error < 1.1e-14
Exercise 3.19 Write a function in R that represents \(F(x)\) in Example 3.32.
3.8.1 Expected value
The expected value of a countinous random variable \(X\) is given by
\[\begin{equation} E(X) = \int_{x} x \cdot f(x)\;dx \tag{3.70} \end{equation}\]
the expected value of a function \(g(X)\) is given by \[\begin{equation} E(g(X)) = \int_{x} g(x) \cdot f(x)\;dx \tag{3.71} \end{equation}\]
Example 3.34 (Expected value of continuous r.v. \(X\) and \(X^2\)) From the Example 3.33 one can calculate \[ E(X) = -\dfrac{46875}{19652} \ int_{1.00}^{2.36} x \; (x^{2} - 3.36x + 2.36) \;dx = 1.68. \] This result was expected given the symmetry of the distribution (parabolic). Note that \((1.00+2.36)/2 = 1.68\). The expected value of \(g(X) = X^2\) is given by \[ E(X^2) = -\dfrac{46875}{19652} \int_{1.00}^{2.36} x^2 \; (x^{2} - 3.36x + 2.36) \;dx = 2.91488. \]
Exercise 3.20 Carry out the calculations indicated in Example 3.34. \(\\\)
3.8.2 Variance and standard deviation
The variance of a continuous random variable \(X\) is given as in the discrete case indicated by Eq. (3.46). Likewise, the standard deviation is the square root of the variance, as indicated in Eq. (3.47).
Example 3.35 (Variance and standard deviation of a continuous r.v.) From the Example 3.34 it can be calculated \[ V(X) = 2.91488 - 1.68^2 = 0.09248 \] \[ D(X) = \sqrt{0.09248} \approx 0.30411 \]