Counting Outcomes: Binomial and Poisson

Today let's understand two of the most common ways to count outcomes in data: the binomial and the Poisson.

Let's say you run Lindero, a small online store. Two things happen there every hour that you might want to count. At checkout, 20 customers reach the payment page, and some of them buy. In the support inbox, emails arrive through the day, with no cap on how many can land in an hour.

Both are counts. But they behave completely differently, and mixing them up leads to the wrong formula and the wrong answer.

Here is what a count distribution generally looks like: bars for what actually happened, and a line for what a model expects.

Checkout has a fixed number of chances to buy, 20 of them, every hour. The inbox has no such limit, zero emails or fifty are both possible. The first kind of count is called binomial. The second is called Poisson.

Here is what each one actually looks like for Lindero, side by side.

RInteractive R
# A first look at Lindero's two counters: checkout and the support inbox n <- 20; p <- 0.3; lambda <- 4 par(mfrow = c(1, 2)) barplot(dbinom(0:n, n, p), names.arg = 0:n, col = "steelblue", main = "Checkout: buyers per hour", xlab = "buyers out of 20", ylab = "probability") barplot(dpois(0:12, lambda), names.arg = 0:12, col = "darkorange", main = "Inbox: emails per hour", xlab = "emails", ylab = "probability")

  

Press Run and look at the two charts. The left one stops dead at 20, because checkout cannot produce more buyers than it had visitors. The right one keeps going past 12, because nothing in the inbox says it has to stop there. That difference, a hard stop against no stop at all, is the whole reason checkout and the inbox need two different distributions, not one.

A trial with a fixed count: the binomial setup

Start with checkout, the fixed count side of Lindero's business.

Every hour, exactly 20 customers reach the checkout page. That number is fixed before the hour even starts, it does not depend on how many of them end up buying. Each one of those 20 either buys or does not, two outcomes and nothing in between. And Lindero's historical conversion rate says each customer buys with probability 0.3, independent of what the customer before them did.

Put those three facts together and you get the four conditions a binomial distribution needs:

  • A fixed number of trials, n. Here n = 20.
  • Each trial has exactly two outcomes: buy, or do not buy.
  • Each trial carries the same probability of success, p. Here p = 0.3.
  • The trials are independent, so one customer's decision does not change the next customer's odds.

When all four hold, the count of successes, call it X, follows a binomial distribution, written X ~ Binomial(20, 0.3).

Plot every possible value of X at once and you get the full shape of that distribution.

RInteractive R
# Plot every possible count of buyers out of 20 checkouts, each with its probability n <- 20 p <- 0.3 buyers <- 0:n prob_buyers <- dbinom(buyers, n, p) barplot(prob_buyers, names.arg = buyers, col = "steelblue", xlab = "number of buyers out of 20", ylab = "probability", main = "Binomial(20, 0.3): buyers per hour at Lindero's checkout")

  

That chart is the binomial distribution for Lindero's checkout. It peaks around 6 buyers, tapers off on both sides, and never goes past 20, because 20 is as many buyers as that hour can possibly produce.