# Software and Formulas to Calculate Lottery and Lotto Odds Using the Hypergeometric Distribution Probability

## By Ion Saliu, Founder of Lottery Mathematics

The page Primer: Probability, Odds, Formulae, Algorithm, Software Calculator presents the mathematics and logic of calculating the odds for various games of chance. The odds for various lotto games are presented here in more detail.

The formula of hypergeometric probability distribution is the most comprehensive calculator of odds and probabilities in lottery and lotto, including Powerball, Mega Millions, Euromillions, Keno.

The lottery games are much more diverse and complex (compared to coin tossing, or dice rolling, or even roulette spinning). The diversity widens when the Powerball-type of lotto games are taken into account. The lottery commissions set the odds as exactly k of m. Exactly is the operative keyword here. I thought it was at least. The lotto odds calculated as at least k of m lead to very different values.

The most certain element in calculating the lotto odds is total possible cases. It is known as total number of combinations C(n, k) in lottery calculations. The combination formula is widely accepted, expert or layperson:

n!
C(n, k) = --------------
k! (n  k)!

It is equivalent to:

n*(n-1)*(n-2)*(n-3)*...(n-k+1)
C(n, k) = -------------------------------------
1*2*3*...k

n! represents the factorial function and is calculated as 1*2*3*4*...*n. For example, the lotto 6/49 game has a total of [49 * 48 * 47 * 46 * 45 * 44] / [1 * 2 * 3 * 4 * 5 * 6] = 13,983,816 combinations.

This is the step that calculates the odds or probability of winning the lotto jackpot: 6 of 6, regardless of drawing order. The main attribute of the numeric sets known as combinations is: The numbers in the set are always sorted in ascending order; e.g. 1 2 3 4 5 6.

Calculating the odds for other lottery prizes requires a different formula. But we still need the above formula of probability to hit the jackpot. Let's calculate the odds of hitting 5 of 6 in a 6/49 lotto game. We already know the odds of getting 6 of 6. The 6-number winning combination can be broken into C(6,5) = 6 groups of 5 lotto numbers each. Each 5-number group can be combined with 1 number from the rest of the field: 49  6 = 43. C(43,1) = 43. There is a total of 6 x 43 = 258 combinations. Therefore one winning 6-number combination offers 258 chances of getting 5 of 6. Furthermore, the probability of hitting 5 of 6 is calculated by dividing total possible lotto combinations C(49,6) by total chances of 5 of 6 (258); 13,983,816 / 258 = 54,200.8 to 1 or 1 in 54,200.8.

Let's calculate the lottery odds of hitting 4 of 6 in a 6/49 game. We already know the odds of getting 6 of 6. The 6-number winning combination can be broken into C(6,4) = 15 groups of 4 numbers each. Each 4-number group can be combined with 2 numbers from the rest of the field: 49  6 = 43. C(43,2) = 903. There is a total of 15 x 903 = 13,545 lotto combinations. Therefore one winning 6-number combination offers 13,545 chances of 4 of 6. Therefore, the probability of hitting 4 of 6 is calculated by dividing total possible combinations C(49,6) by total chances of 4 of 6 (13,545); 13,983,816 / 13,545 = 1,032.4 to 1 or 1 in 1,032.4.

We can write now a general formula to calculate the odds or probability of various lotto prizes or situations. Hitting 2 of 6 is not a prize; it is just a probability situation.

C(n, k)
P(m of k from n) = ----------------------------
C(k, m) * C(n-k, k-m)

This lottery odds formula has restrictions. There are impossible situations, such as exactly 1 of 6 in a 6/10 lottery game. The above formula leads to mathematical absurdities in restricted cases. The computer programmer must include code to avoid the mathematically absurd situations. My probability application OddsCalc does that and a lot more. OddsCalc calculates the odds of any lotto game, including Powerball, Mega Millions, Euromillions, Keno  plus casino gambling and horse racing. If the lottery game draws 6 winning numbers, the program calculates the lotto odds from 0 of 6 to 6 of 6. The lotto probabilities or winning odds are calculated two ways: exactly and at least.

