#-----------------------------------------------------# #--- Classical and Bayesian inference (AMS132) ---# #--- Class 13 ---# #-----------------------------------------------------# # Chi square distribution: curve(dchisq(x, df=1), 0, 10, lwd=3) curve(dchisq(x, df=2), 0, 10, lwd=3, add=TRUE, col="blue") curve(dchisq(x, df=3), 0, 10, lwd=3, add=TRUE, col="red") curve(dchisq(x, df=4), 0, 10, lwd=3, add=TRUE, col="green") curve(dchisq(x, df=10), 0, 10, lwd=3, add=TRUE, col="magenta") # Lactic acid concentration in cheese # a) pchisq(10*0.3^2/0.09, df=10) curve(dchisq(x, df=10), 0, 30, lwd=3) abline( v=10*0.3^2/0.09, col="red", lwd=3) polygon(c(0,seq(0,10*0.3^2/0.09, len=10),10), c(0,dchisq(seq(0,10*0.3^2/0.09, len=10), df=10),0), col="blue") # b) n <- 10 sigma <- sqrt(0.09) pnorm(0.1*sqrt(n)/sigma, 0, 1) - pnorm(-0.1*sqrt(n)/sigma, 0, 1) curve(dnorm(x, 0, 1), -5,5, lwd=3) abline(v=c(-0.1*sqrt(n)/sigma, 0.1*sqrt(n)/sigma), lwd=3, col="red") sec <- seq(-0.1*sqrt(n)/sigma,0.1*sqrt(n)/sigma, len=10) polygon(c(sec[1],sec,sec[10]), c(0,dnorm(sec, 0,1),0), col="blue")