Page 363 ###12 Test your conclusions in Exercise 11 by computer simulation. First choose 364 numbers Xi with density f(x) = normal(x, 0, 1/4). Now form the sum Y365 = 100 + X1 + X2 + … + X364, and repeat this experiment 200 times.Make up a bar graph on [50, 150] of the results, superimposing the graph of the approximating normal density. What does this graph say about your answers in Exercise 11?
Answer:Given \(\mu\)= 0 and \({ \delta }^{ 2 }\)= 1/4, I get In (a) Yn>= 100, n=364
set.seed(2802)
y <- replicate(200, {
y365 <- 100+sum(rnorm(364,0,0.5))})
sum(y>=100)/200
## [1] 0.515
h<-hist(y, breaks=20, col="red", xlab="Prices on 365th Day",
main="Histogram with Normal Curve")
xfit<-seq(min(y),max(y),length=150)
yfit<-dnorm(xfit,mean=mean(y),sd=sd(y))
yfit <- yfit*diff(h$mids[1:2])*length(y)
lines(xfit, yfit, col="blue", lwd=2)
In (b) Yn>= 110, n=364
sum(y>=110)/200
## [1] 0.17
h<-hist(y, breaks=20, col="blue", xlab="Prices on 365th Day",
main="Histogram with Normal Curve")
xfit<-seq(min(y),max(y),length=150)
yfit<-dnorm(xfit,mean=mean(y),sd=sd(y))
yfit <- yfit*diff(h$mids[1:2])*length(y)
lines(xfit, yfit, col="yellow", lwd=2)
In (c) Yn>= 120, n=364
sum(y>=120)/200
## [1] 0.025
h<-hist(y, breaks=20, col="yellow", xlab="Prices on 365th Day",
main="Histogram with Normal Curve")
xfit<-seq(min(y),max(y),length=150)
yfit<-dnorm(xfit,mean=mean(y),sd=sd(y))
yfit <- yfit*diff(h$mids[1:2])*length(y)
lines(xfit, yfit, col="red", lwd=2)