octave-maintainers
[Top][All Lists]
Advanced

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

Re: binocdf inaccuracy in Octave


From: Rik
Subject: Re: binocdf inaccuracy in Octave
Date: Mon, 08 Jul 2013 09:38:27 -0700

7/8/13

Dr. Klein,

I think this is actually a much easier problem to solve that it first appeared.  In the the file binocdf.m the formula used to calculate the CDF is

cdf(k) = 1 - betainc (p, tmp + 1, n - tmp);

According to Wikipedia (http://en.wikipedia.org/wiki/Binomial_distribution) the CDF for the binomial distribution is

\textstyle I_{1-p}(n - k, 1 + k)

or

I(1-p, n-k, 1+k)

So it appears that we simply have the arguments wrong to the betainc function.  I modified binocdf.m to

cdf(k) = betainc (1 - p, n - tmp, tmp + 1);

and now I get the same answers as Erlang to ~14 significant digits which seems acceptable.

Can you verify that this now correct?

--Rik

Attachment: binocdf.m
Description: Text Data


reply via email to

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