Binomial cumulative distribution function
p can be
vectors, matrices, or multidimensional arrays of the same size. Alternatively, one or more
arguments can be scalars. The
binocdf function expands scalar inputs to
constant arrays with the same dimensions as the other inputs.
Compute and plot the binomial cumulative distribution function for the specified range of integer values, number of trials, and probability of success for each trial.
A baseball team plays 100 games in a season and has a 50-50 chance of winning each game. Find the probability of the team winning more than 55 games in a season.
format long 1 - binocdf(55,100,0.5)
ans = 0.135626512036917
Find the probability of the team winning between 50 and 55 games in a season.
binocdf(55,100,0.5) - binocdf(49,100,0.5)
ans = 0.404168106656672
Compute the probabilities of the team winning more than 55 games in a season if the chance of winning each game ranges from 10% to 90%.
chance = 0.1:0.05:0.9; y = 1 - binocdf(55,100,chance);
Plot the results.
scatter(chance,y) grid on
Compute the complement of the binomial cumulative distribution function with more accurate upper tail probabilities.
A baseball team plays 100 games in a season and has a 50-50 chance of winning each game. Find the probability of the team winning more than 95 games in a season.
format long 1 - binocdf(95,100,0.5)
ans = 0
This result shows that the probability is so close to 1 (within
eps) that subtracting it from 1 gives 0. To approximate the extreme upper tail probabilities better, compute the complement of the binomial cumulative distribution function directly instead of computing the difference.
ans = 3.224844447881779e-24
Alternatively, use the
binopdf function to find the probabilities of the team winning 96, 97, 98, 99, and 100 games in a season. Find the sum of these probabilities by using the
ans = 3.224844447881779e-24
x— Values at which to evaluate binomial cdf
[0 n]| array of integers from interval
Values at which to evaluate the binomial cdf, specified as an integer or an array of
integers. All values of
x must belong to the interval
n is the number of trials.
[0 1 3 4]
n— Number of trials
Number of trials, specified as a positive integer or an array of positive integers.
[10 20 50 100]
p— Probability of success for each trial
[0 1]| array of scalar values from interval
Probability of success for each trial, specified as a scalar value or an array of
scalar values. All values of
p must belong to the interval
[0.01 0.1 0.5 0.7]
The binomial cumulative distribution function lets you obtain the probability of observing less than or equal to x successes in n trials, with the probability p of success on a single trial.
The binomial cumulative distribution function for a given value x and a given pair of parameters n and p is
The resulting value 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 ensures that x only adopts values of 0,1,...,n.
binocdf is a function specific to binomial distribution.
Statistics and Machine Learning Toolbox™ also offers the generic function
cdf, which supports various probability distributions. To use
cdf, specify the probability distribution name and its parameters.
Alternatively, create a
BinomialDistribution probability distribution
object and pass the object as an input argument. Note that the distribution-specific
binocdf is faster than the generic function
Use the Probability Distribution Function app to create an interactive plot of the cumulative distribution function (cdf) or probability density function (pdf) for a probability distribution.