Expected values


Example

Find the center of mass of the bars

## Loading required package: MASS

plot of chunk unnamed-chunk-1


Using manipulate

library(manipulate)
myHist <- function(mu){
  hist(galton$child,col="blue",breaks=100)
  lines(c(mu, mu), c(0, 150),col="red",lwd=5)
  mse <- mean((galton$child - mu)^2)
  text(63, 150, paste("mu = ", mu))
  text(63, 140, paste("Imbalance = ", round(mse, 2)))
}
manipulate(myHist(mu), mu = slider(62, 74, step = 0.5))

The center of mass is the empirical mean

hist(galton$child, col = "blue", breaks = 100)
meanChild <- mean(galton$child)
lines(rep(meanChild, 100), seq(0, 150, length = 100), col = "red", lwd = 5)

plot of chunk lsm


Example

plot of chunk unnamed-chunk-2


Example


Continuous random variables


Example


Rules about expected values


Example


Example

  1. Let \( X_i \) for \( i=1,\ldots,n \) be a collection of random variables, each from a distribution with mean \( \mu \)
  2. Calculate the expected value of the sample average of the \( X_i \) \[ \begin{eqnarray*} E\left[ \frac{1}{n}\sum_{i=1}^n X_i\right] & = & \frac{1}{n} E\left[\sum_{i=1}^n X_i\right] \\ & = & \frac{1}{n} \sum_{i=1}^n E\left[X_i\right] \\ & = & \frac{1}{n} \sum_{i=1}^n \mu = \mu. \end{eqnarray*} \]

Remark


The variance

\[ Var(X) = E[(X - \mu)^2] \]

the expected (squared) distance from the mean



Example


Example


Interpreting variances


Example


Example