[R] Overlay cdf

Matthieu Dubois matthdub at gmail.com
Wed May 13 13:40:19 CEST 2009


You might also use ?curve

# same example as Bill's
par(mar = c(5,4,2,4)+0.1, yaxs = "r")
Sample <- rgamma(1000,2.5,.8)
hist(Sample, main = "", freq = FALSE, ylim = c(0,1))

curve(pgamma(x, 2.5, 0.8), add=T, col='red')
curve(dgamma(x, 2.5, 0.8), add=T, col='darkgreen')

axis(4, col = "red")
mtext(side = 4, text = "Cumulative probability", col = "red", line = 2.5)

x0 <- c(0, sort(Sample))
p0 <- 0:1000/1000
lines(x0, p0, type = "S", col = "blue")
 
Regards,

Matthieu




More information about the R-help mailing list