BINDF
This function evaluates the binomial cumulative distribution function.
Function Return Value
BINDF — Function value, the probability that a binomial random variable takes a value less than or equal to K. (Output)
BINDF is the probability that K or fewer successes occur in N independent Bernoulli trials, each of which has a PIN probability of success.
Required Arguments
K — Argument for which the binomial distribution function is to be evaluated. (Input)
N — Number of Bernoulli trials. (Input)
PIN — Probability of success on each independent trial. (Input)
FORTRAN 90 Interface
Generic: BINDF (K, N, PIN)
Specific: The specific interface names are S_BINDF and D_BINDF.
FORTRAN 77 Interface
Single: BINDF (K, N, PIN)
Double: The double precision name is DBINDF.
Description
Function BINDF evaluates the cumulative distribution function of a binomial random variable with parameters n and p where n = N and p = PIN. 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 0, if k is not greater than n times p, and are computed backward from n, otherwise. 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 = 0, BINDF is set to 1; and for the case p = 1, BINDF is set to 1 if k = n and to 0 otherwise.
Comments
Informational Errors
Type | Code | Description |
---|
1 | 3 | The input argument, K, is less than zero. |
1 | 4 | The input argument, K, is greater than the number of Bernoulli trials, N. |
Example
Suppose X is a binomial random variable with n = 5 and p = 0.95. In this example, we find the probability that X is less than or equal to 3.
USE UMACH_INT
USE BINDF_INT
IMPLICIT NONE
INTEGER K, N, NOUT
REAL PIN, PR
!
CALL UMACH (2, NOUT)
K = 3
N = 5
PIN = 0.95
PR = BINDF(K,N, PIN)
WRITE (NOUT,99999) PR
99999 FORMAT (' The probability that X is less than or equal to 3 is ' &
, F6.4)
END
Output
The probability that X is less than or equal to 3 is 0.0226