Post Reply 
Bug in BINOMIAL_ICDF
10-18-2015, 08:46 PM (This post was last modified: 10-18-2015 08:58 PM by Dieter.)
Post: #2
RE: Bug in BINOMIAL_ICDF
(10-18-2015 06:23 PM)Arno K Wrote:  On writing a program for the kind of hypothesis test that are usual in Germany I discovered the following bug: BINOMIAL_ICDF() does not provide the result below the given probability, instead it results to the nearest integer value:

It seems to provide the next higher integer, which IMHO is the usual way results of this kind are returned.

(10-18-2015 06:23 PM)Arno K Wrote:  BINOMIAL_ICDF(20,0.6,0.05) -> 8

That's what my own inverse Binomial program returns as well.

(10-18-2015 06:23 PM)Arno K Wrote:  BINOMIAL_CDF(20,0.6,8) -> 0.0565 which is too big.

Right. The continuous extension of the Binomial CDF (using the Beta function) would yield an exact result of 7,8652865... If an integer result is desired, the usual way (at least as I know it) is to round up to the next higher integer, i.e. ceil(x).

This way the CDF of the returned result k is greater or equal to the given probability: CDF(k) ≥ q.

(10-18-2015 06:23 PM)Arno K Wrote:  The oncalc-help says:
Returns the number of successes, k, out of n trials, each with a probability of p, such that the probability of k or fewer successes is q.

In other words: P(x≤k) = 0,05. Since there is no integer k that yields a probability of exactly 0.05, the calculator actually returns an integer result so that P(x≤k) ≥ 0,05. Which in my humble opinion is perfectly okay.

For instance Matlab's "binoinv" seems to work the same way, take a look here:
Quote:"X = binoinv(Y,N,P) returns the smallest integer X such that the binomial cdf evaluated at X is equal to or exceeds Y."

The (real) results (with n=162 and p=0,5) for q=0,05 and 0,95 are ~70,04 and 90,96, which Matlab returns as 71 and 91.

(10-18-2015 06:23 PM)Arno K Wrote:  So, in my opinion, it should return 7, not 8.

This (k=7) is the largest integer for which P(x≤k) ≤ 0,05. Which may also be a valid solution, but I think it's not a common one.

That's why my 34s program for the Binomial (and Poisson) distribution optionally returns real results (if desired by the user). If you know that the "exact" value is 7,865... you can decide on your own if you want to round up or down. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Bug in BINOMIAL_ICDF - Arno K - 10-18-2015, 06:23 PM
RE: Bug in BINOMIAL_ICDF - Dieter - 10-18-2015 08:46 PM
RE: Bug in BINOMIAL_ICDF - Tim Wessman - 10-18-2015, 08:50 PM
RE: Bug in BINOMIAL_ICDF - Dieter - 10-18-2015, 09:05 PM
RE: Bug in BINOMIAL_ICDF - Arno K - 10-18-2015, 09:15 PM
RE: Bug in BINOMIAL_ICDF - lrdheat - 10-18-2015, 08:53 PM
RE: Bug in BINOMIAL_ICDF - lrdheat - 10-18-2015, 09:52 PM
RE: Bug in BINOMIAL_ICDF - Dieter - 10-20-2015, 06:48 PM



User(s) browsing this thread: 1 Guest(s)