Discrete distribution
Geometric distribution
The number of independent trials needed to get the first success, counting the success itself: rolls of a die until the first six, calls until someone answers. It is the only discrete distribution without memory: having failed ten times does not make success any more due.
Geometric probability calculator
P(X ≤ 3) = 0.578125
At the parameters set by the sliders. The shaded region on the plot is the probability; the dots on the CDF mark F at its ends. For a discrete distribution, < and ≤ differ.
PMF
CDF
mean 4 · variance 12 · sd 3.464 · mode 1 · entropy 2.249 nats
Formulas
| Parameters |
|
|---|---|
| Support | |
| PMF | |
| CDF | |
| Mean | |
| Variance | |
| Mode | |
| MGF | |
| Entropy |
Some books count the failures before the first success instead, on , with mean . SciPy and NumPy both use the trials version shown here.
Worked example
You roll a fair die until a six appears. What is the probability that it takes more than 3 rolls?
It takes more than 3 rolls exactly when the first three are not sixes, so . On average it takes rolls. answer checked by code
How it relates to others
- Sum→ Negative binomial: If are independent Geometric() trial counts, (the failures) is Negative binomial(). checked by code
- Special case← Negative binomial: Negative binomial() counts failures before the first success, so adding 1 gives Geometric(). checked by code
- Limit→ Exponential: If is Geometric(), tends to Exponential() as : the continuous version of waiting for a success. checked by code
All the relationships, as a diagram →
In Python
from scipy import stats
import numpy as np
X = stats.geom(p=0.25)
X.pmf(3) # P(X = 3) = 0.1406
X.cdf(3) # P(X ≤ 3) = 0.5781
X.mean(), X.var() # 4, 12
X.ppf(0.95) # 95th percentile
X.rvs(size=10, random_state=0)
rng = np.random.default_rng(0)
rng.geometric(p=0.25, size=10)Choosing between this and its neighbours? Which distribution for count data? · Which distribution for waiting times and lifetimes?