0% found this document useful (0 votes)
296 views10 pages

Lottery Number Prediction Model

Uploaded by

lavinsai564
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
296 views10 pages

Lottery Number Prediction Model

Uploaded by

lavinsai564
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Predicting Winning Lottery Numbers

Thando Nkomozake
arXiv:2403.12836v1 [math.PR] 19 Mar 2024

Department of Mathematics and Physics, Cape Peninsula University of


Technology, Bellville, Cape Town, South Africa

March 20, 2024

Abstract
We use mathematical statistics theory to derive the Compound-Dirichlet-Multinomial
(CDM) prediction model. We then use this model to predict winning numbers for
the 6-number, 5-number, pick-4 and pick-3 lottery games. We also develop a strategy
which we call “the 3-strategy”, for generating profit by predicting winning numbers for
the pick-3 lottery game.

1 Introduction
The purpose of this work is to obtain a good model for predicting winning lottery numbers.
In chapter 2 we discuss the prior and posterior distributions in some detail. We then provide
a practical example based on the Bernoulli distribution. In chapter 3 we focus on the vector
case of our theoretical discussion. In section 3.1 we discuss the definition of the Multinomial
distribution. In section 3.2 we discuss the definition of the Dirichlet distribution and use
this and our results in the previous sections to define the Compound-Dirichlet-Multinomial
distribution.

In chapter 4 we focus on the matrix case of our theoretical discussion. In section 4.1 we
derive the probability distribution function (pdf) of the Compound-Dirichlet-Multinomial
distribution for the matrix case. In section 4.2 we use the results of section 4.1 to write
the (CDM) prediction model. In chapter 5 we discuss the three methods that we use to
estimate the parameter α of the (CDM) prediction model. In section 5.1 we discuss maximum
likelihood estimation, in section 5.2 we discuss the method of moments and in section 5.3
we discuss the main diagonal method. In chapter 6 we discuss our results, where in section
6.1 we discuss our results for the 6-number lottery game and in section 6.2 we discuss our
results for the 5-number lottery game. In section 6.3 we discuss our results for the pick-3
lottery game. We introduce our strategy that we call “the 3-strategy” where we use the
(CDM) prediction model to obtain profit from the Vermont pick-3 lottery game. We don’t
discuss the pick-4 lottery game because our results for it are similar to our results for the
pick-3 lottery game.

1
2 The Prior and Posterior Distributions
2.1 Prior Distribution
In the frequentist paradigm the uknown parameter is a fixed number. In the Bayesian
paradigm the uknown parameter is a random variable. For two random variables X and Y ,
their joint pdf is denoted with fX,Y (x, y). Then the marginal pdf of X is given by,
Z
fX (x) = fX,Y (x, y) dy. (1)

The conditional pdf of Y given that X = x is given by,


fX,Y (x, y)
fY |X (y|x) = . (2)
fX (x)
In Bayesian analysis the uknown parameter is represented by a random variable Θ. The
corresponding pdf is denoted by fΘ (θ) and is called the prior distribution. It is given such a
name because it gives us information about the uknown parameter prior to the observation
of data.

2.2 Posterior Distribution


We now observe the data and denote the observed data with the random vector X. The
conditional pdf of X given Θ = θ is given by,
fX,Θ (x, θ)
fX|Θ (x|θ) = . (3)
fΘ (θ)
You can rewrite (3) as,
fX,Θ (x, θ) = fX|Θ (x|θ) fΘ (θ). (4)
The marginal pdf of X in this case is given by,
Z
fX (x) = fX,Θ (x, θ) dθ. (5)

Then the conditional pdf of Θ given that X = x is given by,


fX,Θ (x, θ)
fΘ|X (θ|x) = R . (6)
fX,Θ (x, θ) dθ
This pdf (6) is called the posterior distribution because it gives us information about the
uknown parameter after we observe the data. We can rewrite (6) as follows,
fX|Θ (x|θ) fΘ (θ)
fΘ|X (θ|x) = R . (7)
fX|Θ (x|θ′ ) fΘ (θ′ ) dθ′

Then we summarize (7) as follows,


fΘ|X (θ|x) ∝ fX|Θ (x|θ) fΘ (θ). (8)

2
2.3 Example
Let X ≡ getting a heads when flipping a loaded coin. Therefore X ∼ Bernoulli(p), where
p is the parameter of the Bernoulli distribution and it denotes the probability of getting a
heads. We have that P ∼ Uniform(0, 1) and it has the following pdf,

fP (p) = 1, ∀p ∈ (0, 1). (9)

The pdf of X given that P = p is,

fX|P (x|p) = px (1 − p)1−x , (10)

