jaredec18

Untitled

Sep 18th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. num = seq(2,1000,by = 1)
  2. y.num = replicate(1000,0)
  3. y.lower = replicate(1000,0)
  4. y.upper = replicate(1000,0)
  5.  
  6. #Getting the plot for n = 2 to 1000
  7. for (i in 2:length(samp.num))
  8. {
  9. rsamp= rnorm(i,mean,sd)
  10. rsamp.mean = mean(rsamp)
  11. rsamp.sd = sd(rsamp)
  12. rsamp.se = rsamp.sd/sqrt(i)
  13. y.num[i] = rsamp.mean
  14. y.lower[i] = rsamp.mean - 1.96*rsamp.se
  15. y.upper[i] = rsamp.mean + 1.96*rsamp.se
  16. }
  17. plot(num,y.num[-1],xlab = "sample size",ylab = "Sample mean and SE")
  18. lines(num,replicate(999,mean),col = "red")
  19. lines(num,y.lower[-1],col = "blue")
  20. lines(num,y.upper[-1],col = "green")
Advertisement
Add Comment
Please, Sign In to add comment