[R] Plotting probability density and cumulative distribution function
chrisr34000
crisr at wolke7.net
Tue Jan 17 14:11:39 CET 2012
Hi!
I want to plot the probability density function and the cumulative
distribution function for the gamma, lognormal, exponential and Pareto
distribution. I want to vary the parameters and and have a plot with 2-3
different parameters in the same figure. It should look like this (example
weibull distribution):
http://en.wikipedia.org/wiki/File:Weibull_PDF.svg
library(Cairo)
CairoFonts(regular="DejaVu Sans:style=Regular")
CairoSVG("Weibull PDF.svg")
par(mar=c(3, 3, 1, 1))
x <- seq(0, 2.5, length.out=1000)
plot(x, dweibull(x, .5), type="l", col="blue", xlab="", ylab="", xlim=c(0,
2.5), ylim=c(0, 2.5), xaxs="i", yaxs="i")
lines(x, dweibull(x, 1), type="l", col="red")
lines(x, dweibull(x, 1.5), type="l", col="magenta")
lines(x, dweibull(x, 5), type="l", col="green")
legend("topright", legend=paste("\u03bb = 1, k =", c(.5, 1, 1.5, 5)), lwd=1,
col=c("blue", "red", "magenta", "green"))
dev.off()
and
http://en.wikipedia.org/wiki/File:Weibull_CDF.svg
library(Cairo)
CairoFonts(regular="DejaVu Sans:style=Regular")
CairoSVG("Weibull CDF.svg")
par(mar=c(3, 3, 1, 1))
x <- seq(0, 2.5, length.out=1000)
plot(x, pweibull(x, .5), type="l", col="blue", xlab="", ylab="", xlim=c(0,
2.5), ylim=c(0, 1), xaxs="i", yaxs="i")
lines(x, pweibull(x, 1), type="l", col="red")
lines(x, pweibull(x, 1.5), type="l", col="magenta")
lines(x, pweibull(x, 5), type="l", col="green")
legend("bottomright", legend=paste("\u03bb = 1, k =", c(.5, 1, 1.5, 5)),
lwd=1, col=c("blue", "red", "magenta", "green"))
dev.off()
How do I adapt the syntax to use it for the other distributions?
--
View this message in context: http://r.789695.n4.nabble.com/Plotting-probability-density-and-cumulative-distribution-function-tp4303198p4303198.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list