where x ∈ {0, 1}. If we have a random vector X = (X1 , X2 , ..., Xn ) that follows the
Bernoulli(p) distribution then we have that,
n
Y
fX|P (x|p) = pxi (1 − p)1−xi
i=1 . (11)
Pn Pn
xi n− i=1 xi
=p i=1 (1 − p)
Pn
If we let i=1 xi = s, then we can write (11) as,

fX|P (x|p) = ps (1 − p)n−s . (12)

Using (4) we have that,

fX,P (x, p) = fX|P (x|p) fP (p)


(13)
= ps (1 − p)n−s .

Now we can calculate the marginal pdf of X,


Z 1
fX (x) = ps (1 − p)n−s dp. (14)
0

Therefore the posterior distribution of P is given by,

ps (1 − p)n−s
fP |X (p|x) = R 1 . (15)
0
ps (1 − p)n−s dp

3
3 The Vector Case
3.1 The Multinomial Distribution
Examples of categorical variables include the following:

(a) Gender has two categories (k = 2) and these are male and female.

(b) The outcome of flipping a six-sided die has six categories (k = 6) and these are 1, 2,
3, 4, 5 and 6.

The multinomial distribution is commonly used to characterize categorical random variables.


Suppose that Z is a categorical random variable with k categories. Let P (Z = j) = pj ∀j =
1, 2, ..., k. The parameter p = (p1 , p2 , ..., pk ) describes the entire distribution of Z, where
P k
j=1 pj = 1. We now generate a random sample Z1 , Z2 , ..., Zn . Let,

n
X
Xj = I {Z = j}. (16)
i=1

So then we have that the random vector X = (X1 , X2 , ..., Xk ) follows the multinomial dis-
tribution with parameters (n; p1 , p2 , ..., pk ). We write X ∼ MNk (n; p1 , p2 , ..., pk ). Therefore
the pdf of X given that P = p is,
k
n! Y x
fX|P (x|p) = pj j . (17)
x1 ! x2 ! ... xk ! j=1

3.2 The Dirichlet Distribution


The Dirichlet distribution is the prior distribution to the multinomial parameters p =
(p1 , p2 , ..., pk ). Therefore p ∼ Dir(α), which implies that its pdf is given by,
k
Γ( ki=1 αi ) Y αi −1
P
fP ((p)) = Qk pi , (18)
i=1 Γ(α i ) i=1

where αi > 0 ∀i = 1, 2, ..., k.

The posterior distribution of P is given by,

fP |X (p|x) ∝ fX|P (x|p) fP (p)


k
n! Γ( ki=1 αi )
P
(x +α )−1
Y
= Qk Qk pi i i
i=1 xi ! i=1 Γ(αi ) i=1
(19)
k
(x +α )−1
Y
∝ pi i i
i=1
∼ Dir(x1 + α1 , x2 + α2 , ..., xk + αk ).

4
We also have that the joint pdf of X and P is given by,

fX,P (x, p) = fX|P (x|p) fP (p)


k
n! Γ( ki=1 αi ) (20)
P
(x +α )−1
Y
= Qk Qk pi i i .
i=1 xi ! i=1 Γ(αi ) i=1

The marginal pdf of X is the integral of the joint pdf (20), so we have,
Pk k
n! Γ( i=1 αi )
Z
(x +α )−1
Y
fX (x) = Qk Qk pi i i dp
i=1 xi ! i=1 Γ(α i ) i=1
Pk Qk (21)
n! Γ( i=1 αi ) i=1 Γ(xi + αi )
= Qk Qk Pk .
i=1 xi ! i=1 Γ(αi ) Γ( i=1 (xi + αi ))

This marginal pdf of X (21) is called the Compound-Dirichlet-Multinomial (CDM) distri-


bution. Its corresponding expectation value is given by,
αi
E(xi ) = n Pk . (22)
i=1 αi

4 The Matrix Case


4.1 The (CDM) Distribution For a Matrix
 
Let X = X i ∀i = 1, 2, ..., n. Where X i = (Xi1 , Xi2 , ..., XiK ). So X is a matrix with n rows
and K columns. Let Y = (y1 , y2 , ...yK ) be the multinomial parameter. Let M = K
P
j=1 Xij
Pn 
and nj = i=1 Xij . We then have that X ∼ MNK M; Y and Y ∼ Dir(α), which implies
that the corresponding marginal pdf is given by,
PK K
M! Γ( j=1 αj )
Z
(nj +αj )−1
Y
fX (x) = QK QK yj dy
nj !
j=1 j=1 Γ(αj ) j=1
(23)
M! Γ( K
P QK
j=1 αj ) j=1 Γ(nj + αj )
= QK QK PK .
j=1 nj ! j=1 Γ(α j ) Γ( j=1 (nj + α j ))

Therefore this pdf (23) is the (CDM) distribution for the matrix X. Where, K
P
j=1 αj = α0
PK
and j=1 yj = 1. The corresponding expectation value for this distribution is,
αj
E(nj ) = M . (24)
α0

