#Math 480 R homework #The easiest way to get M480pack.txt is to copy and paste the following #command into R. source("http://parker.ad.siu.edu/Olive/M480pack.txt") #HW4 6a) qnorm(p=0.9,mean=100,sd=15) #HW4 6b) qnorm(p=0.99,mean=100,sd=15) #HW7 8a) #From Olive (2014, 8.1). #The following commands will plot 4 histograms #with n =1, 5, 25 and 200. Save the plot in Word. z1 <- cltsim(n=1) z5 <- cltsim(n=5) z25 <- cltsim(n=25) z200 <- cltsim(n=200) par(mfrow=c(2,2)) hist(z1$ybar) hist(z5$ybar) hist(z25$ybar) hist(z200$ybar) #click on R console and hit enter if necessary #HW7 8b) z1 <- cltsim2(n=1) z5 <- cltsim2(n=5) z25 <- cltsim2(n=25) z200 <- cltsim2(n=200) par(mfrow=c(2,2)) hist(z1$ybar,breaks="Scott") hist(z5$ybar,breaks="Scott") hist(z25$ybar,breaks="Scott") hist(z200$ybar,breaks="Scott") par(mfrow=c(1,1)) #HW8 6) rwalk(n=100,type=3,y0=1) #HW8 7) poisprocess(n=100, rate=1) #HW9 3a) c1 <- c(0,2/5,1/5,2/5) c2 <- c(2/5,0,2/5,1/5) c3 <- c(1/5,2/5,0,2/5) c4 <- c(2/5,1/5,2/5,0) P <- cbind(c1,c2,c3,c4) C <- P P for(i in 1:1) C <- C%*%P # C = P^2 C ##look at a) output for b) # HW9 3c) C <- P for(i in 1:39) C <- C%*%P # C = P^40 C #HW9 4a) c1 <- c(0,2/5,1/5,2/5) c2 <- c(2/5,0,2/5,2/5) c3 <- c(1/5,2/5,0,1/5) c4 <- c(2/5,1/5,2/5,0) P <- cbind(c1,c2,c3,c4) C <- P P for(i in 1:1) C <- C%*%P # C = P^2 C ##look at a) output for b) # HW9 4c) C <- P for(i in 1:999) C <- C%*%P # C = P^1000 C #C%*%C - C approx the 0 matrix #HW10 4 ##copy and paste the source command near the top of this file into R #HW10 4 a) bmot(n=1000000) #HW10 4 b) Z <- 1:1000 for(i in 1:1000) Z[i] <- bmot(999)$B[500] hist(Z) #Z(500) approx N(0,50) and hist looks like a N(0,50) hist #HW 11 ##copy and paste the source command near the top of this file into R #HW11 5 #HW11 5a qcauchy(c(0.025,0.975)) #HW11 5b out <- rcauchy(1000000) quantile(out,c(0.025,0.975)) #HW11 5c shorth3(out) #HW11 6 u <- rng(n=201)$u plot(u[-1],u[-201])