|
Hi,
With R version 2.10.0 (2009-10-26) on Windows, I computed the p=1.e-20 quantile of the geometric distribution with parameter prob=0.1. > qgeom(1.e-20,0.1) [1] -1 But this is not possible, since X=0,1,2,... I guess that this might be a bug in the quantile function, which should use the log1p function, instead of the naive formula. Am I correct ? Best regards, Michaël ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel |
|
On Jun 28, 2012, at 22:49 , <[hidden email]> <[hidden email]> wrote: > Hi, > > With R version 2.10.0 (2009-10-26) on Windows, I computed the p=1.e-20 quantile of the geometric distribution with parameter prob=0.1. > >> qgeom(1.e-20,0.1) > [1] -1 > > But this is not possible, since X=0,1,2,... > > I guess that this might be a bug in the quantile function, which should use the log1p function, instead of the naive formula. > > Am I correct ? Nope. (The source is availably, you know....). The problem is that a slight fuzz is subtracted inside ceil(....), but there's no check that the result is positive. qnbinom(...., size=1) is equivalent and does get right, by the way. -pd > > Best regards, > > Michaël > > ______________________________________________ > [hidden email] mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: [hidden email] Priv: [hidden email] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel |
|
Hi,
I'm sorry, I do not clearly understand. I'm aware that the source is available at : http://svn.r-project.org/R/trunk/src/nmath/qgeom.c But a good source does not mean a correct result, because of compilation issues. Moreover, I do not fully understand why the 1e-7 coefficient in the formula was put there. The comment "add a fuzz to ensure left continuity" is not obvious to me. Best regards, Michaël On Fri, 29 Jun 2012 14:21:50 +0200, peter dalgaard <[hidden email]> wrote: > On Jun 28, 2012, at 22:49 , <[hidden email]> > <[hidden email]> wrote: > >> Hi, >> >> With R version 2.10.0 (2009-10-26) on Windows, I computed the >> p=1.e-20 quantile of the geometric distribution with parameter >> prob=0.1. >> >>> qgeom(1.e-20,0.1) >> [1] -1 >> >> But this is not possible, since X=0,1,2,... >> >> I guess that this might be a bug in the quantile function, which >> should use the log1p function, instead of the naive formula. >> >> Am I correct ? > > Nope. (The source is availably, you know....). > > The problem is that a slight fuzz is subtracted inside ceil(....), > but there's no check that the result is positive. > > qnbinom(...., size=1) is equivalent and does get right, by the way. > > -pd > >> >> Best regards, >> >> Michaël >> >> ______________________________________________ >> [hidden email] mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel |
|
On Jun 30, 2012, at 12:13 , <[hidden email]> <[hidden email]> wrote: > Hi, > > I'm sorry, I do not clearly understand. > > I'm aware that the source is available at : > > http://svn.r-project.org/R/trunk/src/nmath/qgeom.c Yes, but you were suggesting that non-use of log1p caused the problem, and the source clearly uses it, so I assumed that you didn't check. > > But a good source does not mean a correct result, because of compilation issues. Moreover, I do not fully understand why the 1e-7 coefficient in the formula was put there. The comment "add a fuzz to ensure left continuity" is not obvious to me. I never implied that there wasn't a problem. The gist of the comment it is that we want to ensure that (for moderate i at least) qgeom(pgeom(i,.1),.1)==i and that slightly lower values should also give i, whereas higher values give i+1: > qgeom(pgeom(1,.1),.1) [1] 1 > qgeom(pgeom(1,.1)-.01,.1) [1] 1 > qgeom(pgeom(1,.1)+.01,.1) [1] 2 However, floating point calculations being what they are, we don't trust equality, so we move the cutpoint a little -- apparently a little too much. > Best regards, > > Michaël > > On Fri, 29 Jun 2012 14:21:50 +0200, peter dalgaard <[hidden email]> wrote: >> On Jun 28, 2012, at 22:49 , <[hidden email]> >> <[hidden email]> wrote: >> >>> Hi, >>> >>> With R version 2.10.0 (2009-10-26) on Windows, I computed the p=1.e-20 quantile of the geometric distribution with parameter prob=0.1. >>> >>>> qgeom(1.e-20,0.1) >>> [1] -1 >>> >>> But this is not possible, since X=0,1,2,... >>> >>> I guess that this might be a bug in the quantile function, which should use the log1p function, instead of the naive formula. >>> >>> Am I correct ? >> >> Nope. (The source is availably, you know....). >> >> The problem is that a slight fuzz is subtracted inside ceil(....), >> but there's no check that the result is positive. >> >> qnbinom(...., size=1) is equivalent and does get right, by the way. >> >> -pd >> >>> >>> Best regards, >>> >>> Michaël >>> >>> ______________________________________________ >>> [hidden email] mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: [hidden email] Priv: [hidden email] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel |
| Powered by Nabble | Edit this page |
