Concept map / Geometric distribution

Share

The geometric distribution

Count independent draws through the first success, see why the first draw is always the most likely, and check memorylessness.

1Keep drawing until the first success

Draw a card, put it back, and repeat until a marked card turns up. Each draw is a Bernoulli trial with the same chance of success p. The number of draws it takes, counting the successful one, has a geometric distribution.

At p = 0.25, how many draws does a person usually need, and how long can an unlucky run last? Set p, pick a draw k to read its probability, and simulate people to compare their runs with the bars.

0.00.20.415101520ProbabilityDraw on which the first success happens (k)
P(X = 4)Other draws

One way to first succeed on draw 4: 3 failures, then a success

With p = 0.25 on each draw, the first success comes on draw 4 with probability 10.5%, and the chance of needing more than 4 draws is 31.6%. Draw 1 is always the most likely (25.0%), even though the mean is 4.00 draws.

More controls

2Predict the most likely draw

Each draw succeeds with probability p = 0.20, so on average a person needs 1/p = 5 draws to reach the first success. On which single draw is the first success most likely to happen?

3Failures, then one success

A first success on draw k needs k − 1 failures in a row and then a success. The draws are independent, so their probabilities multiply. Point at a term and the matching cards in section 1 light up.

P(X=k)=(1−p)k−1  pP(X>k)=(1−p)k\begin{gathered} P(X = k) = \htmlClass{term-fail}{(1-p)^{k-1}}\;\htmlClass{term-succ}{p} \\ P(X > k) = \htmlClass{term-fail}{(1-p)^{k}} \end{gathered}

Now: P(X = 4) = 0.753 × 0.25 = 0.105. The mean is 1/p = 4.00 and the variance is (1 − p)/p² = 12.00.

Why earlier failures change nothing
P(X>m+j∣X>m)=(1−p)m+j(1−p)m=(1−p)j\begin{gathered} P(X > m + j \mid X > m) \\ = \frac{(1-p)^{m+j}}{(1-p)^{m}} = (1-p)^{j} \end{gathered}

After m failures, the chance of needing more than j further draws is what it was at the start. This is called memorylessness. A run of failures does not make a success due.

4Check yourself

The tasks use the sliders and buttons in section 1 and tick themselves when you meet them.

  • Set p so that the expected number of draws through the first success is 5.Now: p = 0.25, E[X] = 4.00 draws
  • Make the chance of needing more than 10 draws smaller than 5%.Now: P(X > 10) = 5.6%
  • With p = 0.10, simulate at least 500 people and get their average number of draws within 0.5 of 1/p = 10.Now: p = 0.25, no people simulated yet

5Count draws, not failures, in R

R’s dgeom() counts the failures before the first success, while this page counts draws including the success, so the snippet calls dgeom(k - 1, p). Reading dgeom(k, p) as the chance of first success on draw k is a common slip: that is draw k + 1. The snippet then simulates 500 people at p = 0.10, who average 9.8 draws against 1/p = 10, and checks memorylessness.

Geometric probabilities counted in drawsShow the code
# This page counts trials through the first success
# (k = 1, 2, ...). R's dgeom() counts the failures
# before it, so draw k on the page is dgeom(k - 1, p).
# The values fall from draw 1 on: draw 1 is most likely.
p <- 0.25
k <- 1:6
round(dgeom(k - 1, prob = p), 4)

# Chance of needing more than 12 draws: (1 - p)^12
round(c(pgeom(12 - 1, p, lower.tail = FALSE), (1 - p)^12), 4)

# Simulate 500 people at p = 0.10. rgeom() also counts
# failures, so add 1 to count the successful draw.
set.seed(10)
draws <- rgeom(500, prob = 0.10) + 1
round(c(mean = mean(draws), theory = 1 / 0.10), 2)

# Memorylessness: P(X > 8 | X > 5) equals P(X > 3)
surv <- function(k) (1 - p)^k
round(c(surv(8) / surv(5), surv(3)), 4)

Uses base R only.

What the first-success count does