Geometric distribution calculator
How likely is the first success on try k?
What is the geometric distribution?
It counts how many independent tries it takes to get the first success when every try has the same chance of success p. The probability that the first success comes on try k is P(X = k) = (1 − p)^(k − 1) × p: k − 1 failures, then a success.
Example: success chance 2%
With p = 0.02, the chance that the first success comes on the 7th try is 0.98⁶ × 0.02 = 0.0177. On average it takes 1 ÷ 0.02 = 50 tries, with a standard deviation of √(50 × 49) = 49.5 (OpenStax Introductory Statistics 2e, Example 4.20).
How do I find “at least” and “at most” probabilities?
Needing more than k tries means the first k all failed: P(X > k) = (1 − p)^k. So P(X ≤ k) = 1 − (1 − p)^k and P(X ≥ k) = (1 − p)^(k − 1). With p = 0.35, the chance of needing 3 or more tries is 0.65² = 0.4225.
Trials until success or failures before success?
Both conventions are in use. Counting trials (1, 2, 3, …), as OpenStax and SciPy’s geom do, the mean is 1 ÷ p. Counting failures before the first success (0, 1, 2, …), as R’s dgeom does, P(X = k) = (1 − p)^k × p and the mean is (1 − p) ÷ p — one less. The variance, (1 − p) ÷ p², is the same either way.
When does the geometric distribution apply?
When the tries are independent, each has only two outcomes, the chance of success stays the same every time, and you stop at the first success. For a fixed number of tries and a count of successes, use the binomial distribution instead.
Where do the formulas come from?
From OpenStax Introductory Statistics 2e, section 4.4 “Geometric Distribution”, which gives both conventions with their means and variances. Its worked examples are part of this calculator’s automated tests.
How many tries do I need for a 90% or 95% chance of at least one success?
Solve 1 − (1 − p)^k ≥ c for k, which gives k ≥ ln(1 − c) ÷ ln(1 − p), rounded up. With p = 0.02, you need 114 tries for a 90% chance and 149 for 95% — far more than the average of 50 tries, which gives only a 63.6% chance.
Is the average number of tries a typical outcome?
Not really. The distribution is skewed to the right: a few long streaks of failures pull the mean up. For p = 0.02 the mean is 50 tries, yet the chance of succeeding by try 35 is already at least one half. For small p, the chance of needing more than the mean number of tries is close to 1 ÷ e, about 37%.
How the formulas fit together
Let q = 1 − p be the chance of failure. The first success arrives on try k only if the first k − 1 tries all fail, which has probability q^(k − 1), and then try k succeeds, which has probability p. Needing more than k tries means the first k tries all failed, so P(X > k) = q^k, and every other cumulative probability follows from that single expression. The mean is 1 ÷ p, the variance is q ÷ p², and the standard deviation is √q ÷ p.
The model assumes that the tries are independent and that p never changes. The chance does not “build up” after a run of failures: after 20 misses, the expected wait for the next success is the same as it was at the start.
Worked example: rolling a six
A fair die shows a six with p = 1 ÷ 6 on each roll. The chance that the first six comes on exactly the 4th roll is (5 ÷ 6)³ × (1 ÷ 6) = 0.0965. On average a six takes 6 rolls, with a standard deviation of 5.48. The chance of getting a six within those six rolls is 1 − (5 ÷ 6)⁶ = 0.6651, so waiting the average number of rolls still fails about 33.5% of the time.
For the 2% example above, the chance that the first success lands on the 7th try is 0.0177, and the chance of needing at least 7 tries is 0.8858.
Mistakes to avoid
The most frequent slip is mixing conventions. If a textbook counts trials and software such as R counts failures, the same question gets answers one step apart: the probability of a first success on trial 7 is the probability of 6 failures first. The calculator's selector sets which one X means; check it before comparing with another source.
The second is using the model when the tries are not independent or p changes. Drawing cards or marbles without replacement changes the odds on each draw, so the geometric distribution only approximates that case when the population is large. Also, “at least k” and “more than k” differ by one trial, and the difference is large when p is big: with p = 0.5, P(X ≥ 3) = 0.25 but P(X > 3) = 0.125.
Sources: OpenStax, Introductory Statistics 2e, section 4.4 (Geometric Distribution); the cumulative formulas follow directly from P(X > k) = (1 − p)^k. Related tools: binomial probability, negative binomial and exponential distribution calculators.