Computes the quantile or inverse negative binomial cumulative distribution function.
cdfNegBinomialInv(p, s, prob)¶
p (NxK matrix, Nx1 vector or scalar) – The probability of observing f failures before observing s successes. \(0 < p < 1\).
s (matrix) – ExE conformable with p, the number of successes. \(0 < s\).
prob (matrix) – The probability of success on any given trial. ExE conformable with p. \(0 < prob < 1\).
f (NxK matrix, Nx1 vector or scalar) – The number of failures that will be observed before s successes.
For invalid inputs,
cdfNegBinomialInv() will return a scalar error code
which, when its value is assessed by function
scalerr(), corresponds to
the invalid input. If the first input is out of range, scalerr will
return a 1; if the second is out of range,
scalerr() will return a 2; etc.
Pat is supposed to sell five candy bars to raise money for the 6th grade field trip. So he goes door to door, selling candy bars. At each house, there is a 0.4 probability of selling one candy bar and a 0.6 probability of selling nothing.
If we know the probability that Pat sells all of his candy bars is 17.36704%, how many failures should we expect before he sells all five candy bars?
// The probability of selling all candy bars p = 0.1736704; // Number of successes (sold candy bars) s = 5; // Probability of success at each house prob = 0.4; // Compute the number of failures f = cdfNegBinomialInv(p, s, prob);
After running above code, the number of f will be equal to 3. This means that he has 8 houses to visit to sell all his candy bars, since he will fail 3 times and succeed 5 times.