IMSL C# Numerical Library

Cdf.BinomialProb Method 

Evaluates the binomial probability density function.

public static double BinomialProb(
   int k,
   int n,
   double pin
);

Parameters

k
An int specifying the argument for which the binomial distribution function is to be evaluated.
n
An int specifying the number of Bernoulli trials.
pin
A double specifying the probability of success on each independent trial.

Return Value

A double specifying the probability that a binomial random variable takes a value equal to k.

Remarks

Method BinomialProb evaluates the probability that a binomial random variable with parameters n and p with p=pin takes on the value k. It does this by computing probabilities of the random variable taking on the values in its range less than (or the values greater than) k. These probabilities are computed by the recursive relationship

\Pr\left({X=j}\right)=\frac{{\left({n+1-j}
            \right)p}}{{j\left({1-p}\right)}}\Pr\left({X=j-1}\right)

To avoid the possibility of underflow, the probabilities are computed forward from 0, if k is not greater than n\times p, and are computed backward from n, otherwise. The smallest positive machine number, \varepsilon, is used as the starting value for computing the probabilities, which are rescaled by (1-p)^n\varepsilon if forward computation is performed and by p^n\varepsilon if backward computation is done.

For the special case of p = 0, BinomialProb is set to 0 if k is greater than 0 and to 1 otherwise; and for the case p = 1, BinomialProb is set to 0 if k is less than n and to 1 otherwise.

Plot of Binomial Probability Function

See Also

Cdf Class | Imsl.Stat Namespace | Example