Lottery Math

I have taken every care to ensure the accuracy of information presented below. However, I will not take any responsibility for any errors or omissions! Please tell me if I have made a mistake, thanks :)

Combinatorics

Counting objects satisfying certain criteria.


Factorial

Number of ways to order n items.
n! = n * (n-1) * (n-2) * ... * 2 * 1 for integer n>0 and 0! = 1

Card Example: Number of ways to shuffle a deck of cards.
52! = 80,658,175,170,943,878,571,660,636,856,403,766,975,289,505,440,883,277,824,000,000,000,000


Combinations

Number of ways r samples can be chosen from a set of size n, aka n choose r, is
nCr(n, r) = n! / (r! * (n-r)!)
In other words the n samples are partitioned in two, the first subset has size r and the second has size n-r.

Card Example: Number of ways to deal a hand of 7 cards.
nCr(52, 7) = 52! / (7! * 45!) = 133,784,560


Combinations Generalized

The number of ways Σiri samples can be partitioned into subsets of type i with size ri.
Cr(ri) = (Σiri)! / Πi(ri!)

Card Example: Number of ways to deal 4 people each a hand of 7 cards.
Cr(7, 7, 7, 7, 24) = (7 + 7 + 7 + 7 + 24)! / (7! * 7! * 7! * 7! * 24!) = 201,474,727,133,525,966,905,424,640,000
If the player ordering not important, then number of unique deals is given by dividing the above by 4!.

Lotteries Without Replacement

The hypergeometric distribution is a discrete probability distribution that describes the number of successes in a sequence of draws from a finite population without replacement. I give my own take on this type of lottery below; by trade I'm not a statistician so it might be a good idea to have a look here too.


Hypergeometric

A population of size N contains R successes. A sample of size n is taken without replacement. It is desired that the sample contains exactly r successes.
Number of desirable samples: nCr(R, r) * nCr(N-R, n-r)
Probability a sample is desirable: nCr(R, r) * nCr(N-R, n-r) / nCr(N, n)
We can summarise by using a contingency table which describes the relationship between success/fail and population/sample.
ie

Card Example: The odds of dealing exactly 2 aces in a hand of 7 cards.
Deck of 52 cards contain 4 aces
Hand of 7 cards with 2 aces
N=52, R=4
n=7, r=2
The number of hands
Probability of dealing
nCr(4, 2) * nCr(48, 5) = 10,273,824
nCr(4, 2) * nCr(48, 5) / nCr(52, 7) = 594 / 7,735
The odds of dealing ever so slightly worse than 1 in 13

Lottery Example: There are a total of 54 unique balls. The player selects 6 balls on their ticket. The draw machine selects randomly 6 balls. Winning outcomes are: match 6, match 5, match 4, or match 3.
The number of balls in the game
The number of balls the player chooses
The number of balls drawn
The number of balls to match
N = 54
R = 6
n = 6
r = 6, 5, 4, 3
Winning outcome match exactly 6 match exactly 5 match exactly 4 match exactly 3
The odds 1 in 25,827,165 1 in 89,678 1 in 1,527 1 in 75

The Lotto Texas has the above configuration. Lotteries can sometimes employ several independent machines. Here combinations and probabilities are simply multiplied out, and I place the contingency tables side by side. An example would be EuroMillions.


Hypergeometric Generalized

A population of size ΣiRi exhibits a partitioning into subsets of type i with size Ri. A sample of size Σiri is taken without replacement. It is desired that the sample exhibits a partitioning into subsets of type i with size ri.
Number of desirable samples: Πi nCr(Ri, ri)
Probability a sample is desirable: Πi nCr(Ri, ri) / nCr(ΣiRi, Σiri)
We can summarise by using a contingency table which describes the relationship between the partitioning and population/sample.
Note that the column sums are subset sizes, the row sums are sample sizes, and the sum of all elements is the population size.

Card Example: The odds of dealing exactly 1 ace and 3 picture cards in a hand of 7 cards.
The deck contains 4 aces, 12 picture cards and 36 other cards
The hand contains 1 ace, 3 picture cards and 3 other cards
R1 = 4, R2 = 12, R3 = 36
r1 = 1, r2 = 3, r3 = 3
The number of hands
Probability of dealing
nCr(4, 1) * nCr(12, 3) * nCr(36, 3) = 6,283,200
nCr(4, 1) * nCr(12, 3) * nCr(36, 3) / nCr(52, 7) = 660 / 14,053
The odds of dealing slightly worse than 1 in 21

Lottery Example: There are a total of 49 unique balls. The player selects 6 balls on their ticket. The draw machine selects randomly 6 main balls, and then 1 bonus ball. Winning outcomes are: match 6, match 5 and bonus, match 5, match 4 or match 3. Note that match 6, match 4 and match 3 don't involve the bonus ball. Match 5 is really match 5 and not the bonus.
Winning outcome match exactly
6 main
match exactly
5 main and
1 bonus
match exactly
5 main and
0 bonus
match exactly
4 main
match exactly
3 main
The odds 1 in 13,983,816 1 in 2,330,636 1 in 55,491 1 in 1,032 1 in 57
The column sums give the ball type totals (main, bonus, other): this is either (6,0,43) or (6,1,42) depending if the bonus ball is in play. The row sums give the ticket choice totals (selected, rejected): always (6, 43). Finally, the sum of all elements is the number of balls in play: always 49.
Consequently, the number of possible draws is Cr(6,0,43) = 13,983,816 without the bonus ball, or Cr(6,1,42) = 601,304,088 with the bonus ball. The number of possible tickets is Cr(6,43) = 13,983,816.

The UK Lotto has the above configuration.