[SciPy-user] problems with stats

Travis E. Oliphant oliphant at ee.byu.edu
Tue Apr 27 15:20:38 CDT 2004


danny shevitz wrote:
> Howdy,
> 
> I've encountered two problems with the binomial distribution in the
> stats module. The first is trivial and I believe just an argument
> checking problem.
> 
> 
>>>>binom.pdf(0,3,.5)
> 
> 
> bdtr domain error
> 1.#QNAN

which version are you using?

The current version 0.3  uses pmf (probability mass function) for 
discrete rvs.

for me

 >>> binom.pmf(0,3,.5)
0.125

> 
> (the answer should be .125 of course)
> 
> The second is a little more significant. I'm trying to invert the
> binomial distribution using ppf. I looked at distributions.py
> 
> class binom_gen(rv_discrete):
>     .
>     .
>     .
>     def _ppf(self, q, n, pr):
>         vals = ceil(special.bdtrik(q,n,pr))
>         vals1 = vals-1
>         temp = special.bdtr(vals1,n,pr)
>         return where(temp >= q, vals1, vals)
> 
> and ppf is in fact implemented, but when I try to run it I get an
> error.
> 
> 
>>>>binom.ppf(3,4,.95)

You uncovered a genuine bug here.

But, by the way what you expect this to return seeing how 3 is bigger 
than 1.

-Travis



More information about the SciPy-user mailing list