Accelerating the pace of engineering and science

# binocdf

Binomial cumulative distribution function

## Syntax

y = binocdf(x,N,p)
y = binocdf(x,N,p,'upper')

## Description

y = binocdf(x,N,p) computes a binomial cdf at each of the values in x using the corresponding number of trials in N and probability of success for each trial in p. x, N, and p can be vectors, matrices, or multidimensional arrays that are all the same size. A scalar input is expanded to a constant array with the same dimensions of the other inputs. The values in N must all be positive integers, the values in x must lie on the interval [0,N], and the values in p must lie on the interval [0, 1].

y = binocdf(x,N,p,'upper') returns the complement of the binomial cdf at each value in x, using an algorithm that more accurately computes the extreme upper tail probabilities.

The binomial cdf for a given value x and a given pair of parameters n and p is

$y=F\left(x|n,p\right)=\sum _{i=0}^{x}\left(\begin{array}{c}n\\ i\end{array}\right){p}^{i}{\left(1-p\right)}^{\left(n-i\right)}{I}_{\left(0,1,...,n\right)}\left(i\right).$

The result, y, is the probability of observing up to x successes in n independent trials, where the probability of success in any given trial is p. The indicator function ${I}_{\left(0,1,...,n\right)}\left(i\right)$ ensures that x only adopts values of 0,1,...,n.

## Examples

expand all

### Compute Binomial CDF

If a baseball team plays 162 games in a season and has a 50-50 chance of winning any game, then the probability of that team winning more than 100 games in a season is:

`1 - binocdf(100,162,0.5)`
```ans =

0.0010```

The result is 0.001 (i.e., 1-0.999). If a team wins 100 or more games in a season, this result suggests that it is likely that the team's true probability of winning any game is greater than 0.5.