Poisson Binomial Calculator

Exact counts of successes when every chance differs.

  • Exact fractions
  • Any tail
  • Poisson comparison
A small clay table carrying a hill of rounded blocks that rises to a peak and falls away, with a few loose round beads set beside it, in soft daylight.

The guide

When every trial has its own chance, the average chance gives the wrong answer

The number of successes in trials with different chances follows an exact table that is easy to build and easy to get wrong. The usual shortcuts misstate both the spread and the tails.

  • 29403/80000 exact chance of 3 successes in six unequal trials (0.367538)
  • 0.310162 the same event under a binomial built from the average chance
  • 63/160 how much too large that binomial variance is (1.49625 vs 1.1025)
  • 0.00976 distance to the Poisson for 50 small chances (bound 0.055)
Read the full guide Fold the guide 6 min · 13 sources

Every trial gets its own chance

Take six trials that can each succeed or fail, but are not alike. The first succeeds with chance 1/10, the next with 1/4, then 2/5, 11/20, 7/10 and 17/20. How many of them succeed?

The count of successes, written K, follows the Poisson binomial distribution. The Wikipedia article defines it as the distribution of a sum of independent Bernoulli trials that are not necessarily identically distributed. The ordinary binomial is the special case where every chance is the same. The NIST handbook states that the binomial assumes the chance is fixed for all trials, and that is exactly the assumption that fails here.

The mean is easy. It is the sum of the chances, 57/20 or 2.85. The variance is the sum of p(1 - p) over the trials, because each Bernoulli trial has variance p(1 - p) and independent variances add. Here that is 441/400, or 1.1025.

A tempting shortcut is to average the chances to 0.475, call the result a binomial with six trials, and move on. It has the right mean of 2.85 and the wrong spread: its variance is 1.49625, which is 63/160 larger than the true 1.1025. It also changes answers that people read to the first digit. The exact chance of exactly 3 successes is 29403/80000, which is 0.367538. The averaged binomial says 0.310162, about 16 percent too low.

That gap is no accident. The Wikipedia article gives an identity: the variance of the Poisson binomial equals the variance of the binomial with the same mean, minus the sum of the squared gaps between each chance and the average chance. Equal chances make the sum zero. Spread-out chances make it positive, so unequal trials always give a more predictable count than the average suggests. For the six chances the sum is exactly 63/160, and the page checks the identity in whole numbers, two ways, on every list.

Building the table one trial at a time

The dependable way to get the whole table is to add the trials one at a time. Start with a table that says zero successes have probability 1. When a trial with chance p joins, every entry splits: the old entry for j successes stays at j with probability 1 - p and moves to j + 1 with probability p. In symbols, new[j] = old[j](1 - p) + old[j - 1]p. After the last trial the table holds the probability of every count from 0 to n.

Every step adds positive numbers. Nothing cancels, so nothing is lost. The Wikipedia article describes this direct convolution and calls it numerically stable and exact, and the article on convolution of probability distributions explains why a sum of independent counts is a convolution of their tables.

The page goes one step further and keeps the table in whole numbers. Each chance is read exactly as typed, so 0.35 means 7/20 and not the nearest double. With each chance written as a/b in lowest terms, every new entry is a whole number over the product of the denominators, and no division happens until something is shown to a reader. JavaScript BigInt holds integers of any size, and Python’s fractions module did the same job in the independent check.

For the six chances the table runs 0.008201, 0.084746, 0.275400, 0.367538, 0.212006, 0.048836 and 0.003273 for zero to six successes, and the seven entries add to 1. The chance of at most 3 successes is 0.735885 and of at least 4 is 0.264115. The most likely count is 3. All 64 patterns of success and failure can be listed and weighted by hand, and doing so gives the same table. NumPy’s convolve, run on the same chances in doubles, agrees to better than 1e-15.

Long lists make large numbers. For 500 three-decimal chances, the largest list the page takes, the common denominator has more than a thousand digits, so the page states the digit count instead of hiding it. The heavy work runs in a Web Worker so that typing stays smooth, and each interaction has a ten second limit with a Cancel button.

Why the textbook recursion is a trap

