---
title: "Chapter 4.2 Expected value and 4.3 Variance of a continuous random variable"
author: "Name"
output: pdf_document
---

# Expected Value

### Example: Jail time
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. 



### You try it
Find the expected value for the following p.d.f.; $f(x)=2x$ for $0<x<1$.



# Expected Value of Functions of Random Variables

### Example
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. 

a) using $f(w)$ directly 


b) using theorem 4.2 $E(Y^2)$



### You try it
1. Suppose that the p.d.f. of a random variable $X$ with a continuous distribution is $f(x)=2x$ for $0<x<1$. Find the expectation of $1/X$.Do this by hand, confirming your results using R.




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.








\newpage

# Variance
Just like for discrete variables, the variance and the standard deviation measures the spread of the random variable around its mean. The formulas remain unchanged for the continuous random variable.


### Example
Find the variance of the random variable $Y$, where $f_{Y}(y)=3(1-y)^{2},0<y<1$





### You try it
A random variable $Y$ is described by the pdf $f_{Y}(y)=2y$ for $0\leq y\leq 1$. What is the standard deviation of $3Y+2$



