Geometric distribution
Geometric distribution: the number of trials until the first success. With the default parameters (probability of success p = 0.25) its mean is 4 and its standard deviation 3.4641. Use the simulator below to draw samples and see it take shape.
Simulate it
Change the parameters, then draw random samples. The bars are the samples; the dots are the exact probabilities. With more samples the bars settle onto it.
Samples to draw
What is the geometric distribution?
The geometric distribution counts how many independent trials you need until the first success, when each trial succeeds with probability p. How many rolls until the first six? How many calls until the first sale? How many attempts until the test is passed?
Its distinctive property is that it has no memory: however many failures you have had, the chance of success on the next trial is still p. That is why a run of bad luck does not make a success any more likely to come next.
Where it is used
- Rolls of a die until the first six.
- Sales calls until the first sale.
- Attempts at a driving test until the first pass.
- Days until the first machine failure when each day carries the same risk.
- Packets sent until the first one is lost.
Shape and parameters
The probabilities fall off by a constant factor 1 − p at each step, so the most likely value is always 1 and the distribution has a long right tail that is longer when p is small. The mean 1/p is the typical number of trials needed.
What it assumes
- Independent trials.
- The same probability p of success on every trial.
- You stop at the first success.
How it relates to other distributions
- Negative binomial distribution: The number of trials until the r-th success is negative binomial; r = 1 gives the geometric.
- Exponential distribution: The geometric is the discrete counterpart of the exponential: both are memoryless.
- Bernoulli distribution: Each trial is a Bernoulli trial.
Common mistakes
- Mixing up the two conventions: counting the trials including the success (here, starting at 1) or only the failures before it (starting at 0). R's dgeom counts failures.
- Expecting a success to be 'due' after a run of failures.
How to work it out
- 1
The probability mass function (the formula that gives the shape):
- 2
Its mean (the long-run average) and variance (the spread):
- 3
Worked example with the default parameters (probability of success p = 0.25): With p = 0.25, what is the probability that the first success comes within 3 trials?
LaTeX source of the formulas on this page
\[ P(X=k)=(1-p)^{k-1}p \]
\[ \mu = \frac{1}{p},\qquad \sigma^2 = \frac{1-p}{p^2} \]
\[ \text{answer} = 0.5781 \]At a glance
| Property | Value |
|---|---|
| Type | Discrete (counts) |
| Parameters | probability of success p |
| Possible values | 1, 2, 3, … |
| Mean | 4 |
| Variance | 12 |
| Standard deviation | 3.4641 |
| Example (probability of success p = 0.25) | With p = 0.25, what is the probability that the first success comes within 3 trials? Answer: 0.5781. |
How to compute it in Excel, Python and R
| Tool | Function |
|---|---|
| Excel / Google Sheets | =(1-p)^(k-1)*p (Excel has no geometric function) |
| Python (SciPy) | scipy.stats.geom.pmf(k, p) |
| R | dgeom(k - 1, p) (R counts failures before the first success) |
Questions
What is the geometric distribution used for?
The number of trials until the first success. Typical uses: Rolls of a die until the first six. Sales calls until the first sale. Attempts at a driving test until the first pass.
What are the mean and variance of the geometric distribution?
Mean: μ = (1)/(p). Variance: σ² = (1-p)/(p²).
What does the geometric distribution assume?
Independent trials. The same probability p of success on every trial. You stop at the first success.
How do I calculate it in Excel?
=(1-p)^(k-1)*p (Excel has no geometric function)
How is the geometric distribution related to other distributions?
Negative binomial distribution: The number of trials until the r-th success is negative binomial; r = 1 gives the geometric. Exponential distribution: The geometric is the discrete counterpart of the exponential: both are memoryless. Bernoulli distribution: Each trial is a Bernoulli trial.