There is a second route to the same table. The probability of zero successes is the product of the (1 - p). For k above zero, the probability of k successes is one over k times an alternating sum, over i from 1 to k, of the probability of k - i successes multiplied by T(i), where T(i) adds up (p / (1 - p)) raised to the power i over the trials. It is neat, needs only n numbers T(i), and fits in a few lines. It also needs every chance to be below 1, since it divides by 1 - p.

The alternating signs are the problem. Large terms cancel to leave a small answer, and every rounding error in the large terms survives the cancellation.

The Wikipedia article warns that this recursion is not numerically stable and should be avoided when n is above about 20. The page measures that warning. In exact whole numbers the recursion reproduces the table for 60 chances between 0.30 and 0.70, entry by entry. In doubles the same recursion is off by roughly 5e-6 to 8e-6 on that list, against about 3e-17 for the dynamic programme in doubles. On 100 chances spread from 0.01 to 0.99, the doubles recursion returns values of the order of 1e140 where no probability can exceed 1.

The two figures for the 60-chance list, one from NumPy and one from this page, come from programs written independently. Both are wrong, by different amounts. That is what instability looks like: the size of the error depends on the order in which the sums are added.

How good are the stand-ins?

Two stand-ins are in everyday use: the binomial with the average chance, and the Poisson with the same mean. To say how far off they are, the page uses the total variation distance, which is half the sum of the absolute differences between the two tables. As the Wikipedia article on it puts it, this is the largest difference between the probabilities that the two distributions give to the same event.

For the six chances the distance to the averaged binomial is 0.077, which is modest, and the distance to the Poisson is 0.238, which is large. The Poisson has variance equal to its mean, 2.85, against the true 1.1025. It also puts probability on counts above 6, which six trials cannot reach, and it gives 0.223174 for exactly 3 successes against the true 0.367538.

Le Cam’s theorem is the guarantee behind the Poisson stand-in. The sum of the absolute differences is below twice the sum of the squared chances, so the distance is below the sum of the squared chances. The Wikipedia article on the Poisson binomial distribution adds sharper bounds by Barbour and Hall, including the upper bound (1 - e^-mean) / mean times that sum.

Small chances make the guarantee bite. For 50 chances between 0.01 and 0.05 the mean is 1.5 and the sum of squares is 0.055. The measured distance is 0.00976, comfortably under 0.055 and under the sharper bound of about 0.0285. The chance of at least 4 successes is 0.062100 exactly and 0.065642 under the Poisson.

For the six chances the sum of squares is 1.7475. A bound above 1 says nothing, because a distance never exceeds 1, and the measured 0.238 shows why. For 100 chances spread from 0.01 to 0.99 the averaged binomial has variance 24.9987 against the true 16.7854, and it puts 0.120539 on at least 56 successes where the exact answer is 0.075931, about 59 percent too high.

What this does not cover

The method assumes the trials are independent. Correlated trials need other models, and so does the conditional Bernoulli distribution, which fixes the total number of successes in advance. The page also does not estimate the chances. It takes them as given, and the table is only as good as they are.

In Exact mode the table, the tails, the mean and the variance are exact, and the page also reports the smallest count whose chance of that many or fewer successes reaches a chosen level, which for the six chances at 95 percent is 5. The binomial and Poisson columns, both distances and the doubles recursion are approximate, good to about 13 to 15 digits, and the page labels them so. Past 500 chances, or past ten seconds of work, the page stops and says so rather than guessing.

Sources

Every source consulted for this guide. Links checked November 11, 2026.

  1. Poisson binomial distribution Wikipedia
  2. Le Cam's theorem Wikipedia
  3. Total variation distance of probability measures Wikipedia
  4. Binomial distribution Wikipedia
  5. Poisson distribution Wikipedia
  6. Bernoulli distribution Wikipedia
  7. Convolution of probability distributions Wikipedia
  8. 1.3.6.6.18. Binomial Distribution NIST/SEMATECH e-Handbook of Statistical Methods
  9. BigInt MDN Web Docs
  10. Web Workers API MDN Web Docs
  11. fractions: Rational numbers Python Software Foundation
  12. numpy.convolve NumPy documentation
  13. scipy.stats.poisson SciPy documentation