Geometric distribution (source code)

= Geometric distribution
{title2=$\operatorname{Geom}(p)$}
{wiki}

= Geometrically distributed
{synonym}

= Geometric random variable
{synonym}

Consider successive <independent> <Bernoulli trials> with the same success <probability> $0<p\leq1$. A <geometric distribution> models waiting for their first success. Two conventions coexist, so always say what is counted. Let $T$ count all trials up to and including the successful trial, and let $F=T-1$ count preceding failures. Their <probability mass functions> are
$$
\mathbb P(T=k)=(1-p)^{k-1}p,\quad k=1,2,\ldots,
\qquad
\mathbb P(F=j)=(1-p)^jp,\quad j=0,1,\ldots.
$$
The factors describe failures followed by one success; <independence> permits multiplication. Summing the <geometric series> verifies that each law has total mass one. Their <expected values> differ by one, while shifting by a constant leaves the <variance> unchanged:
$$
\mathbb E T=\frac1p,\qquad \mathbb E F=\frac{1-p}{p},\qquad
\operatorname{Var}(T)=\operatorname{Var}(F)=\frac{1-p}{p^2}.
$$
The positive convention and these moments are also given by Penn State STAT 414.<STAT 414: Introduction to Probability Theory at Pennsylvania State University/11 Geometric and Negative Binomial Distributions>[STAT 414: Introduction to Probability Theory at Pennsylvania State University; §11.1, Definition 11.1; §11.2, mean and variance theorems]{ref}

For a constructed retry mechanism with <independent> attempts and $p=0.3$, success on attempt four has <probability> $\mathbb P(T=4)=0.7^3(0.3)=0.1029$. More than four attempts are needed precisely when the first four fail: $\mathbb P(T>4)=0.7^4=0.2401$. The <expected values> are $\mathbb E T=10/3$ and $\mathbb E F=7/3$, and the common <variance> is $70/9\approx7.7778$. The large spread explains why the average waiting count is not a deadline.

\Image[/geometric-distribution-counting-conventions.png]
{title=First-success trial versus preceding failures: the same probability masses shifted by one}

The two <probability mass functions> have identical heights with different labels: $T=4$ and $F=3$ describe the same <event>. For $0<p<1$, consecutive masses have ratio $1-p$, explaining the name <geometric distribution>. The <support of a probability distribution> is the positive <integers> for $T$ and the nonnegative <integers> for $F$. At $p=1$, it collapses to $T=1$ and $F=0$, both with <variance> zero; interpret an empty product, including $(1-p)^0$, as one. These counts concern attempts; converting them into elapsed time requires specifying the time spent per attempt.

The <survival function> makes the counting convention especially visible. Put $q=1-p$. For nonnegative <integers> $n$, and for $k\geq1$,
$$
\mathbb P(T>n)=q^n,\qquad \mathbb P(T\leq n)=1-q^n,\qquad
\mathbb P(T\geq k)=q^{k-1},\qquad
\mathbb P(F\geq n)=q^n,\qquad \mathbb P(F>n)=q^{n+1}.
$$
The <event> $T>n$ requires $n$ failures, whereas $T\geq n$ requires only $n-1$ when $n\geq1$. For the constructed $p=0.3$ mechanism, $\mathbb P(T\geq4)=0.343$ differs from $\mathbb P(T>4)=0.2401$. The <geometric success deadline> uses the latter tail to control the chance of still waiting.

The striking <memorylessness of the geometric distribution> says that, for nonnegative integers $m,r$ with $\mathbb P(T>m)>0$,
$$
\mathbb P(T>m+r\mid T>m)=\frac{(1-p)^{m+r}}{(1-p)^m}
=(1-p)^r=\mathbb P(T>r).
$$
After five failures, the <conditional probability> of requiring more than two additional attempts is still $0.7^2=0.49$. The analogous zero-based identity uses $\mathbb P(F\geq m+r\mid F\geq m)=\mathbb P(F\geq r)$; keeping the inequalities straight avoids an off-by-one error. This property follows from fresh <independent> trials with unchanged $p$; learning or changing conditions can destroy it. At $p=0$, success never occurs, so there is no proper finite waiting-count law.