[SciPy-user] problems with stats

danny shevitz danny_shevitz at yahoo.com
Tue Apr 27 16:03:54 CDT 2004


I'm using .2. I'm trying to get a release out the door and haven't had
the chance to download .3 yet (it's only been out a week, so I beg for
an indulgence).

As for the binom.ppf().  Here's what I was trying to do. It's a fairly
standard problem. I am running a monte carlo simulation to try to
determinine the probability of an event happening and put confidence
bounds on the answer. The probability is relatively low e.g. 10e-6. I'm
running approximately 10^7 trials and getting approximately 10 events.
There is a standard way to assign the error bars using the continuous F
distribution, but when I looked at the stats documentation I noticed
the binomial distribution could be inverted via ppf. That's not to say
I was using it correctly, which you graciously pointed out I was not.
Of course there is no documentation either so I had to guess from the
code :-). In short I was just trying to play with the binomial
distribution to see if I could get it do what I wanted directly. 

The short version of the problem that I was trying to solve is: Given N
trials and n events, what is the specified confidence interval for the
binomial probability p.

The hypothetical argument call should therefore take 2 integers and a
probability, e.g. f(10, 10000000, .95) The third number is a
confidence, not the probability in the binomial distribution. Of course
there would have to be a pair of such functions ( one for the lower
bound, and one for the upper). 

Like I said, what I was doing, wasn't particularly well thought out. I
was just playing around, and using the function wrong anyway...

BTW I guess I have no idea what binom.ppf is supposed to do then. Why
do you need two probilities? Is one a confidence and the other the
probability.

Also in case it wasn't obvious, I'm not a statistician by training :-)

D  


> > 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
> 
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user



	
		
__________________________________
Do you Yahoo!?
Win a $20,000 Career Makeover at Yahoo! HotJobs  
http://hotjobs.sweepstakes.yahoo.com/careermakeover 



More information about the SciPy-user mailing list