• There are lotto games that also draw a bonus or supplementary number. For example, there are situations when nobody hits the 6 of 6 jackpot combination. In that rollover case, the lottery commission pays a special prize for 5 of 6 AND bonus number. What are the odds for such a case? We already calculated the probability to get 5 of 6; e.g. 1 in 54,200.8 for 6-49 lotto. The supplementary number comes from the remaining 49  6 = 43 numbered balls. Therefore, the odds of winning 5 of 6 AND bonus number are 1 / (54,200.8 * 43) or 1 in 2,330,636.

You should know about this subtlety: The lottery commission pays you as at least, not as exactly! No, this not a jeu de mots. Otherwise, you would have to play for something like exactly 4 of 6. If your ticket would hit 6 of 6, you would not be paid the jackpot  because you played for exactly 4 of 6! Luckily, your lottery ticket is valid for winning any prize!

We can use a more complex formula to calculate the lotto odds. The formula we used before assumes that if the game draws 6 winning numbers, the player must select 6 numbers and play 6 numbers. But the player has the liberty to select, for example, 10 numbers from the field of 49; then the player must play 6-number combinations from the 10 picks. We can use a more generalized formula to calculate the odds. What is the probability to get 4 of 6 in 10 from 49 The first formula dealt with 3 elements (numbers): m, k, n; e.g. 6 of 6 from 49. The hypergeometric distribution probability adds a 4th parameter; e.g. number of picks or selections, s. The equation becomes m of k in s from n; e.g. 4 of 6 in 18 picks from a field of 49. The hypergeometric distribution probability reads:

C(n, k)
P(m of k in s from n) = ----------------------------
C(s, m) * C(n-s, k-m)

The hypergeometric distribution probability formula has also restrictions. As before, some cases are impossible; e.g. 1 of 6 in 10 from 10.

My probability software OddsCalc calculates the lotto odds based on the formula of hypergeometric distribution probability.

There are many more probability situations that can be calculated using formulas. Many lotto players want to calculate before generating the number of combinations of exactly 3 odd numbers and 3 even numbers. There are 24 even numbers and 25 odd numbers in a set of 49 elements. The 24 even numbers are grouped 3 at a time. C(24, 3) = 2024 groups. The 25 odd numbers are also grouped 3 at a time. C(25, 3) = 2300 groups. The 3-number groups must be combined so that we get 6-number combinations.
Therefore, total number of 3 odd, 3 even combinations is: 2024 x 2300 = 4,655,200.

2 odd, 4 even: C(25,2) * C(24,4) = 3,187,800.
1 odd, 5 even: C(25,1) * C(24,5) = 1,062,600.
0 odd, 6 even: C(25,0) * C(24,6) = 134,596.
6 odd, 0 even: C(25,6) * C(24,0) = 177,100.
5 odd, 1 even: C(25,5) * C(24,1) = 1,275,120.
4 odd, 2 even: C(25,4) * C(24,2) = 3,491,400.

No other combination of odd/even is possible. If we add-up the combinations of all 7 odd/even groups:
Sum-total: 13,983,816 (equal to C(49,6) = total possible lotto 649 combinations).

From another perspective: There are 24 low numbers (1 to 24) and 25 high numbers (25 to 49) in a set of 49 elements. The 24 low numbers are grouped 3 at a time. C(24, 3) = 2024 groups. The 25 high numbers are also grouped 3 at a time. C(25, 3) = 2300 groups. The 3-number groups must be combined so that we get 6-number combinations. Therefore, total number of 3 low, 3 high combinations is: 2024 x 2300 = 4,655,200.
There are 7 groups of low/high, very similar to the odd/even situation.

The calculations are more difficult if the two previous conditions act simultaneously. What is the number of combinations of exactly 3-odd, 3-high OR 3-low, 3-even? We need to take inventory of the numbers that satisfy the condition. Let's exemplify for the world-wide popular 6/49 lotto game. There are 24 low numbers (1 to 24) and 25 high numbers (25 to 49). There are 12 ODD numbers in the LOW-number group; there are 12 EVEN numbers in the LOW-number group. There are 13 ODD numbers in the HIGH-number group; there are 12 EVEN numbers in the HIGH-number group. Now, it has become really easy to calculate all possible 6-number lottery combinations for each of the four groups.

