Asymptotics


Numerical limits


Limits of random variables


The Law of Large Numbers


Law of large numbers in action

n <- 10000; means <- cumsum(rnorm(n)) / (1  : n)
plot(1 : n, means, type = "l", lwd = 2, 
     frame = FALSE, ylab = "cumulative means", xlab = "sample size")
abline(h = 0)
plot of chunk unnamed-chunk-1

Discussion


The Central Limit Theorem


Example


Simulation of mean of \( n \) dice

plot of chunk unnamed-chunk-2

Coin CLT


plot of chunk unnamed-chunk-3

CLT in practice


Confidence intervals


Give a confidence interval for the average height of sons

in Galton's data

library(UsingR);data(father.son); x <- father.son$sheight
(mean(x) + c(-1, 1) * qnorm(.975) * sd(x) / sqrt(length(x))) / 12
[1] 5.710 5.738

Sample proportions


Example

round(1 / sqrt(10 ^ (1 : 6)), 3)
[1] 0.316 0.100 0.032 0.010 0.003 0.001

Poisson interval


R code

x <- 5; t <- 94.32; lambda <- x / t
round(lambda + c(-1, 1) * qnorm(.975) * sqrt(lambda / t), 3)
[1] 0.007 0.099
poisson.test(x, T = 94.32)$conf
[1] 0.01721 0.12371
attr(,"conf.level")
[1] 0.95

In the regression class

exp(confint(glm(x ~ 1 + offset(log(t)), family = poisson(link = log))))
  2.5 %  97.5 % 
0.01901 0.11393