({{, (RefLink[GeometricDistribution, paclet:ref/GeometricDistribution])[p] 
represents a geometric distribution with probability parameter p. }})

OpenersNotesSection(Spacer1)Details

The probability for value x in a geometric distribution is ((p(1-p))^x) for non-negative integers, and is zero otherwise. »

(RefLink[GeometricDistribution, paclet:ref/GeometricDistribution])[p] is the distribution of the number of failures in a sequence of trials with success probability p before a success occurs.

(RefLink[GeometricDistribution, paclet:ref/GeometricDistribution]) allows p to be a dimensionless quantity. »

(RefLink[GeometricDistribution, paclet:ref/GeometricDistribution]) 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  (32)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Probability mass function:

DiscretePlot[Table[PDF[GeometricDistribution[p],k],{p,{0.1,0.2,0.4}}]//Evaluate,{k,15},PlotMarkers->Automatic,PlotRange->All]

PDF[GeometricDistribution[p],k]

Cumulative distribution function:

DiscretePlot[Table[CDF[GeometricDistribution[p],k],{p,{0.1,0.2,0.5}}]//Evaluate,{k,0,14},ExtentSize->Right]

CDF[GeometricDistribution[p],k]

Mean and variance of a geometric distribution:

Mean[GeometricDistribution[p]]

Variance[GeometricDistribution[p]]

OpenersExampleSection1(Spacer1)Scope  (8)

Generate a sample of pseudorandom numbers from a geometric distribution:

data=RandomVariate[𝒹=GeometricDistribution[.1],10^4];

Compare its histogram to the PDF:

Show[
Histogram[data,{2},"PDF"],
DiscretePlot[PDF[𝒹,x],{x,0,40},PlotStyle->PointSize[Medium]]]

Distribution parameters estimation:

sample=RandomVariate[GeometricDistribution[.3],10^3];

Estimate the distribution parameters from sample data:

edist=EstimatedDistribution[sample, GeometricDistribution[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,0,15},PlotStyle->PointSize[Medium]]]

Skewness:

Plot[Skewness[GeometricDistribution[p]],{p,0,1},Filling->Axis]

Skewness[GeometricDistribution[p]]

Limiting values:

Limit[Skewness[GeometricDistribution[p]],p->0]

Limit[Skewness[GeometricDistribution[p]],p->1,Direction->1]

Kurtosis:

Plot[Kurtosis[GeometricDistribution[p]],{p,0,1},Filling->Axis]

Kurtosis[GeometricDistribution[p]]

Limiting values:

Limit[Kurtosis[GeometricDistribution[p]],p->0]

Limit[Kurtosis[GeometricDistribution[p]],p->1,Direction->1]

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[GeometricDistribution[p],k]//Together,{k,3}],M]

Closed form for symbolic order:

Moment[GeometricDistribution[p],r]

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

FormulaGrid[Table[CentralMoment[GeometricDistribution[p],k]//Together,{k,3}],CM]

Closed form for symbolic order:

CentralMoment[GeometricDistribution[p],r]

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

FormulaGrid[Table[FactorialMoment[GeometricDistribution[p],k],{k,3}],FM]

Closed form for symbolic order:

FactorialMoment[GeometricDistribution[p],r]

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

FormulaGrid[Table[Cumulant[GeometricDistribution[p],k]//Together,{k,3}],C]

Hazard function is constant:

HazardFunction[GeometricDistribution[p],x]

Quantile function:

𝒟=GeometricDistribution[.3];
points=N[Table[CDF[𝒟,x],{x,0,6}]];

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

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

𝒟=GeometricDistribution[(QuantityPostfix[25, "%", percent, "Percent"])]

OpenersExampleSection2(Spacer1)Applications  (11)

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

DiscretePlot[CDF[GeometricDistribution[.7],x],{x,0,4},ExtentSize->Right,ExtentMarkers->{"Filled","Empty"}]

A coin-tossing experiment consists of tossing a fair coin repeatedly until a tail results. Simulate the process:

RandomVariate[GeometricDistribution[1/2],10]

ListPlot[RandomVariate[GeometricDistribution[1/2],100],Filling->Axis]

Compute the probability that at least 4 coin tosses will be necessary:

Probability[x≥4,x\[Distributed]GeometricDistribution[1/2]]

Compute the expected number of coin tosses:

Mean[GeometricDistribution[1/2]]

A person is standing by a road counting cars until he sees a red one, at which point he restarts the count. Simulate the counting process, assuming that 20% of the cars are red:

RandomVariate[GeometricDistribution[0.2],20]

ListPlot[%,Filling->Axis]

Find the expected number of cars to come by before the count starts over:

Mean[GeometricDistribution[0.2]]

Find the probability of counting 10 or more cars before a red one:

NProbability[x≥10,x\[Distributed]GeometricDistribution[0.2]]

A student will take a test repeatedly until he or she passes it, each time succeeding with probability p. Find the probability that the student succeeds in k attempts or less:

prob1=Probability[x≤k,x\[Distributed]GeometricDistribution[p],Assumptions->k∈Integers&&k≥0]

Block[{p=1/3},DiscretePlot[prob1,{k,10}]]

Given that the student passes the test in n attempts or less, find the PDF:

prob2=Probability[x==k\[Conditioned]x≤n,x\[Distributed]GeometricDistribution[p],Assumptions->{k,n}∈Integers&&n>0]//FullSimplify

Block[{p=1/3,n=3},DiscretePlot[prob2,{k,10}]]

A budget-priced lighter has 90% probability of lighting on any given attempt. Simulate the lighting process; the result indicates the number of failures before successful lighting:

BarChart[RandomVariate[GeometricDistribution[(QuantityPostfix[90, "%", percent, "Percent"])],100]]

Find the probability that the lighter lights in 3 trials or less:

NProbability[x≤3,x\[Distributed]GeometricDistribution[(QuantityPostfix[90, "%", percent, "Percent"])]]

A cereal box contains one out of a set of n different plastic animals. The animals are equally likely to occur, independently of what animals are in other boxes. Simulate the animal collection process, assuming there are 10 animals for 25 boxes:

RandomVariate[DiscreteUniformDistribution[{1,10}],25]

After k unique animals have been collected, the number of boxes needed to find a new unique animal among the remaining n-k follows a geometric distribution with parameter 1-k/n. Find the expected number of boxes needed to get a new unique animal:

e=Expectation[x+1,x\[Distributed]GeometricDistribution[1-k/n]]

Number of boxes before next unique animal:

Block[{n=5},DiscretePlot[e,{k,1,n-1},ExtentSize->1/2]]

Find the expected number of boxes needed to collect 6 unique animals:

Block[{n=5},Sum[e,{k,0,n-1}]]

N[%]

When a computer accesses memory, the desired data is in the cache with probability p. A cache miss occurs if the desired data is not in the cache. Find the probability of a cache miss on the k(^th) memory access:

CacheMissDistribution[p_]:=TransformedDistribution[a+1,a\[Distributed]GeometricDistribution[1-p]]

Simplify[PDF[CacheMissDistribution[p],k],k∈Integers]

Table[PDF[CacheMissDistribution[p],k],{k,3}]

Find the probability that the first cache miss occurs after the 4(^th) memory access:

Probability[k>4,k\[Distributed]CacheMissDistribution[p]]

Find the average number of memory accesses before the first cache miss:

Mean[CacheMissDistribution[p]]

Simulate the number of cache hits before a cache miss occurs, assuming 20% of your data is in the cache:

ListPlot[RandomVariate[CacheMissDistribution[0.2],50],Frame->True,Filling->Axis]

Assuming that access time is 10 ns for cache and 1000 ns for RAM, find the average access time:

pmiss=PDF[CacheMissDistribution[0.2],1]

Quantity[1000,"ns"] pmiss+Quantity[10,"ns"] (1-pmiss)

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

𝒟=GeometricDistribution[1/4!];

PDF[𝒟,x]

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

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

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

N[%]

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

flows=RandomVariate[𝒟,50]

ListPlot[flows,Filling->Axis]

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

Mean[𝒟]

A player bets amount a in a casino with no betting limit in a game with chance of winning p. If he loses he doubles the bet, and if he wins he quits, hence the number of games played follows a geometric distribution, with expected number of games played represented as follows:

Expectation[k+1,k\[Distributed]GeometricDistribution[p]]

The cash reserve needed to win the k(^th) game:

cashReserve[k_]=Sum[a (2^(n-1)),{n,1,k-1}]

The player always leaves the casino collecting the amount of the initial bet:

a (2^(k-1))- cashReserve[k]//Simplify

The cash reserve needed to execute the above strategy is finite only for strictly favorable games, where 1/2<p≤1:

Expectation[cashReserve[k+1],k\[Distributed]GeometricDistribution[p],GenerateConditions->True]

In an optical communication system, transmitted light generates current at the receiver. The number of electrons follows the parametric mixture of Poisson distribution and other distributions, depending on the type of light. If the source uses coherent laser light of intensity λ, then the electron count distribution is Poisson:

Bdist=TransformedDistribution[λ x,x\[Distributed]BernoulliDistribution[1]];

PDF[Bdist,x]//Refine[#,λ>0]&

𝒟1=ParameterMixtureDistribution[PoissonDistribution[μ],μ\[Distributed]Bdist];

PDF[𝒟1,x]

Which is (RefLink[PoissonDistribution, paclet:ref/PoissonDistribution]):

PDF[PoissonDistribution[λ],x]

If the source uses thermal illumination, then the Poisson parameter follows (RefLink[ExponentialDistribution, paclet:ref/ExponentialDistribution]) with parameter 1/λ, and the electron count distribution is:

𝒟2=ParameterMixtureDistribution[PoissonDistribution[μ],μ\[Distributed]ExponentialDistribution[1/λ]]

These two distributions are distinguishable and allow you to determine the type of source:

Block[{λ=3},Histogram[{RandomVariate[𝒟1,10^3],RandomVariate[𝒟2,10^3]},{1},"PDF"]]

Find the sampling population expectation of the method of moment estimator for p:

Solve[Mean[GeometricDistribution[p]]==Mean[data],p]

{MMEstimator[data_]}=p/.%

Find sampling population expectations for a few small sample sizes:

{e1,e2,e3,e4,e5}=Table[Expectation[MMEstimator[Array[k,s]],Array[k,s]\[Distributed]ProductDistribution[{GeometricDistribution[p],s}]],{s,5}]

Prove that these are positively biased:

Reduce[(e1<=p||e2≤p||e3≤p||e4≤p||e5≤p)&&0<p<1,p,Reals]

Plot the bias:

Plot[{e1,e2,e3,e4,e5}-p//Evaluate,{p,0,1},WorkingPrecision->20]

OpenersExampleSection3(Spacer1)Properties & Relations  (8)

The geometric distribution has the memoryless property:

Probability[x>m+k\[Conditioned]x>=m,x\[Distributed]GeometricDistribution[p],Assumptions->k>0&&m>0&&{k,m}∈Integers]

Probability[x>k,x\[Distributed]GeometricDistribution[p],Assumptions->k>0&&k∈Integers]

FullSimplify[%-%%]

The family of (RefLink[GeometricDistribution, paclet:ref/GeometricDistribution]) is closed under (RefLink[Min, paclet:ref/Min]):

TransformedDistribution[Min[x,y],{x\[Distributed]GeometricDistribution[p1],y\[Distributed]GeometricDistribution[p2]}]

And for identically distributed variables:

OrderDistribution[{GeometricDistribution[p],n},1]

Relationships to other distributions:

(RefLink[NegativeBinomialDistribution, paclet:ref/NegativeBinomialDistribution]) simplifies to geometric distribution:

PDF[NegativeBinomialDistribution[1,p],k]

PDF[GeometricDistribution[p],k]

%-%%

Sum of n independent geometric variables has (RefLink[NegativeBinomialDistribution, paclet:ref/NegativeBinomialDistribution]):

TransformedDistribution[u+v+x+y+z,{u,v,x,y,z}\[Distributed]ProductDistribution[{GeometricDistribution[p],5}]]

Proof for the general case:

CharacteristicFunction[GeometricDistribution[p],t]^n

CharacteristicFunction[NegativeBinomialDistribution[n,p],t]

%-%%

Geometric distribution is a transformation of (RefLink[PascalDistribution, paclet:ref/PascalDistribution]):

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

CDF[𝒟,x]

CDF[GeometricDistribution[p],x]

FullSimplify[%-%%]

(RefLink[WaringYuleDistribution, paclet:ref/WaringYuleDistribution]) is a parameter mixture of geometric distribution and (RefLink[UniformDistribution, paclet:ref/UniformDistribution]):

𝒟=ParameterMixtureDistribution[GeometricDistribution[(w^(1/a))],w\[Distributed]UniformDistribution[],Assumptions->a>0];

PDF[𝒟,k]

PDF[WaringYuleDistribution[a],k]

FullSimplify[%-%%]

Geometric distribution is a parameter mixture of (RefLink[PoissonDistribution, paclet:ref/PoissonDistribution]) and (RefLink[GammaDistribution, paclet:ref/GammaDistribution]):

ParameterMixtureDistribution[PoissonDistribution[μ],μ\[Distributed]GammaDistribution[1,(1-p)/p]]

It is the same as the mixture with an (RefLink[ExponentialDistribution, paclet:ref/ExponentialDistribution]):

ParameterMixtureDistribution[PoissonDistribution[μ],μ\[Distributed]ExponentialDistribution[p/(1-p)]]

OpenersExampleSection4(Spacer1)Possible Issues  (2)

(RefLink[GeometricDistribution, paclet:ref/GeometricDistribution]) is not defined when p is not between zero and one:

Mean[GeometricDistribution[2.4]]

Substitution of invalid parameters into symbolic outputs gives results that are not meaningful:

Mean[GeometricDistribution[p]]/.{p->-1000}

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

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

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Urn Model Distributions, paclet:guide/UrnModelDistributions])}, {▪(RefLinkPlain[Discrete Univariate Distributions, paclet:guide/DiscreteUnivariateDistributions])}, {▪(RefLinkPlain[Distributions in Reliability Analysis, paclet:guide/DistributionsUsedInReliabilityAnalysis])}, {▪(RefLinkPlain[Distributions Used in Actuarial Science, paclet:guide/DistributionsUsedInActuarialScience])}})}})