Documentation

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 inXusing the corresponding number of trials inNand probability of success for each trial inP.Y,N, andPcan 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 inNmust be positive integers, and the values inPmust lie on the interval [0, 1].

The binomial probability density function for a given valuex鉴于两个参数nandpis

y = f ( x | n , p ) = ( n x ) p x q ( n x ) I ( 0 , 1 , ... , n ) ( x )

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

Extended Capabilities

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

Introduced before R2006a

Was this topic helpful?