If a random variable has a continuous distribution for which the p.d.f. is \(f\), then the expectation \(E(X)\) is defined as
\[ \mu_{X} = E(X) = \int_{-\infty}^{\infty}x*f(x)dx \]
Suppose \(X\) is the random variable that represents the prison sentence in years for persons convicted of grand theft auto and assume that \(X\) has a p.d.f. of
\[ f(x)=\frac{1}{9}x^{2} for 0<x<3 \]
What is the average length of time these people spend in jail? Calculate this by hand, and using R.
\[ E(X) = \int^{3}_{0}x*\frac{1}{9}x^{2} = \int^{3}_{0}\frac{1}{9}x^{3} = \frac{9}{4} \]
The average prison sentence for someone convicted of GTA is 2.25years.
<- function(x) {1/9*x^3}
integrand integrate(integrand,lower=0,upper=3)
## 2.25 with absolute error < 2.5e-14
Find the expected value for the following p.d.f.; \(f(x)=2x\) for \(0<x<1\).
<- function(x){2*x^2}
integrand integrate(integrand,lower=0,upper=1)
## 0.6666667 with absolute error < 7.4e-15
As in the discrete case, we can also define functions of random variables.
Let \(X\) be a continuous random variable and let \(g\) be a function.
\[ E[g(X)]=\int g(x)f(x)dx \]
The expected value for \(g(x)\) a function of X, is the integral of the multiplication of the function of x, times the pdf.
This is the same process as what we did for the discrete case.
Let \(Y\) have probability density function \(f_{Y}(y)=2(1-y), 0\leq y\leq 1\). Suppose that \(W=Y^{2}\), and the pdf of \(W\) is
\[ f_{W}(w)=\frac{1}{\sqrt{w}}-1,0\leq w\leq1 \]
Find \(E(W)\) a) using \(f(w)\) directly, and b) using theorem 4.2. Confirm both using R.
\[ E(W) = \int^{1}_{0}w*(\frac{1}{\sqrt{w}}-1)\ dw \\ = \int^{1}_{0} w^{1/2} - w\ dw \\ = \frac{2}{3}w^{3/2}\biggr|_{0}^{1} - \frac{1}{2}w^{2}\biggr|_{0}^{1} \\ = \frac{2}{3} - \frac{1}{2} = \frac{1}{6} \]
<- function(w){w*(1/sqrt(w)-1)}
integrand integrate(integrand,lower=0,upper=1)
## 0.1666667 with absolute error < 9.3e-05
\[ E(W) = E(Y^{2}) = \int^{1}_{0} y^{2} * 2(1-y)\ dy \\ = 2\int^{1}_{0} y^{2} -y^{3}\ dy \\ = 2 [ \frac{y^3}{3} - \frac{y^4}{4}\bigg|_{0}^{1} ] \\ = \frac{2}{3} - \frac{1}{2} = \frac{1}{6} \]
<- function(y){y^2*(2*(1-y))}
integrand integrate(integrand,lower=0,upper=1)
## 0.1666667 with absolute error < 1.9e-15
\[ E(1/x) = \int \frac{1}{x} f(x)\ dx \\ = \int_{0}^{1} = \frac{1}{x} 2x\ dx \\ = \int_{0}^{1} 2\ dx = 2\\ \]
<- function(x){(2*x)/x}
integrand integrate(integrand,lower=0,upper=1)
## 2 with absolute error < 2.2e-14
2 Grades on the last test were not very good. Their distribution is as follows:
\[ f(y)=\frac{1}{5000}(100-y) \]
for \(0\leq y\leq 100\).
As a way of curving the results, the professor announces that he will replace each person’s grade, \(Y\), with a new grade \(g(Y)\) where \(g(Y)=10\sqrt{Y}\). Will the professor’s strategy be successful in raising the class average above 60? Write down the equation, then use R to calculate the value.
\[ E(g(Y)) = \int g(y)f(y) = \int_{0}^{100} 10\sqrt(y) \frac{1}{5000}(100-y)dy \]
<- function(y) {10*sqrt(y)*((1/5000)*(100-y))}
apply.curve integrate(apply.curve,lower=0,upper=100)
## 53.33334 with absolute error < 0.0056
No - the expected value for the class average is still below 60.