5
4.2 The (CDM) Prediction Model
We start by making the following substitution in (23), nj → zj and αj → αj + nj . This
gives,
M! Γ( K
P QK
j=1 (αj + nj )) j=1 Γ(zj + nj + αj )
fZ (z) = QK QK PK , (25)
j=1 zj ! j=1 Γ(αj + nj ) Γ( j=1 (zj + nj + αj ))

where Z represents the predicted matrix. The corresponding expectation value is given by,

(αj + nj )
E(zj ) = M PK . (26)
j=1 (α j + nj )

Therefore if we want to predict the next row of the matrix X using its previous n rows we
use,
(αj + nj )
P red(xn+1) = M PK , (27)
j=1 (α j + nj )
and this is the (CDM) prediction model.

5 Parameter Estimation
5.1 Maximum Likelihood Estimation
Suppose that we have the following matrix,

 
x11 x12 . . . x1K
 x21 x22 . . . x2K 
X =  .. .. . . ..  ,
 
 . . . . 
xn1 xn2 . . . xnK
where M = K
P Pn
j=1 xij and nj = i=1 xij . Suppose that we want to predict the (n + 1)-th
row from the matrix X using the (CDM) prediction model (27). We therefore first have
to estimate the parameter α = (α1 , α2 , ..., αK ). In order to obtain the maximum likelihood
estimate for α we use the following formula [1],

α̂j = α0 fj , ∀j = 1, 2, ..., K, (28)


Pn
where fj = ( i=1 xij )/n, and α0 is given by the following formula,

n (K − 1) γ
α0 = PK PK Pn , (29)
n j=1 fj ln(fj ) − j=1 fj i=1 ln(xij )

where γ is the Euler-Mascheroni constant and is given by γ = 0.57721566490.

6
5.2 Method of Moments
The method of moments estimate for the parameter α is given by [2],
nj
α̂j = , ∀j = 1, 2, ..., K. (30)
n

5.3 Main Diagonal Method


The author found that if X is a square matrix then the main diagonal of X is a good estimate
for the parameter α. That gives,
α̂j = xjj , ∀j = 1, 2, ..., K. (31)

6 Results
6.1 The Six-Number Lottery Game
The author collected historical data from the South African national lottery for the six-
number lottery game. To play the South African six-number lottery game you pick six
numbers from 1 to 52. The historical data shows the past winning numbers for 1971 draws
≡ 21 years. The author then wrote code that compares the numbers predicted by the (CDM)
model (27) for each historical draw with the actual winning numbers for that draw. When
the model predicts correctly then the code prints out the corresponding winning numbers
and their position in the historical data.

We then used the code to compare for 2 winning numbers, 3 winning numbers, 4 winning
numbers, 5 winning numbers and 6 winning numbers in the six-number lottery game. We
summarized the results on Table 1 below.

WINNING NUMBERS TIME DIFFERENCE


TWO 12 draws ≡ 1 month
THREE 105 draws ≡ 13 months
FOUR 529 draws ≡ 5.5 years
FIVE 9984 draws ≡ 104 years
SIX 1000 0032 draws ≡ 104 167 years

Table 1: (Using the case of two winning numbers to explain. This therefore means that if
the code predicts two winning numbers correctly it will take approximately 12 draws ≡ 1
month for it to correctly predict two winning numbers again.)

In using our code on the historical data that covers 21 years, we didn’t get any outputs
for five winning numbers and six winning numbers. Therefore the time difference between
five winning numbers and six winning numbers reflected on Table 1 is approximated using
patterns observed in the outputs for two winning numbers, three winning numbers and four
winning numbers.

7
Table 2: (These are some outputs from our code. The
combinations labelled [MD] are outputs the code prints
having used the main diagonal method. The combina-
tions labelled [MM] are outputs the code prints having
used the method of moments. The combinations labelled
[AC] are the actual winning jackpot numbers for that
draw.)

(09/07/2022) (16/07/2022) (06/08/2022)


11 19 27 37 39 45 [MD] 8 19 23 31 37 46 [MD] 7 12 27 35 43 47 [MD]
11 19 28 36 39 45 [MM] 9 17 23 31 37 46 [MM] 7 13 24 34 45 47 [MM]
6 24 29 35 41 44 [AC] 7 13 22 31 45 46 [AC] 7 18 30 36 44 47 [AC]

6.2 The Five-Number Lottery Game


We collected historical data from the Oklahoma Cash 5 lottery which is based in America.
The historical data shows the past winning numbers for 4642 draws ≡ 13 years. We then
used the same code we used for the six-number lottery game to compare for two winning
numbers, three winning numbers, four winning numbers and five winning numbers in the
five-number lottery game. We summarized the results on Table 3 below.