~ all-low & all-odd: C(12, 6) = 924 lotto 6/49 combinations;
~ all-low & all-even: C(12, 6) = 924 lotto 6/49 combinations;
~ all-HIGH & all-odd: C(13, 6) = 1716 lotto 6/49 combinations;
~ all-HIGH & all-even: C(12, 6) = 924 lotto 6/49 combinations.

The calculations are far more difficult if the two previous conditions act simultaneously. What is the number of lotto combinations of exactly 3 odd, 3 even AND 3 low, 3 high? Let's try to replicate the method in the previous paragraph. We deal now with 4 groups of lotto numbers: low-odd, low-even, high-odd, high-even. We combine the 4 groups 2 at a time in compliance with the restriction: low-odd with high-even and low-even with high-odd. C(12,3) * C(12,3) + C(12,3) * C(13,3) = 48,400 + 62,920 = 111,320.

It doesn't work that way! It is the same situation if trying to calculate, by formulas, the number of lotto combinations for particular sum-totals. As far as I can tell, nobody has ever found such formulae. Only precise lottery software can achieve such tasks via precise algorithms. The computer program can generate lottery combinations AND apply various filters. Low/high + odd/even act now as filters; the same in the case of lottery sums.

As far as I can tell, nobody has ever written such type of lottery software  except for yours truly, that is! My lotto programs are entitled UserGroups6 (for 6-number lotto games) and UserGroups5 (for 5-number lotto games).

Here are some totals for various combinations of low/high and odd/even for a 6-49 lotto game. The lottery software also quickly generates the combinations and saves them to files.

3 odd, 3 even AND 3 low, 3 high: 1,532,168
3 odd, 3 even AND 2 low, 4 high: 1,156,584
3 odd, 3 even AND 4 low, 2 high: 1,059,696
4 odd, 2 even AND 3 low, 3 high: 1,156,584
2 odd, 4 even AND 3 low, 3 high: 1,059,696

4 odd, 2 even AND 4 low, 2 high: 784,278
4 odd, 2 even AND 2 low, 4 high: 881,166
2 odd, 4 even AND 4 low, 2 high: 737,946
2 odd, 4 even AND 2 low, 4 high: 784,278

5 odd, 1 even AND 5 low, 1 high: 86,724
5 odd, 1 even AND 1 low, 5 high: 118,404
1 odd, 5 even AND 5 low, 1 high: 81,576
1 odd, 5 even AND 1 low, 5 high: 81,576

It's very important to remember that the calculations above refer to the condition EXACTLY m of k; e.g. exactly 5 of 6. The lottery commissions only pay one prize of 5 of 6. Some people expect also prizes for the 4 of 6 groups that a 5 of 6 winning combination is composed of. That's what EXACTLY stands for. If the lottery commissions were to pay for all the prizes that a winning combination is composed of, the odds would have to be calculated as AT LEAST m of k. The odds calculated by the two methods differ to a great extent. The odds of EXACTLY 1 of 6 in a lotto 6/49 game are 1 in 2.4. The odds of AT LEAST 1 of 6 in a lotto 6/49 game are 6/49 = 1 in 8.16.

If you thought this was difficult stuff  you were right! You aren't alone in this regard. But we all can learn  fairly easily, I might add. All of the above dealt with one parameter only: The probability or winning odds. Many people, especially British, have a problem with equating the odds to probability. I would say they are too puritan or picky. We semantically equate here probability to favorable odds or odds of winning. The odds of winning are expressed as 1 in SomeNumber; the individual probability is also expressed as 1 in SomeThing, which is absolutely valid in mathematics.

In many of the world cultures, they only deal with probability or its mathematical synonym chance. They usually say the chance of winning or the probability of winning, or the probability of losing, etc. Odds came from the British passion for horse racing. The odds can be represented as hurdles to overcome.

Hold it... there is more! There is one very important parameter that I introduced back in 1997: Degree of certainty. Most people confuse the probability for the degree of certainty. The layperson can look at the degree of certainty as being the probability of probability. The event of probability p has a degree of certainty DC to appear in a number of trials N. The real-life is much more complex than to be described by just the individual probability!

