Re: [Rd] pbinom with size argument 0 (PR#8560)

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Fri 03 Feb 2006 - 14:47:07 GMT

(Ted Harding) <Ted.Harding@nessie.mcc.ac.uk> writes:

> On 03-Feb-06 uht@dfu.min.dk wrote:
> > Full_Name: Uffe Høgsbro Thygesen
> > Version: 2.2.0
> > OS: linux
> > Submission from: (NULL) (130.226.135.250)
> >
> >
> > Hello all.
> >
> > pbinom(q=0,size=0,prob=0.5)
> >
> > returns the value NaN. I had expected the result 1. In fact any
> > value for q seems to give an NaN.
>
> Well, "NaN" can make sense since "q=0" refers to a single sampled
> value, and there is no value which you can sample from "size=0";
> i.e. sampling from "size=0" is a non-event. I think the probability
> of a non-event should be NaN, not 1! (But maybe others might argue
> that if you try to sample from an empty urn you necessarily get
> zero "successes", so p should be 1; but I would counter that you
> also necessarily get zero "failures" so q should be 1. I suppose
> it may be a matter of whether you regard the "r" of the binomial
> distribution as referring to the "identities" of the outcomes
> rather than to how many you get of a particular type. Hmmm.)
>
> > Note that
> >
> > dbinom(x=0,size=0,prob=0.5)
> >
> > returns the value 1.
>
> That is probably because the .Internal code for pbinom may do
> a preliminary test for "x >= size". This also makes sense, for
> the cumulative p<dist> for any <dist> with a finite range,
> since the answer must then be 1 and a lot of computation would
> be saved (likewise returning 0 when x < 0). However, it would
> make even more sense to have a preceding test for "size<=0"
> and return NaN in that case since, for the same reasons as
> above, the result is the probability of a non-event.

Once you get your coffee, you'll likely realize that you got your p's and d's mixed up...

I think Uffe is perfectly right: The result of zero experiments will be zero successes (and zero failures) with probability 1, so the cumulative distribution function is a step function with one step at zero ( == as.numeric(x>=0) ).  

> (But it depends on your point of view, as above ... However,
> surely the two should be consistent with each other.)
>
> Best wishes,
> Ted.
>
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 03-Feb-06 Time: 14:34:28
> ------------------------------ XFMail ------------------------------
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Sat Feb 04 01:55:14 2006

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:40 GMT