Deviations from normal distribution based on number of observations


/ Published in: R
Save to your folder(s)



Copy this code and paste it in your HTML
  1. par(mfrow = c(2, 2))
  2.  
  3. norm = density(rnorm(1e6,0,1))
  4. n.minx = min(norm$x)
  5. n.maxx = max(norm$x)
  6. n.miny = min(norm$y)
  7. n.maxy = max(norm$y)
  8.  
  9. for (i in c(10, 20, 50, 100) ) {
  10. d = density(rnorm(i,0,1))
  11. plot ( d,
  12. xlim=c( min(n.minx,min(d$x)),max(n.maxx,max(d$x)) ),
  13. ylim=c( min(n.miny,min(d$y)),max(n.maxy,max(d$y)) ) )
  14. lines ( norm, col="Red" )
  15. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.