CNLMath : Special Functions : binomial_cdf
binomial_cdf
Evaluates the binomial distribution function.
Synopsis
#include <imsl.h>
float imsl_f_binomial_cdf (int k, int n, float p)
The type double procedure is imsl_d_binomial_cdf.
Required Arguments
int k (Input)
Argument for which the binomial distribution function is to be evaluated.
int n (Input)
Number of Bernoulli trials.
float p (Input)
Probability of success on each trial.
Return Value
The probability that k or fewer successes occur in n independent Bernoulli trials, each of which has a probability p of success.
Description
The function imsl_f_binomial_cdf evaluates the distribution function of a binomial random variable with parameters n and p. It does this by summing probabilities of the random variable taking on the specific values in its range. These probabilities are computed by the recursive relationship
To avoid the possibility of underflow, the probabilities are computed forward from zero if k is not greater than n × p; otherwise, they are computed backward from n. The smallest positive machine number, ɛ, is used as the starting value for summing the probabilities, which are rescaled by (1  p)n ɛ if forward computation is performed and by pnɛ if backward computation is done.
For the special case of p is zero, imsl_f_binomial_cdf is set to 1; and for the case p is 1, imsl_f_binomial_cdf is set to 1 if k = n and is set to zero otherwise.
Example
Suppose X is a binomial random variable with an n = 5 and a p = 0.95. This example finds the probability that X is less than or equal to three.
 
#include <imsl.h>
#include <stdio.h>
 
int main()
{
int k = 3;
int n = 5;
float p = 0.95;
float pr;
 
pr = imsl_f_binomial_cdf(k,n,p);
printf("Pr(x <= 3) = %6.4f\n", pr);
}
Output
 
Pr(x <= 3) = 0.0226
Informational Errors
IMSL_LESS_THAN_ZERO
The input argument, k, is less than zero.
IMSL_GREATER_THAN_N
The input argument, k, is greater than the number of Bernoulli trials, n.