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;
> p:=0.5;
> PlotDiscCDF(NegBinomialPDF(r,p,x),1..20);
>
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;
> p:=0.5;
> f:=x->NegBinomialPDF(r,p,x);
> F:=x->NegBinomialCDF(r,p,x);
Below you will find three different ways to calculate P(4<= X <= 8).
> evalf(f(4)+f(5)+f(6)+f(7)+f(8));
> evalf(sum(f(x),x=4..8));
> evalf(F(8));