Home ↓
CalculatorsVerified

Math & Geometry

Geometric Distribution Calculator (Trials Until First Success)

Many everyday situations involve repeating something until it works: rolling a die until a six appears, making sales calls until one leads to a sale, or testing items until a defective one is found. If each attempt is independent and has the same probability p of success, the number of the trial on which the first success occurs follows the geometric distribution. The probability that the first success happens on trial k is the probability of k minus one failures in a row, one minus p raised to the power k minus one, times the probability of success on that trial. The probability of at least one success within the first k trials is one minus the probability that all k fail, and the probability of still waiting after k trials is one minus p to the power k. The expected number of trials is one divided by p: on average you need six rolls to get a six. The distribution has a long tail, so there is a real chance of needing many more attempts than average; with p equal to one in six, there is about a 40 percent chance of needing more than five rolls. Like the exponential distribution, the geometric distribution is memoryless: past failures do not change the chance of success on the next attempt. This calculator uses the convention that counts trials starting from one. It takes the success probability and a trial number, and returns the probability of first success on that trial, the cumulative and survival probabilities, the mean, the standard deviation, the number of trials needed for a 50 percent chance and a table of the first trials.

How to use this calculator

  1. Enter the probability of success on each trial, as a decimal such as 0.2.
  2. Enter the trial number k you are interested in.
  3. Read the probability that the first success happens on trial k.
  4. Read the probability of at least one success by trial k.
  5. Use the table to see how the probabilities build up.

The gambler's fallacy

Because trials are independent, a long run of failures does not make success more likely next time. After ten tails in a row, a fair coin still has a 50 % chance of heads on the next toss.

The geometric distribution shows why long streaks are less rare than intuition suggests: with p = 0.5, a run of five failures before the first success has a probability of about 3 %.

Uses in quality control and reliability

Inspectors use the geometric distribution to estimate how many items must be checked before a defect is found, which helps set inspection plans.

In networking, the number of transmission attempts needed for a packet to get through on a noisy channel with a constant error rate follows a geometric distribution.

Formula & method

P(X = k) = (1 − p)^(k−1) × p (first success on trial k)P(X ≤ k) = 1 − (1 − p)^kP(X > k) = (1 − p)^k (no success in the first k trials)Mean = 1 ÷ p; variance = (1 − p) ÷ p²

P(X = k) = (1 − p)^(k−1) p, P(X ≤ k) = 1 − (1 − p)^k, P(X > k) = (1 − p)^k, mean = 1/p and variance = (1 − p)/p².

Worked example

A 20 % chance of success on each attempt; first success on attempt 3

  1. P(X = 3) = 0.8² × 0.2 = 0.128
  2. P(success by attempt 3) = 1 − 0.8³ = 0.488
  3. Expected number of attempts = 1 ÷ 0.2 = 5

Answer: There is a 12.8 % chance the first success comes exactly on the third attempt, and a 48.8 % chance it comes within three.

Frequently asked questions

What is the expected number of trials?

It is 1/p. With a 1 in 6 chance per roll, the expected number of rolls to get a six is 6.

How many trials give a 50 % chance of success?

It is the smallest k with 1 − (1 − p)^k ≥ 0.5. For p = 0.2 it is 4 trials, because 1 − 0.8⁴ ≈ 59 %.

Is the geometric distribution the same as the binomial?

No. The binomial counts successes in a fixed number of trials; the geometric counts trials until the first success.

What is the negative binomial distribution?

It generalises the geometric distribution to the number of trials needed for r successes. The geometric is the case r = 1.

Why is there a version that starts at 0?

Some texts count failures before the first success, which starts at 0 and has mean (1 − p)/p. This calculator counts the trial on which success occurs, starting at 1.

Can p be 1?

Yes. Then the first trial always succeeds, so P(X = 1) = 1 and the expected number of trials is 1.