What is a Geometric Random Variable?
The geometric distribution arises when we repeat the same kind of trial until something happens. For instance, we might keep flipping a coin until we get “heads”.
Each trial must have exactly two possible outcomes, which we call “success” and “failure”. The trials must be independent, and the probability of success, $p$, must be the same each time.
A geometric random variable $X$ records the number of trials needed to get a “success” for the first time. In the above example, we are therefore thinking of “heads” as a success.
We write
$$X\sim\operatorname{Geom}(p).$$
Since we must perform at least one trial to get a success, the possible values of $X$ are:
$$1,2,3,\dots$$
Of course, the trials do not have to involve coins at all. The same distribution can be used whenever we repeat a series of independent success-or-failure trials, with the same probability of success each time, until the first success occurs.
Finding Geometric Probabilities
Suppose, for example, we want to find the probability that the first success occurs on trial $5$.
For this to happen, we need four failures followed by one success:
$$F\ F\ F\ F\ S.$$
The probability of a failure is $1-p$, while the probability of a success is $p$. Since the trials are independent,
$$\mathbb{P}(X=5)=(1-p)^4p.$$
More generally, for $X=k$ we need $k-1$ failures followed by one success. So,
$$\mathbb{P}(X=k)=(1-p)^{k-1}p,$$
for
$$k=1,2,3,\dots$$
This is the pmf of the geometric distribution.
Cumulative Probabilities
With the geometric distribution, the probability that $X \ge k$ has a particularly simple form.
For example, suppose we want the probability that it takes at least five trials to get the first success.
For this to happen, the first four trials must all be failures. Then it will take at least $5$ flips, regardless of whether or not a success comes on trial $5$.
So,
$$\mathbb{P}(X\geq5)=(1-p)^4.$$
More generally,
$$\mathbb{P}(X\geq k)=(1-p)^{k-1}.$$
We can use this to find the cdf. For a possible value $k$,
$$F_X(k)=\mathbb{P}(X\leq k).$$
The event $X\leq k$ means that the first success occurs within the first $k$ trials. Its opposite is that all of the first $k$ trials are failures.
So,
$$F_X(k)=1-(1-p)^k.$$
Mean and Variance
For a geometric random variable,
$$\mathbb{E}(X)=\frac{1}{p}.$$
For example, with a fair coin,
$$p=\frac{1}{2},$$
so
$$\mathbb{E}(X)=2.$$
On average, we therefore need two flips to obtain heads for the first time.
The variance is
$$\operatorname{Var}(X)=\frac{1-p}{p^2}.$$
A Different Convention
Confusingly, there is actually a second common definition of the geometric distribution.
On this page, $X$ counts the total number of trials needed to obtain the first success, including the successful trial itself. Its possible values are therefore
$$1,2,3,\dots$$
Some authors instead define a geometric random variable as the number of failures before the first success. Under that convention, the possible values are
$$0,1,2,\dots$$
So it is always worth checking which convention is being used.
Explore the Geometric pmf
The shape of a geometric distribution changes when we change its parameter $p$.
The interactive graph below shows the first $10$ possible values. The geometric distribution itself can continue beyond $10$, since it might take any number of flips to get heads!
The horizontal axis shows the number of trials, $k$, and each bar has height $\mathbb{P}(X=k)$.
Try changing $p$, the probability of success on each trial.
Notice how the probabilities change as $p$ changes!
You can also choose a particular value of $k$ to see the corresponding probability $\mathbb{P}(X=k)$.
Geometric Distribution Summary
| Notation: | $X\sim\operatorname{Geom}(p)$ |
| Type: | Discrete |
| Meaning: | Number of trials needed to obtain the first success |
| Parameter: | $p$ = probability of success on each trial |
| pmf: | $\mathbb{P}(X=k)=(1-p)^{k-1}p$ |
| Support: | $k\in{1,2,3,\dots}$ |
| cdf: | $F_X(k)=1-(1-p)^k$ |
| Mean: | $\mathbb{E}(X)=1/p$ |
| Variance: | $\operatorname{Var}(X)=\frac{1-p}{p^2}$ |
Background:
Understanding Econometrics is completely free to use, and always will be.
If you found the site useful and would like to help me keep adding new material, please consider buying me a coffee! Buy me a coffee ☕