The individual probability would indicate that the odds of getting heads (or tails) in 2 coin tosses are 100%. NOT! The degree of certainty of getting heads (favorable odds, p = 1 in 2) in 2 coin tosses is only 75%! The Ion Saliu Paradox calculates with random precision that the degree of certainty of hitting one 00-roulette number in 38 spins is just about 65%. If an event has a probability p = 1/N, the degree of certainty DC tends to 1  1/e or 0.632 (63.2%) to appear in N trials.

The cynics argue with me this way: "Tossing heads always has a probability p = 1/2. Thus, getting heads after 10 trials is .5 or 50%; getting heads after 100 coin tosses is 1/2 or 50-50; getting heads after 1000 coin tosses is .5 or 50%"... and so on ad infinitum... My answer is always silencing, because it is truthful to its most simplicity. While heads always has a probability p = 1/2, simultaneously tails always has a probability p = 1/2. Both elements have a "right and duty" to appear  and they do appear randomly equally. Has anyone witnessed 100 heads in a row? Or 100 consecutive tails? Forget about 1000 consecutives!

Read more about this fascinating matter, as it were, that is at the very core of the Universe:

• Mathematical Foundation of Fundamental Formula of Gambling.

## Multum in parvo: Much in little

Axiomatic one, here is one more highly-debated probability problem. "Is it the same chance to win the lottery jackpot IF playing more tickets at once OR one ticket at a time for a long period of time?"

Methinks it is multum in parvo  more tickets at once. It is based on the aforementioned Ion Saliu Paradox. I did a few convincing calculations in the historic lottery newsgroup. What gives the best chance to win the jackpot:

• Play 1 ticket a week for one year; or 
• Play 52 tickets once a year?

1) Coin-tossing is the most convincing. There are 2 possibilities (outcomes): Heads and Tails. The probability to get one possibility is p = 1/2. If we play the 2 possibilities, the probability is p = 2/2 = 100% or 1 in 1. But if we play 1 outcome in 2 trials, the chance is only 75% or 1 in 3.3. The difference is 25%

2) Roll one die: 6 possibilities. The probability is p = 1/6. If we play 3 possibilities, the chance is p = 3/6 = 50% or 1 in 2. But if we play 1 outcome in 3 trials, the chance is 42.1% or 1 in 2.38. The difference is 7.9%
We can play all 6 point-faces at once; the chance is p = 6/6 = 100% or 1 in 1. If we play 1 point-face in 6 rolls, the chance is 66.5% or 1 in 1.5. The difference is 33.5%

3) Let's do now calculations for 6/49 lotto, for we got great software to do such calculations: SuperFormula. We apply the function C = Degree of Certainty.

So, play 52 tickets (distinct 6-number combinations) once a year or one ticket a week (52 weeks, right?) If we play the 52 possibilities, the chance is p = 52/13983816 = 0.000371858% or 1 in 268919.5. But if we play 1 combination in 52 weeks, the chance is 0.0000371858% or 1 in 269179.

We already see a difference. But how about 10 years? Play 520 tickets (distinct 6-number combinations) ONCE or one ticket a week (520 weeks, right?) If we play the 520 possibilities, the chance is p = 520/13983816 = 0.00372% or 1 in 26892. But if we play 1 combination in 520 weeks, the chance is 0.000371% or 1 in 229541.

The more combination played, the wider the gap between the two methods. And there is a limit in all this matter, as calculated by the Ion Saliu Paradox. If we play all lotto combinnations at once (as the Australian investors tried to do in Virginia Lottery in the 1980s or 1990s), the degree of certainty to hit the jackpot is 100%. If we play 1 ticket for the next 13983816 drawings (good luck with that!) the probability to hit the jackpot is only 63.2%  a significant difference of 36.8%.

That's how randomness works for all intents and purposes.

Read Ion Saliu's first book in print: Probability Theory, Live!
~ Founded on valuable mathematical discoveries with a wide range of scientific applications, including the organic connection between probability theory and calculation of odds in all lotto games.