[R] Overlay cdf

Bill.Venables at csiro.au Bill.Venables at csiro.au
Wed May 13 08:17:04 CEST 2009


Here are some ideas you might like to consider

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))

pu <- par("usr")[1:2]
x <- seq(pu[1], pu[2], len = 5000)
y <- pgamma(x, 2.5, 0.8)
par(new = TRUE)
plot(x, y, type = "l", axes = FALSE, ann = FALSE, col = "red")
lines(x, dgamma(x, 2.5, 0.8), 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")


Bill Venables
http://www.cmis.csiro.au/bill.venables/ 


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of beetle2
Sent: Wednesday, 13 May 2009 3:23 PM
To: r-help at r-project.org
Subject: [R] Overlay cdf


Hi,
Is it possible to  overlay a cummulative distribution function on a
histogram of a gamma distribuition.

I have a gamma function 

Sample = rgamma(1000,2.5,.8)+1.5
hist(Sample)

regards


-- 
View this message in context: http://www.nabble.com/Overlay-cdf-tp23515551p23515551.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list