Anyone who has studied discrete probability has run into urns containing balls of varying colors, which are withdrawn according to seemingly arbitrary rules, always ending in the same big question that Jakob Bernoulli’s own students surely posed: Why do we even care?

For example, suppose three urns are filled with the following balls. Urn 1: 673 blue, 490 red, 37 white; Urn 2: 635 blue, 436 red, 46 white; Urn 3: 501 blue, 351 red, 58 white. If you draw 26 balls from Urn 1, 3 balls from Urn 2, and 6 balls from Urn 3, what is the probability that you get at least 10 more blue balls than red ones? Assuming you aren’t still giggling about blue balls, you’re surely wondering why anyone is so eager to get them. It turns out they might be the key to an extremely competitive Minnesota State House race.

Representative Mary Franson, Republican from Alexandria, Minnesota, seems to have been reelected, though a mandatory recount will be conducted later this week. Franson heads into the recount with an 11-vote lead over her opponent, Bob Cunniff. That doesn’t sound like much of a margin, but it’s enough to make an upset unlikely. After election night, however, she only had a 1-vote lead, which could easily have been flipped by the recount. The reason her margin grew by 10 votes is that 35 ballots were withdrawn from those cast in three precincts, and 10 more of those ballots were marked for Cunniff than for Franson. In case you couldn’t guess, the number of withdrawn ballots in the precincts were 26, 3, and 6. The urn problem stated above is just another way of asking how lucky Mary Franson was. What was the probability the withdrawn ballots would break at least as favorably for her as they did? The answer turns out to be 0.24. That is, she had about 1-in-4 odds of doing this well (or better), once it became known the ballots would be withdrawn.

The reason why an election judge was blindly pulling ballots out of three ballot boxes is because administrative errors on election day had resulted in more ballots being cast than voters were signed in. (In Alexandria’s Ward 1 – Precinct 2, there were 26 excess ballots; in Ward 3, 3 excess ballots; in Wart 5 – Precinct 2, 6 excess ballots.) Section 204C.20 of the Minnesota Statutes says “If there is still an excess of properly marked ballots, the election judges shall replace them in the box, and one election judge, without looking, shall withdraw from the box a number of ballots equal to the excess.”

To get some sense of the probability calculation, consider what actually happened in Ward 1 – Precinct 2. In withdrawing 26 of the 1200 ballots, 16 of them turned out to come from the 673 that had been marked for Cunniff (blue), 9 of them from the 490 that were marked for Franson (red), and 1 of them from the 37 that were marked for neither candidate (white). The probability of this particular outcome is C(673,16)C(490,9)C(37,1)/C(1200,26), where C(*n*,*k*) indicates the number of ways to choose *k* out of *n*. Using the same reasoning, one can find the probability for what happened in each of the other two precincts. As they are independent, multiplying the three probabilities together yields the probability of the process ending exactly as it did, with Cunniff having lost 16, 3, and 3 votes in the three precincts and Franson having lost 9, 0, and 3.

Of course, that’s only one of many ways in which Franson could have gotten her 10-vote boost. She could equally well have gained less of her edge in Ward 1 – Precinct 2 and more of it in one of the other precincts. Adding up the probabilities for all the different mixes that result in a 10-vote edge gives a sum of about 0.05. Taking into account the outcomes with even more than a 10-vote edge brings the total up to about 0.24.

I’m not happy about having to use a nest of six summations in order to get my final answer. (Update: nor with an alternative I also know of that uses a total of eight summations, but limits the nesting depth to four.) If anyone knows a better way, please let me know.