WINNING NUMBERS TIME DIFFERENCE


TWO 12 draws ≡ 2 weeks
THREE 109 draws ≡ 4 months
FOUR 1182 draws ≡ 3 years
FIVE 7665 draws ≡ 21 years

Table 3: (Using our code on the historical data from the Oklahoma Cash 5 lottery, that covers
13 years, we didn’t get any outputs for five winning numbers. Therefore the time difference
between five winning numbers reflected on this table is approximated using patterns observed
in the outputs for two winning numbers, three winning numbers and four winning numbers.)

6.3 The Pick 3-Lottery Game


The author collected historical data from the Vermont Pick 3 lottery, which is based in
America. This data contains 5844 draws where 60 draws ≡ 1 month. In order to play the
Vermont Pick 3-lottery game you pick three digits between 0 and 9. You win the jackpot
if the three digits you picked match the drawn three digits in the exact order. The jackpot
prize money is $500. If there’s multiple jackpot winners of a particular draw they each get
$500. There are two draws per day every day of the year. For each draw one person can
play up to 21 consecutive three number combinations. The price to play each combination is
$1. We applied our code to the historical data and got the results shown on Table 4 below.
Using our results and considering the rules of the game we developed a strategy which we

8
call “The 3-Strategy” and we discuss it below. With this strategy we play the Vermont Pick
3-lottery game and generate a profit.

Draw Number Difference


0
44 44
659 615
1357 698
1369 12
1915 546
2039 124
3449 1410
3685 236
4285 600
Table 4: (The average difference between two consecutive draws is 476 draws ≡ 8 months.
The left column of this table shows the draw numbers where our code correctly predicted
the jackpot numbers. The right column shows the difference between two consecutive draw
numbers.)

The 3-Strategy:
Stream 1

The average number of draws between successfully predicted wins is 476 draws ≡ 240 days.
We divide 240 days into four quarters and there’s 60 days per quarter. We start by using 1
player and we start playing in the first 60 days:

$2 × 60 = $120.

If we win we get $500 and therefore a profit of $380. If we don’t win in the first 60 days we
play in the second 60 days and this time we use 2 seperate players in order to make back
the $120 we lost and also make some profit.

The second 60 days:(2 players)

$4 × 60 = $240.
If we win we get $1000 and therefore a profit of $760. So $760 − $120 = $640. We therefore
make back our $120 and make a total profit of $640. If we don’t win in the second 60 days
we play in the third 60 days. Also this time we use 5 seperate players in order to make back
the $120 + $240 = $360 we lost and also make some profit.

9
The third 60 days:(5 players)

$10 × 60 = $600.
If we win we get $2500 and therefore a profit of $1900. So $1900 − $360 = $1540. We
therefore make back our $360 that we had lost and make a total profit of $1540. If we don’t
win in the third 60 days then there’s a good probability that we’ll win in the fourth 60 days
because it completes the 240 days. So we play in the fourth 60 days and this time we use
12 seperate players in order to make back the $120 + $240 + $600 = $960 we lost and also
make some profit.

The fourth 60 days:(12 players)

$24 × 60 = $1440.
If we win we get $6000 and therefore a profit of $4560. So $4560 − $960 = $3600. We there-
fore make back our $960 that we had lost and make a profit of $3600. That completes the 240
days. In total we spent $2400 on tickets and won a total of $6000 and made a profit of $3600.

Remember the 240 days is just the average time between successfully predicted wins by our
model. Therefore practically this time can be less or more. With respect to the historical
data we collected, the most this time has been is 1410 draws ≡ 730 days. So if it happens
that we don’t win even in the fourth 60 days, we continue with the procedure, adding more
players accordingly until we win. Therefore in this stream 1 of the 3-strategy it’s safe to have
a budget of $100 000 in order to play. We can run the 3-strategy across multiple streams
simultaneously for maximum profit. If you don’t have $100 000 at your disposal and you
want to apply the 3-strategy, you can then observe the pattern displayed by the data and
only play at favourable times. The historical data shows that there’s “Short-stretches” and
“Long-stretches”. Where a,

Long − stretch ≥ 500 draws,

and a,
Short − stretch < 500 draws.
The data shows that 60% of the time, the time between successfully predicted wins (by our
model) alternates between a Short-stretch and a Long-stretch. Therefore if you don’t have
$100 000 in your budget then it’s better for you to play during a Short-stretch.

References
[1] N. Wicker et.al, A maximum likelihood approximation method for Dirichlet’s parameter
estimation, Computational Statistics and Data Analysis 52.3 (2008): 1315-1322.

[2] A. Narayanan, A note on parameter estimation in the multivariate beta distribution,


Computers and Mathematics with Applications 24.10 (1992): 11-17.

10

You might also like