Binomial probability density function
p can be
vectors, matrices, or multidimensional arrays of the same size. Alternatively, one or more
arguments can be scalars. The
binopdf function expands scalar inputs to
constant arrays with the same dimensions as the other inputs.
Compute and plot the binomial probability density function for the specified range of integer values, number of trials, and probability of success for each trial.
In one day, a quality assurance inspector tests 200 circuit boards. 2% of the boards have defects. Compute the probability that the inspector will find no defective boards on any given day.
ans = 0.0176
Compute the binomial probability density function values at each value from 0 to 200. These values correspond to the probabilities that the inspector will find 0, 1, 2, ..., 200 defective boards on any given day.
defects = 0:200; y = binopdf(defects,200,.02);
Plot the resulting binomial probability values.
Compute the most likely number of defective boards that the inspector finds in a day.
[x,i] = max(y); defects(i)
ans = 4
x— Values at which to evaluate binomial pdf
[0 n]| array of integers from interval
Values at which to evaluate the binomial pdf, specified as an integer or an array of
integers. All values of
x must belong to the interval
n is the number of trials.
n— Number of trials
Number of trials, specified as a positive integer or an array of positive integers.
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
The binomial probability density function lets you obtain the probability of observing exactly x successes in n trials, with the probability p of success on a single trial.
The binomial probability density function for a given value x and given pair of parameters n and p is
where q = 1 – p. The resulting value y is the probability of observing exactly x successes in n independent trials, where the probability of success in any given trial is p. The indicator function I(0,1,...,n)(x) ensures that x only adopts values of 0, 1, ..., n.
binopdf is a function specific to binomial distribution.
Statistics and Machine Learning Toolbox™ also offers the generic function
BinomialDistribution probability distribution
object and pass the object as an input argument. Note that the distribution-specific
binopdf 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.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).