Code
k <- 0:9
mass <- 2^(-(k + 1))
plot(k, mass, type = "h", lwd = 5, lend = 1, col = "#B2182B",
xlab = "k", ylab = "Probability",
main = "PMF defined by a geometric series", bty = "l")
points(k, mass, pch = 19, col = "#B2182B")
The original notes introduce the geometric family from the geometric series
\sum_{k=0}^{\infty}\frac{1}{2^{k+1}}=1.
Thus p_K(k)\equiv2^{-(k+1)}, for k=0,1,2,\ldots, is a probability mass function (PMF) with countably infinite support.

Let K count failures before the first success in independent Bernoulli trials with common success probability \pi\in(0,1]. We define
K\sim\operatorname{Geometric}(\pi)
by
p_K(k) \equiv\mathbb P(K=k) =(1-\pi)^k\pi, \qquad k=0,1,2,\ldots.
This is the convention used by dgeom in R. If T counts total trials through the first success, then T\equiv K+1 and
\mathbb P(T=t)=(1-\pi)^{t-1}\pi, \qquad t=1,2,\ldots.
Suppose we sample word tokens until the first loanword, with constant loanword probability \pi=.20. The event K=k requires k nonloanwords followed by one loanword. Independence gives
\mathbb P(K=k)=(.80)^k(.20).
Thus
\begin{aligned} p_K(0)&=.20,\\ p_K(1)&=.80(.20)=.16,\\ p_K(2)&=.80^2(.20)=.128,\\ p_K(3)&=.80^3(.20)=.1024. \end{aligned}
The event K\geq4 requires four initial failures, so
\mathbb P(K\geq4)=.80^4=.4096
and \mathbb P(T\leq4)=1-.4096=.5904.
The following graphs reproduce the \pi=.5, .1, and .9 sequence from the original notes.
plot_geometric <- function(probability) {
k <- 0:9
mass <- dgeom(k, prob = probability)
plot(k, mass, type = "h", lwd = 5, lend = 1, col = "#B2182B",
xlab = "Failures before the first success", ylab = "Probability",
main = sprintf("PMF of Geometric(%.1f)", probability), bty = "l")
points(k, mass, pch = 19, col = "#B2182B")
}
plot_geometric(.5)


For every k\geq0,
\frac{p_K(k+1)}{p_K(k)} =1-\pi<1.
Thus every nondegenerate geometric PMF is strictly decreasing. Its mode is K=0. If L\equiv K+1 represents positive word length, its mode is necessarily L=1. The negative-binomial page compares this restriction with the empirical distribution of phoneme counts in CMUdict.
Under this convention,
\mathbb E[K]=\frac{1-\pi}{\pi}, \qquad \operatorname{Var}(K)=\frac{1-\pi}{\pi^2}.
---
title: "The geometric distribution"
execute:
enabled: true
echo: true
warning: false
message: false
---
The original notes introduce the geometric family from the geometric series
$$
\sum_{k=0}^{\infty}\frac{1}{2^{k+1}}=1.
$$
Thus $p_K(k)\equiv2^{-(k+1)}$, for $k=0,1,2,\ldots$, is a probability mass function (PMF) with countably infinite support.
```{r}
k <- 0:9
mass <- 2^(-(k + 1))
plot(k, mass, type = "h", lwd = 5, lend = 1, col = "#B2182B",
xlab = "k", ylab = "Probability",
main = "PMF defined by a geometric series", bty = "l")
points(k, mass, pch = 19, col = "#B2182B")
```
## Definition and convention
Let $K$ count failures before the first success in independent Bernoulli trials with common success probability $\pi\in(0,1]$. We define
$$
K\sim\operatorname{Geometric}(\pi)
$$
by
$$
p_K(k)
\equiv\mathbb P(K=k)
=(1-\pi)^k\pi,
\qquad k=0,1,2,\ldots.
$$
This is the convention used by `dgeom` in R. If $T$ counts total trials through the first success, then $T\equiv K+1$ and
$$
\mathbb P(T=t)=(1-\pi)^{t-1}\pi,
\qquad t=1,2,\ldots.
$$
## Constructing the PMF from trial sequences
Suppose we sample word tokens until the first loanword, with constant loanword probability $\pi=.20$. The event $K=k$ requires $k$ nonloanwords followed by one loanword. Independence gives
$$
\mathbb P(K=k)=(.80)^k(.20).
$$
Thus
$$
\begin{aligned}
p_K(0)&=.20,\\
p_K(1)&=.80(.20)=.16,\\
p_K(2)&=.80^2(.20)=.128,\\
p_K(3)&=.80^3(.20)=.1024.
\end{aligned}
$$
The event $K\geq4$ requires four initial failures, so
$$
\mathbb P(K\geq4)=.80^4=.4096
$$
and $\mathbb P(T\leq4)=1-.4096=.5904$.
## The original parameter sequence
The following graphs reproduce the $\pi=.5$, $.1$, and $.9$ sequence from the original notes.
```{r}
plot_geometric <- function(probability) {
k <- 0:9
mass <- dgeom(k, prob = probability)
plot(k, mass, type = "h", lwd = 5, lend = 1, col = "#B2182B",
xlab = "Failures before the first success", ylab = "Probability",
main = sprintf("PMF of Geometric(%.1f)", probability), bty = "l")
points(k, mass, pch = 19, col = "#B2182B")
}
plot_geometric(.5)
plot_geometric(.1)
plot_geometric(.9)
```
For every $k\geq0$,
$$
\frac{p_K(k+1)}{p_K(k)}
=1-\pi<1.
$$
Thus every nondegenerate geometric PMF is strictly decreasing. Its mode is $K=0$. If $L\equiv K+1$ represents positive word length, its mode is necessarily $L=1$. The [negative-binomial page](negative-binomial-distribution.qmd) compares this restriction with the empirical distribution of phoneme counts in CMUdict.
Under this convention,
$$
\mathbb E[K]=\frac{1-\pi}{\pi},
\qquad
\operatorname{Var}(K)=\frac{1-\pi}{\pi^2}.
$$