Full_Name: Murray H Smith Version: 0.63.3 OS: Windows NT Submission from: (NULL) (130.216.5.57) The ppois function is displaced by -0.5. Try:> ppois(-0.5,1)[1] 0.3678794> ppois(-0.51,1)[1] 0> ppois(0,1)[1] 0.3678794 and> par(mfrow=c(2,1)) > x<-seq(-1,5,0.01) > plot(x,ppois(x,1),type="s",ylab="F(x)",main="Poisson CDF?") > plot(x,pbinom(x,100,0.01),type="s",ylab="F(x)",main="Binomial CDF")-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 9 Apr 1999 mh.smith@auckland.ac.nz wrote:> Full_Name: Murray H Smith > Version: 0.63.3 > OS: Windows NT > Submission from: (NULL) (130.216.5.57) > > > The ppois function is displaced by -0.5. > Try: > > > ppois(-0.5,1) > [1] 0.3678794 > > ppois(-0.51,1) > [1] 0 > > ppois(0,1) > [1] 0.3678794The problem is in> ?ppoisThe Poisson Distribution dpois(x, lambda) ppois(q, lambda) qpois(p, lambda) rpois(n, lambda) Arguments: x: vector of (positive) quantiles. p: vector of probabilities. n: number of random values to return. lambda: vector of positive means. where q is undefined! It should only be defined for integers. Similarly, x should only be integers. It seems better to make ppois defined as the CDF for all q. The code had x = floor(x + 0.5); and that should be something like floor(x + 1e-7). I've fixed this for 0.64.1, and dpois now warns on non-integer x and, correctly, gives 0. (Yes, I know S does not warn, but that is taking silence too far I think.)> > and > > > par(mfrow=c(2,1)) > > x<-seq(-1,5,0.01) > > plot(x,ppois(x,1),type="s",ylab="F(x)",main="Poisson CDF?") > > plot(x,pbinom(x,100,0.01),type="s",ylab="F(x)",main="Binomial CDF")Thank you for the nice example, now on the help page. You did not try pnbinom, which is much more wrong:> pnbinom(1, 3, 0.5)[1] 0.3125> pnbinom(1.1, 3, 0.5)[1] 0.3320067> pnbinom(1.5, 3, 0.5)[1] 0.4089029 -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 9 Apr 1999 mh.smith@auckland.ac.nz wrote:> Full_Name: Murray H Smith > Version: 0.63.3 > OS: Windows NT > Submission from: (NULL) (130.216.5.57) > > > The ppois function is displaced by -0.5. > Try: > > > ppois(-0.5,1) > [1] 0.3678794 > > ppois(-0.51,1) > [1] 0 > > ppois(0,1) > [1] 0.3678794The problem is in> ?ppoisThe Poisson Distribution dpois(x, lambda) ppois(q, lambda) qpois(p, lambda) rpois(n, lambda) Arguments: x: vector of (positive) quantiles. p: vector of probabilities. n: number of random values to return. lambda: vector of positive means. where q is undefined! It should only be defined for integers. Similarly, x should only be integers. It seems better to make ppois defined as the CDF for all q. The code had x = floor(x + 0.5); and that should be something like floor(x + 1e-7). I've fixed this for 0.64.1, and dpois now warns on non-integer x and, correctly, gives 0. (Yes, I know S does not warn, but that is taking silence too far I think.)> > and > > > par(mfrow=c(2,1)) > > x<-seq(-1,5,0.01) > > plot(x,ppois(x,1),type="s",ylab="F(x)",main="Poisson CDF?") > > plot(x,pbinom(x,100,0.01),type="s",ylab="F(x)",main="Binomial CDF")Thank you for the nice example, now on the help page. You did not try pnbinom, which is much more wrong:> pnbinom(1, 3, 0.5)[1] 0.3125> pnbinom(1.1, 3, 0.5)[1] 0.3320067> pnbinom(1.5, 3, 0.5)[1] 0.4089029 -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 9 Apr 1999, Prof Brian D Ripley wrote:> ppois(q, lambda) > > where q is undefined! It should only be defined for integers. Similarly, x > should only be integers.Ummmm. I guess I see the argument for dpois, but I thought the distribution function was defined for all values. Wouldn't it be in order to apply the integer argument function to floor(q) perhaps? This seems to be what S does. > ppois(1.5, 2) [1] 0.4060058 > ppois(1.1, 2) [1] 0.4060058 Ross -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 9 Apr 1999, Ross Ihaka wrote: Some nonsense or other ... Never mind, it's late Friday. But ... How about dpois(1.2, 3) returning NA? Ross -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Fri, 9 Apr 1999 ihaka@stat.auckland.ac.nz wrote:> On Fri, 9 Apr 1999, Prof Brian D Ripley wrote: > > > ppois(q, lambda) > > > > where q is undefined! It should only be defined for integers. Similarly, x > > should only be integers. > > Ummmm. I guess I see the argument for dpois, but I thought the > distribution function was defined for all values. Wouldn't it be in order > to apply the integer argument function to floor(q) perhaps?Try reading on:> > It seems better to make ppois defined as the CDF for all q. The codehad> > > > x = floor(x + 0.5); > > > > and that should be something like floor(x + 1e-7).(q in R is x in C.)> This seems to be what S does. > > > ppois(1.5, 2) > [1] 0.4060058 > > ppois(1.1, 2) > [1] 0.4060058and R-0.64.1 does> ppois(1.5, 2)[1] 0.4060058> ppois(1.1, 2)[1] 0.4060058> dpois(1.1, 2)Warning: non-integer x = 1.100000 [1] 0 Happy? Brian -- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
ripley@stats.ox.ac.uk writes:> and R-0.64.1 does > > > ppois(1.5, 2) > [1] 0.4060058 > > ppois(1.1, 2) > [1] 0.4060058 > > dpois(1.1, 2) > Warning: non-integer x = 1.100000 > [1] 0 > > Happy?Almost. Do you use round(x) - x < 1e-7 or some such as criterion for "integer"? (although I'd be hard pressed to come up with a natural example where the argument to dpois is subject to FP accuracy issues) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> ripley writes:> On Fri, 9 Apr 1999 ihaka@stat.auckland.ac.nz wrote: >> On Fri, 9 Apr 1999, Prof Brian D Ripley wrote: >> >> > ppois(q, lambda) >> > >> > where q is undefined! It should only be defined for integers. Similarly, x >> > should only be integers. >> >> Ummmm. I guess I see the argument for dpois, but I thought the >> distribution function was defined for all values. Wouldn't it be in order >> to apply the integer argument function to floor(q) perhaps?> Try reading on:>> > It seems better to make ppois defined as the CDF for all q. The code > had >> > >> > x = floor(x + 0.5); >> > >> > and that should be something like floor(x + 1e-7).> (q in R is x in C.)>> This seems to be what S does. >> >> > ppois(1.5, 2) >> [1] 0.4060058 >> > ppois(1.1, 2) >> [1] 0.4060058> and R-0.64.1 does>> ppois(1.5, 2) > [1] 0.4060058 >> ppois(1.1, 2) > [1] 0.4060058 >> dpois(1.1, 2) > Warning: non-integer x = 1.100000 > [1] 0> Happy?No! Why the warning? dpois(non-integer, something) makes perfect sense, and simply gives 0. (Yes, dwilcox() and dsignrank() will need fixing, too ...) -k -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Seemingly Similar Threads
- pnmath compilation failure; dylib issue?
- Exactness of ppois
- Bug report: Function ppois(0:20, lambda=0.9) does not generate a non-decreasing result.
- Bug report: Function ppois(0:20, lambda=0.9) does not generate a non-decreasing result.
- R-beta: Problem with `rpois'