help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: computing binomial distribution tails


From: Johan Kullstam
Subject: Re: computing binomial distribution tails
Date: 30 Jun 2005 22:38:51 -0400
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

(Ted Harding) <address@hidden> writes:

> On 30-Jun-05 Johan Kullstam wrote:
> > 
> > I wish to compute the tail of a binomial distribution but I keep
> > running into numerical difficulties.
> > 
> > For example, given probability p (small) what is the chance of no
> > success for m bernouli trials?
> > 
> > Q = 1-(1-p)^m
> > 
> > has trouble when p is near eps in magnitude and fails utterly when p <
> > eps.
> 
> You can hardly be far out, in this case, with
> 
>   (1-p)^m = 1 - m*p

Right -- but this requires some kind of special casing for p small.

if p < tol,
  retval = m*p
else
  retval = 1-binomial_pdf(0,m,p)
endif

> unless m is also large, in which case you might be better with
> 
>   (1-p)^m = (1 - (m*p)/m)^m = exp(-m*p)
> 
> (which is in effect the Poisson approximation to the Binomial).
> 
> Incidentally, your Q = 1 - (1-p)^m is the chance of at least
> one success.

> The chance of no successes is (1-p)^m, i.e. that
> all m trials fail.

My bad.  Thanks.

-- 
Johan KULLSTAM



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]