({{, (RefLink[PascalDistribution, paclet:ref/PascalDistribution])[n,p] 
represents a Pascal distribution with parameters n and p.}})

OpenersNotesSection(Spacer1)Details

The probability for value x in a Pascal distribution is  (Binomial[x-1, n-1]) (((p^n)(1-p))^(x-n)) for x≥n, and is zero otherwise.

(RefLink[PascalDistribution, paclet:ref/PascalDistribution])[n,p] gives the distribution of the number of trials with nonzero success probability p before n successes occur.

(RefLink[PascalDistribution, paclet:ref/PascalDistribution]) allows n to be any positive integer and p any positive real number less than or equal to 1.

(RefLink[PascalDistribution, paclet:ref/PascalDistribution]) allows n and p to be dimensionless quantities. »

(RefLink[PascalDistribution, paclet:ref/PascalDistribution]) can be used with such functions as (RefLink[Mean, paclet:ref/Mean]), (RefLink[CDF, paclet:ref/CDF]), and (RefLink[RandomVariate, paclet:ref/RandomVariate]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (23)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Probability mass function:

DiscretePlot[Table[PDF[PascalDistribution[10,p],x],{p,{0.4,0.5,0.6}}]//Evaluate,{x,10,40},PlotMarkers->Automatic]

DiscretePlot[Table[PDF[PascalDistribution[n,0.4],x],{n,{5,8,10}}]//Evaluate,{x,5,40},PlotMarkers->Automatic]

PDF[PascalDistribution[n,p],x]

Cumulative distribution function:

DiscretePlot[Table[CDF[PascalDistribution[10,p],x],{p,{0.4,0.5,0.6}}]//Evaluate,{x,10,40},ExtentSize->Right]

DiscretePlot[Table[CDF[PascalDistribution[n,0.4],x],{n,{5,8,10}}]//Evaluate,{x,5,45},ExtentSize->Right]

CDF[PascalDistribution[n,p],x]

Mean and variance:

Mean[PascalDistribution[n,p]]

Variance[PascalDistribution[n,p]]

OpenersExampleSection1(Spacer1)Scope  (8)

Generate a sample of pseudorandom numbers from a Pascal distribution:

data=RandomVariate[PascalDistribution[10,0.3],10^4];

Compare its histogram to the PDF:

Show[
Histogram[data,{2},"PDF"],
DiscretePlot[PDF[PascalDistribution[10,0.3],x],{x,10,56},PlotStyle->PointSize[Medium]]]

Distribution parameters estimation:

sample=RandomVariate[PascalDistribution[5,.3],10^3];

Estimate the distribution parameters from sample data:

edist=EstimatedDistribution[sample,PascalDistribution[n,p]]

Compare the density histogram of the sample with the PDF of the estimated distribution:

Show[Histogram[sample,{1},"PDF"],DiscretePlot[PDF[edist,x],{x,5,40},PlotStyle->PointSize[Medium]]]

Skewness:

Plot[Table[Skewness[PascalDistribution[n,p]],{n,r={5,10,15,20}}]//Evaluate,{p,0,1},PlotLegends->(Row[{"n = ",#}]&/@r)]

Skewness[PascalDistribution[n,p]]

In the limit the distribution becomes more symmetric:

Limit[Skewness[PascalDistribution[n,p]],n->∞]

Limiting values:

Limit[Skewness[PascalDistribution[n,p]],p->0]

Limit[Skewness[PascalDistribution[n,p]],p->1,Direction->1,Assumptions->n>0]

Kurtosis:

Plot[Table[Kurtosis[PascalDistribution[n,p]],{n,r={5,10,15,20}}]//Evaluate,{p,0,1},PlotLegends->(Row[{"n = ",#}]&/@r)]

Kurtosis[PascalDistribution[n,p]]

The limiting value for large n is the kurtosis of standard (RefLink[NormalDistribution, paclet:ref/NormalDistribution]):

Limit[Kurtosis[PascalDistribution[n,p]],n->∞]

Kurtosis[NormalDistribution[]]

Limiting values:

Limit[Kurtosis[PascalDistribution[n,p]],p->0]

Limit[Kurtosis[PascalDistribution[n,p]],p->1,Direction->1,Assumptions->n>0]

Different moments with closed forms as functions of parameters:

FormulaGrid[list_,type_]:=Grid[Transpose[{list}],Alignment->{Left,Automatic},Background->{None,{{Lighter[Blend[Switch[type,M,{Blue,Green},CM,{Red,Orange},FM,{Magenta,Cyan},C,{Purple,Red}]],.8],White}}},Dividers->{None,{Darker[Gray,.6],{False},Darker[Gray,.6]}},ItemSize->30]

(RefLink[Moment, paclet:ref/Moment]):

FormulaGrid[Table[Moment[PascalDistribution[n,p],k]//Factor,{k,3}],M]

(RefLink[CentralMoment, paclet:ref/CentralMoment]):

FormulaGrid[Table[CentralMoment[PascalDistribution[n,p],k]//Factor,{k,3}],CM]

(RefLink[FactorialMoment, paclet:ref/FactorialMoment]):

FormulaGrid[Table[FactorialMoment[PascalDistribution[n,p],k]//Factor,{k,3}],FM]

Closed form for symbolic order:

FactorialMoment[PascalDistribution[n,p],r]

(RefLink[Cumulant, paclet:ref/Cumulant]):

FormulaGrid[Table[Cumulant[PascalDistribution[n,p],k]//Factor,{k,3}],C]

Hazard function:

DiscretePlot[Table[HazardFunction[PascalDistribution[10,p],x],{p,{0.3,0.45,0.6}}]//Evaluate,{x,10,30},PlotMarkers->Automatic]

DiscretePlot[Table[HazardFunction[PascalDistribution[n,0.4],x],{n,{5,7,10}}]//Evaluate,{x,10,30},PlotMarkers->Automatic]

HazardFunction[PascalDistribution[n,p],x]

Quantile function:

𝒟=PascalDistribution[2,.3];
points=Table[CDF[𝒟,x],{x,0,12}];

DiscretePlot[Quantile[𝒟,p],{p,points},ExtentSize->Right,ExtentMarkers->{"Empty","Filled"}]

Use dimensionless (RefLink[Quantity, paclet:ref/Quantity]) to define (RefLink[PascalDistribution, paclet:ref/PascalDistribution]):

PascalDistribution[Quantity[3+1/2,"Dozens"],Quantity[379,"PerMil"]]

OpenersExampleSection2(Spacer1)Applications  (7)

The (RefLink[CDF, paclet:ref/CDF]) of (RefLink[PascalDistribution, paclet:ref/PascalDistribution]) is an example of a right-continuous function:

DiscretePlot[CDF[PascalDistribution[2,.3],x],{x,0,10},ExtentSize->Right,ExtentMarkers->{"Filled","Empty"}]

The number of fair coin flips before 3 heads:

heads3=PascalDistribution[3,1/2];

Plot the distribution of the number of flips:

DiscretePlot[PDF[heads3,x],{x,3,10}]

Find the probability of getting 3 heads in no more than 6 flips:

Probability[x≤6,x\[Distributed]heads3]

N[%]

Find the average number of flips before getting 3 heads:

Mean[heads3]

Simulate the number of coin flips before getting 3 heads:

ListPlot[RandomVariate[heads3,20],Filling->Axis]

A coin was flipped 10 times and the (7^th) head occurred at the 10(^th) flip. Find the probability of such an event if the coin is fair:

fair𝒟=PascalDistribution[7,1/2];

Probability[x==10,x\[Distributed]fair𝒟]

N[%]

Assuming the coin may not be fair, find the most likely value for p:

𝒟=PascalDistribution[7,p];

Plot[PDF[𝒟,10],{p,0,1},Filling->Axis]

FindMaximum[PDF[𝒟,10],{p,0.9}]

A basketball player shoots free throws until he hits 4 of them. His probability of scoring in any one of them is 0.7. Simulate the process:

throws=RandomVariate[PascalDistribution[4,0.7],50]

ListPlot[throws,Filling->Axis]

Find the average number of throws until 4 hits:

Mean[PascalDistribution[4,0.7]]

Find the probability that the player needs exactly 4 shots:

Probability[x==4,x\[Distributed]PascalDistribution[4,0.7]]

Assume the probability of fouling for each minute interval is 0.1 independently. Simulate the fouling process for 30 minutes:

RandomVariate[BernoulliDistribution[0.1],30]

ListPlot[%,Filling->Axis]

A basketball player fouls out after 6 fouls. Find the expected playing time until foul out:

Mean[PascalDistribution[6,0.1]]

A data stream containing 4 data paclets is repeatedly sent without order information. Find the distribution of the number of tries until the data stream arrives with all the paclets in the right order for the second time:

𝒟=PascalDistribution[2,1/4!];

PDF[𝒟,x]

DiscretePlot[PDF[𝒟,x],{x,0,100}]

Find the probability that paclets will arrive the second time in the correct order on the 20(^th) try or sooner:

Probability[x≤20,x\[Distributed]𝒟]

N[%]

Find the average number of tries until the second ordered data stream:

Mean[𝒟]

Simulate the number of tries until the second ordered data stream:

flows=RandomVariate[𝒟,50]

ListPlot[{flows,{{0,Mean[𝒟]},{50,Mean[𝒟]}}},Joined->{False,True},Filling->Axis]

Messages are being broadcast through two channels, with equal success rates. Find the probability that no more than 5 broadcasts will be needed to ensure that each channel has received at least 3 messages:

Probability[Max[n1,n2]≤5,{n1\[Distributed]PascalDistribution[3,p],n2\[Distributed]PascalDistribution[3,p]}]

Plot[%,{p,0,1}]

OpenersExampleSection3(Spacer1)Properties & Relations  (5)

(RefLink[PascalDistribution, paclet:ref/PascalDistribution])[n,p] converges to a normal distribution when n->∞:

{μ,σ}={Mean[PascalDistribution[n,p]],StandardDeviation[PascalDistribution[n,p]]}

Block[{p=1/3},
Table[Show[DiscretePlot[PDF[PascalDistribution[n,p],k],{k,Ceiling[μ-2σ],Floor[μ+2σ]},PlotRange->{{μ-3σ,μ+2σ},All}],Plot[PDF[NormalDistribution[μ,σ],x],{x,μ-2σ,μ+2σ}],Ticks->{{{μ-2σ,HoldForm[μ-2σ]},{μ,HoldForm[μ]},{μ+2σ,HoldForm[μ+2σ]}},Automatic},PlotLabel->n],{n,{5,15,25,50}}]]

Sum of variates from Pascal distribution is a Pascal distribution:

TransformedDistribution[u+v,{u\[Distributed]PascalDistribution[(Subscript[n, 1]),p],v\[Distributed]PascalDistribution[(Subscript[n, 2]),p]}]

Relationships to other distributions:

(RefLink[GeometricDistribution, paclet:ref/GeometricDistribution]) is a transformation of Pascal distribution:

𝒟=TransformedDistribution[u-1,u\[Distributed]PascalDistribution[1,p]];

CDF[𝒟,x]

CDF[GeometricDistribution[p],x]

FullSimplify[%-%%]

(RefLink[NegativeBinomialDistribution, paclet:ref/NegativeBinomialDistribution]) and Pascal distribution differ by a shift:

TransformedDistribution[u+n,u\[Distributed]NegativeBinomialDistribution[n,p]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[BinomialDistribution, paclet:ref/BinomialDistribution])  ▪  (RefLink[GeometricDistribution, paclet:ref/GeometricDistribution])  ▪  (RefLink[BernoulliDistribution, paclet:ref/BernoulliDistribution])  ▪  (RefLink[NegativeBinomialDistribution, paclet:ref/NegativeBinomialDistribution])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Discrete Distributions, paclet:tutorial/DiscreteDistributions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Discrete Univariate Distributions, paclet:guide/DiscreteUnivariateDistributions])}})}})