From: Douglas Bates <dmbates_at_gmail.com>

Date: Thu 07 Jul 2005 - 12:07:36 EST

> plot(c(-0.3, x), c(0, Pr), type = "s", xlab = "x", ylab = "P", main = "Cumulative distribution function", las = 1)

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 07 12:10:25 2005

Date: Thu 07 Jul 2005 - 12:07:36 EST

On 7/6/05, huang min <minhuangr@gmail.com> wrote:

> Dear all,

*>
**> I have define a discrete distribution P(y_i=x_i)=p_i, which I want to
**> plot a CDF plot. However, I can not find a function in R to draw it
**> for me after searching R and R-archive. I only find the one for the
**> sample CDF instead my theoretical one.
**>
**> I find stepfun can do it for me, however, I want to plot some
**> different CDF with same support x in one plot. I can not manage how to
**> do it with stepfun.
**>
**> Is there any existing function in R to draw the theoretical CDF plot?
**> Or how to abline other step functions in stepfun? Thanks.
*

The type = 's' option to the plot function is used to create the "stairstep" plot of a cumulative distribution function. Try

*> x <- 0:10
*

> Pr <- pbinom(x, size = 10, prob = 0.314)

> data.frame(x = x, Pr = Pr)

x Pr

1 0 0.02308028 2 1 0.12872474 3 2 0.34632766 4 3 0.61193435 5 4 0.82469072 6 5 0.94155166 7 6 0.98612689 8 7 0.99778589 9 8 0.99978712 10 9 0.99999068 11 10 1.00000000

> plot(c(-0.3, x), c(0, Pr), type = "s", xlab = "x", ylab = "P", main = "Cumulative distribution function", las = 1)

R-help@stat.math.ethz.ch mailing list

https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 07 12:10:25 2005

*
This archive was generated by hypermail 2.1.8
: Fri 03 Mar 2006 - 03:33:18 EST
*