Sample Probability Calculations

Sample Probability Calculations

The following code will draw a graph of the cumulative distribution function (CDF) for the

Negative Binomial ( r , p ) distribution for your choice of p .

> r:=4;

[Maple Math]

> p:=0.5;

[Maple Math]

> PlotDiscCDF(NegBinomialPDF(r,p,x),1..20);

[Maple Plot]

>

We can calculate probabilities for the Negative Binomial ( r , p ) distribution using either the probability

distribution function (PDF) or the cumulative distribution function (CDF). We will denote

the PDF by f and the CDF by F .

> r:=4;

[Maple Math]

> p:=0.5;

[Maple Math]

> f:=x->NegBinomialPDF(r,p,x);

[Maple Math]

> F:=x->NegBinomialCDF(r,p,x);

[Maple Math]

Below you will find three different ways to calculate P(4<= X <= 8).

> evalf(f(4)+f(5)+f(6)+f(7)+f(8));

[Maple Math]

> evalf(sum(f(x),x=4..8));

[Maple Math]

> evalf(F(8));

[Maple Math]