How to use the geometric and negative binomial calculator
- Enter the chance of success on each trial as a percent.
- Enter the successes needed. Use 1 for the geometric distribution, the wait for the first success, or a larger number for the negative binomial, the wait for the r-th success.
- Enter the trial number you want the chance for.
- Read the chance of exactly that trial, the chance of that trial or fewer, the chance of more, the expected number of trials and the table by trial.
Formula
geometric: P(first success on trial k) = (1 - p)^(k - 1) p
negative binomial: P(r-th success on trial k) = C(k - 1, r - 1) p^r (1 - p)^(k - r)
mean = r / p variance = r (1 - p) / p^2
The variable counts every trial up to and including the last needed success, so it can never be less than r. The cumulative chance is the sum of the exact probabilities from trial r up to trial k.
Waiting for a 20% chance to come off
With a 20% chance on each try, the chance that the first success comes on exactly the fifth try is 0.8^4 x 0.2 = 8.1920%. The chance it comes on the fifth try or sooner is 0.67232, so there is a 32.768% chance it takes longer. The expected number of tries is 5.
For three successes at 40% each, the chance the third arrives on exactly trial 10 is 6.4497%, and on trial 10 or sooner it is 0.83271. The expected number of trials is 7.5 with a standard deviation of 3.354102. All of these were confirmed by listing the binomial coefficients with exact arithmetic.
Two ways to count
Some textbooks count only the failures before the last success. That number is the one on this page minus r. The two conventions describe the same event, so a table in one book can look shifted compared with another. This page counts the trial number, which matches how most people ask the question: on which try does it happen?
The geometric distribution is the special case of one success needed. It is memoryless, like its continuous cousin the Exponential Distribution: after any number of failures, the chance of success on the next trial has not changed.
Common uses and limits
Use it for repeated independent attempts with the same chance each time: tries until a part passes a test, calls until the third sale, or rolls until a certain number appears twice. It does not fit when the chance changes between trials, as when you draw cards without replacement. In that setting, look at the Hypergeometric Distribution Calculator.
More statistics tools
For streaks, waiting times, agreement and score scales, try the Cohen's Kappa Calculator, Robust Center Calculator and Standard Score Converter.
Assumptions and limits
- Each trial has the same chance of success and trials are independent.
- The variable counts trials, including the one with the last needed success.
- The chance of success must be greater than 0 and at most 100%.
- The table shows up to fifteen trial numbers ending near the one you asked about.
- The example values are an illustration. Replace them with your own.
Frequently asked questions
Can the geometric distribution start at zero?
Some books define it that way by counting failures before the first success. This page counts trials, so the smallest possible value is 1, when the first try succeeds.
Why is the expected number of trials r divided by p?
Each success takes 1 / p trials on average, because a success happens once in every 1 / p tries. Needing r of them multiplies that by r.
What does a chance of 100% do?
Every trial succeeds, so the r-th success is always on trial r. The page handles this case and shows a chance of 100% for trial r and 0% for later trials.
How large can the trial number be?
The page accepts trial numbers up to one million, with up to 100,000 successes needed. Very large values are computed with logarithms so they do not overflow.