Main Content

binocdf

Binomial cumulative distribution function

Description

example

y= binocdf(x,n,p)computes a binomial cumulative distribution function at each of the values inxusing the corresponding number of trials innand the probability of success for each trial inp.

x,n, andpcan be vectors, matrices, or multidimensional arrays of the same size. Alternatively, one or more arguments can be scalars. Thebinocdffunction expands scalar inputs to constant arrays with the same dimensions as the other inputs.

example

y= binocdf(x,n,p,'upper')returns the complement of the binomial cumulative distribution function at each value inx, using an algorithm that computes the extreme upper tail probabilities more accurately than the default algorithm.

Examples

collapse all

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.

formatlong1 - 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) gridon

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.

formatlong1 - binocdf(95,100,0.5)
ans = 0

这一结果表明,概率是如此接近to 1 (withineps) 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.

binocdf(95,100,0.5,'upper')
ans = 3.224844447881779e-24

Alternatively, use thebinopdffunction 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 thesumfunction.

sum(binopdf(96:100,100,0.5),'all')
ans = 3.224844447881779e-24

Input Arguments

collapse all

Values at which to evaluate the binomial cdf, specified as an integer or an array of integers. All values ofxmust belong to the interval[0 n], wherenis the number of trials.

Example:[0 1 3 4]

Data Types:single|double

Number of trials, specified as a positive integer or an array of positive integers.

Example:[10 20 50 100]

Data Types:single|double

Probability of success for each trial, specified as a scalar value or an array of scalar values. All values ofpmust belong to the interval[0 1].

Example:[0.01 0.1 0.5 0.7]

Data Types:single|double

Output Arguments

collapse all

Binomial cdf values, returned as a scalar value or an array of scalar values. Each element inyis the binomial cdf value of the distribution evaluated at the corresponding element inx.

Data Types:single|double

More About

collapse all

Binomial Cumulative Distribution Function

The binomial cumulative distribution function lets you obtain the probability of observing less than or equal toxsuccesses inntrials, with the probabilitypof success on a single trial.

The binomial cumulative distribution function for a given valuexand a given pair of parametersnandpis

y = F ( x | n , p ) = i = 0 x ( n i ) p i ( 1 p ) ( n i ) I ( 0 , 1 , ... , n ) ( i ) .

The resulting valueyis the probability of observing up toxsuccesses innindependent trials, where the probability of success in any given trial isp. The indicator function I ( 0 , 1 , ... , n ) ( i ) ensures thatxonly adopts values of 0,1,...,n.

Alternative Functionality

  • binocdfis a function specific to binomial distribution. Statistics and Machine Learning Toolbox™ also offers the generic functioncdf, which supports various probability distributions. To usecdf, specify the probability distribution name and its parameters. Alternatively, create aBinomialDistributionprobability distribution object and pass the object as an input argument. Note that the distribution-specific functionbinocdfis faster than the generic functioncdf.

  • Use theProbability Distribution Functionapp to create an interactive plot of the cumulative distribution function (cdf) or probability density function (pdf) for a probability distribution.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a