Image of Blaise Pascal with probability mass function for the binomial distribution

Binomial Probability Calculator

Finding myself often computing binomial coefficients and binomial probabilities, and being dissatisfied with calculators that do not display all results for k from zero to n, I put this together. You can either enter n and p above, or pass them as a querystring. Example:, the classic example of tossing a fair coin ten times. Or better, tossing 1,000 times.

Example: At the Monte Carlo casino on August 18, 1913, the roulette wheel came up black 26 times in a row. It was a single zero wheel, so the probability of black on each spin was 18/37 = ~.486486486. What was the probability of 26 black in a row? . (This is actually a bad example since you could just compute (18/37)26 and get the answer, but what the heck.)

Example for my grandkids: Using this calculator to solve the old "birthday problem" -- given a group of n people, what are the chances that two or more people have the same birthday? -- requires a two-step approach. Say the group size is 23. First thing is to find how many distinct pairs of people you can make from a group of 23, that is, the binomial coefficient 23 choose two. So run the calculator with 23 in the n box and anything (say .5) in the p box. The binomial coefficient shown in the full data table for n=23 and k=2 is 253. So you have 253 possible pairs of people. Now, run the calculator with 253 as n, and 1/365 (0.00273973) as p (we're disregarding leap years). You have a ~50% (p=0.4995223425) chance of no pairs with a shared birthday, and thus a ~50% chance of one or more pairs each with a shared birthday. If you take the group size to 70, 70 choose 2 is 2415, and the chance of no pair with a shared birthday falls to 0.13%. Of course, if you had a group of 366 people (disregarding leap years, or 367 if you include leap years), obviously the probability of no shared birthdays would be zero, not some very tiny positive but finite number, as the binomial distribution predicts. But since 366 choose 2 is 66795, if you try this as n and .00273973 as p, the probability of no shared birthdays is computed as 2.599704056 x 10-80, which is about equal to one, divided by the number of atoms in the observable universe, so it's close enough to zero not to worry about.

Caveat arithemeticus: Numbers displayed in the result table show 10 significant digits and scale from about 10-322 to 10322. Columns 3 and 4 (cumulative probabilities) approach 1; if the significand rounds to 1, they just show 1. Display ends when k=n, or when one or more factors go out of range. If a factor goes out of range, a message is displayed showing the factor and its JavaScript value. When that occurs, note that a JavaScript value of zero or "infinity" does not really mean zero or infinity, just a positive number smaller or larger than the range of JavaScript's floating point representation.

When the calculator is run, the URL in the address bar is updated with a querystring. This is done as a convenience for the user, who may wish to save or forward a URL that will duplicate the results shown, but also to ensure that the URL matches page content. Clicking the Clear button will clear the querystring to give the bare URL.

Charting is done with the Highcharts JavaScript library, which we highly recommend.