[SciPy-user] Is this a bug in stats.geom.pmf?
Stefan van der Walt
stefan@sun.ac...
Mon Jun 25 17:19:03 CDT 2007
On Mon, Jun 25, 2007 at 02:59:09PM -0600, Fernando Perez wrote:
> Hi all,
>
> just curious. The stats.geom docstring says:
>
> Geometric distribution
>
> geom.pmf(k,p) = (1-p)**(k-1)*p
> for k >= 1
>
> But I see this:
>
> In [10]: k,p = 2.0,0.5
>
> In [11]: (1-p)**(k-1)*p
> Out[11]: 0.25
>
> In [12]: stats.geom.pmf(k,p)
> Out[12]: array(0.125)
>
> However:
>
> In [13]: stats.geom.pmf(k-1,p)
> Out[13]: array(0.25)
>
>
> Is this an off-by-one bug, or am I misreading something here?
I read now in wikipedia that:
"""
In probability theory and statistics, the geometric distribution is
either of two discrete probability distributions:
* the probability distribution of the number X of Bernoulli trials
needed to get one success, supported on the set { 1, 2, 3, ...},
or
* the probability distribution of the number Y = X − 1 of failures
before the first success, supported on the set { 0, 1, 2, 3,
... }.
Which of these one calls "the" geometric distribution is a matter of
convention and convenience.
"""
So, do we simply pick one and stick with it?
Cheers
Stéfan
More information about the SciPy-user
mailing list