Jan 072009

I was surprised to find the density estimation of a constant was also “bell-shaped” by default when a friend passed some R code to me to illustrate CLT, but I realized the reason soon.

Downdload the R code here
# png(width = 500, height = 300)
x = rep(0, 1000)
par(mfrow = c(1, 2), mar = c(4, 4, 0.1, 0.1))
plot(density(x), main = "")
plot(density(x), main = "")
rug(jitter(x))
# dev.off()

Note that I added a rug (jittered) to the right plot to tell you the true locations of the data points.

Related Posts

Leave a Reply

(required)

(required)

WWW.YIHUI.NAME XIE@YIHUI.NAME © 2007 - 2010 by Yihui Xie