binopdf
Binomial probability density function
Syntax
Y = binopdf(X,N,P)
Description
Y = binopdf(X,N,P)
computes the binomial pdf at each of the values inX
using the corresponding number of trials inN
and probability of success for each trial inP
.Y
,N
, andP
can be vectors, matrices, or multidimensional arrays that all have the same size. A scalar input is expanded to a constant array with the same dimensions of the other inputs.
The parameters inN
must be positive integers, and the values inP
must lie on the interval [0, 1].
The binomial probability density function for a given valuex鉴于两个参数nandpis
whereq= 1 –p. The result,y, is the probability of observingxsuccesses innindependent trials, where the probability of success in anygiventrial isp. The indicator functionI(0,1,...,n)(x) ensures thatxonly adopts values of 0, 1, ...,n.
Examples
AQuality Assurance inspector tests 200circuit boards a day. If 2% of the boards have defects, what is the probability that the inspector will find no defective boards on any given day?
binopdf(0,200,0.02) ans = 0.0176
What is the most likely number of defective boards the inspector will find?
defects=0:200; y = binopdf(defects,200,.02); [x,i]=max(y); defects(i) ans = 4