Analyze Lottery Numbers in Excel

K_McIntosh

New Member
Joined
Sep 5, 2012
Messages
7
Hey all ... my first post here ... I thought this would be a good place to start in order to clarify my understanding of some of the content re:

Analyze Lottery Numbers in Excel
at: Win the Lottery with Excel

I am motivated by both the immediate desire to come up with different ways of picking lottery numbers, as well as a desire to learn more about Excel (FYI - I'm still plunking along with Excel 2000 [9.0.8960 SP-3]) in the process - this seems like an excellent endeavor to do both.

Right out of the gate, from the above referenced page, I think I need clarification with:

"I downloaded data from the Ontario lottery site showing winning numbers for the past 3 months.
mec05050900.jpg
Using cut and paste, copy the numbers into a single column of data. Add a heading in cell A1.
mec05050901.jpg
"

At first read, this appears to work for one column of data at a time ... is it possible to do all six relevant (primary data) columns at once? ie. can we literally C & P all six columns worth of data into one single column of data ... I wouldn't have thought so ...

If we're only able to examine the frequency of a given integer being drawn on a column by column basis (ie. 1st # drawn, 2nd # drawn, ect.), my thought is that we are not seeing the frequency (or lack thereof) of partial or complete strings of six integers, as drawn historically. Or the order in which they occur, if and when they do. Apologies - it seems to me I had this latter thought expressed more clearly yesterday when I first composed this thread, however, that portion was lost due being auto-logged out and is just not coming to me as easily today, for whatever reason.

When implementing the =RANDBETWEEN function (as '=RANDBETWEEN(1,49)'), is it possible to configure the formula to select six unique integers at a time? I tried dragging the formula from one cell across six columns and found that it was occasionally possible for one (or more, although I have yet to see this) of the six integers to be duplicates.

Thanks for any help offered ... K_McIntosh
 
Assuming my "definitive" answers are correct, I still can't reconcile them with the math in post#18. Can anyone straighten me out?

It's the double counting, I believe. In post 18 the calculation was

=COMBIN(45,3)*46 = 652,710 but it turns out there are only 610,170

The first calculation is incorrect because it counts the same combination of 7 numbers multiple times, for example 1,2,3,4,5,6,7 is counted 4 times, once as part of 1,2,3,4 run with every combination of other numbers, once as part of 2,3,4,5 run.....once with 3,4,5,6....etc.

To get the correct 4+ count you could use my previous count of exactly 4 and extend that to add in exactly 5, exactly 6 and exactly 7, e.g.

=2*COMBIN(44,3)+44*COMBIN(43,3)+2*COMBIN(43,2)+43*COMBIN(42,2)+2*COMBIN(42,1)+42*COMBIN(41,1)+43

that gives you 610170
 
Upvote 0

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I'm going to read that three times to internalize it, thank you, Barry.
 
Upvote 0
OK, I ran 4 10M-lottery simulations and got 0.70942%, 0.71168%, 0.71106%, and 0.71220%. I'm happy.

Barry, xenou, thanks for humoring me in an entertaining thread.
 
Upvote 0
Wow! This thread keeps me reading until the last page, though i don't totally understand the percentage discussion :D
I'm amazed with you guys.

I'll try your codes later on my lottery database. thanks to all!
 
Upvote 0
For what it's worth, a lottery number function:

Code:
Function RandomLotteryNumber(ByVal minValue As Long, maxValue As Long, digits As Long) As String
Dim dic As Object  '//Scripting.Dictionary
Dim x As Long
Dim a, i

    Set dic = CreateObject("Scripting.Dictionary")
    
    Randomize
    Do While dic.Count < digits
        x = Int((maxValue - minValue + 1) * Rnd + minValue)
        If Not dic.Exists(CStr(x)) Then
            dic.Add CStr(x), x
        End If
    Loop
    
    a = dic.Keys
    For i = 0 To UBound(a)
        a(i) = CLng(a(i))
    Next i
    Call BubbleSort(a)
    
    RandomLotteryNumber = Join(a, "|")

End Function

Sub BubbleSort(ByRef arr)
     
Dim First As Long
Dim Last As Long
Dim i As Long, j As Long
Dim Temp As Long
     
    First = LBound(arr)
    Last = UBound(arr)
    For i = First To Last - 1
        For j = i + 1 To Last
            If arr(i) > arr(j) Then
                Temp = arr(j)
                arr(j) = arr(i)
                arr(i) = Temp
            End If
        Next j
    Next i
     
End Sub

Edit:
called as (in this case) =RandomLotteryNumber(1,49,6)
meaning, a lottery with six numbers, with the numbers between 1 and 49 inclusive.

I am just wondering that how this code generates from 1 to 49 where the code itself does not refer to any nomirical number|? can you please share your knowledge on this? is it the dictionary scripting that does the magic . I have a little bit of vba knowledge but this code seems sophisticated.
 
Upvote 0
Hi,
We use the rand function to generate an integer between 1 and 49, or more specifically between whatever min and max values are provided to the function when it is called:
x = Int((maxValue - minValue + 1) * Rnd + minValue)

The VBA help file on Rand() gives this same formula, I think. As for the scripting dictionary, the main reason for it is to use it as a collection object that holds only unique numbers. If the number already exists (we've already picked it), then we try again. Dictionary keys must be unique so we store the picked numbers as dictionary keys to take advantage of this feature. My assumption is that all numbers have an equal chance of being chosen, regardless of how many numbers there are, so this is a valid way to pick numbers. In a physical model, you'd have the 49 ping ball balls, then the 48 remaining after the first pick, then 47 ....

ξ
 
Upvote 0
Hi,
We use the rand function to generate an integer between 1 and 49, or more specifically between whatever min and max values are provided to the function when it is called:
x = Int((maxValue - minValue + 1) * Rnd + minValue)

The VBA help file on Rand() gives this same formula, I think. As for the scripting dictionary, the main reason for it is to use it as a collection object that holds only unique numbers. If the number already exists (we've already picked it), then we try again. Dictionary keys must be unique so we store the picked numbers as dictionary keys to take advantage of this feature. My assumption is that all numbers have an equal chance of being chosen, regardless of how many numbers there are, so this is a valid way to pick numbers. In a physical model, you'd have the 49 ping ball balls, then the 48 remaining after the first pick, then 47 ....

ξ
thank you very much.
 
Upvote 0
No problem. I'd forgotten about this thread. It was a fun investigation.
ξ
 
Upvote 0
I have a set of lottery numbers. The lottery is 7/39 (Seven numbers are drawn from a pool of 39 numbers). I have last 52 draws

[TABLE="width: 543"]
<colgroup><col><col span="7"></colgroup><tbody>[TR]
[TD]DRAW[/TD]
[TD]NUMBER 1[/TD]
[TD]NUMBER 2[/TD]
[TD]NUMBER 3[/TD]
[TD]NUMBER 4[/TD]
[TD]NUMBER 5[/TD]
[TD]NUMBER 6[/TD]
[TD]NUMBER 7[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]5[/TD]
[TD]7[/TD]
[TD]26[/TD]
[TD]31[/TD]
[TD]35[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]7[/TD]
[TD]12[/TD]
[TD]13[/TD]
[TD]21[/TD]
[TD]24[/TD]
[TD]33[/TD]
[TD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TD]
[TD]20[/TD]
[TD]23[/TD]
[TD]25[/TD]
[TD]27[/TD]
[TD]33[/TD]
[TD]36[/TD]
[/TR]
[TR]
[TD]45[/TD]
[TD]1[/TD]
[TD]16[/TD]
[TD]19[/TD]
[TD]26[/TD]
[TD]28[/TD]
[TD]32[/TD]
[TD]38[/TD]
[/TR]
[TR]
[TD]46[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]7[/TD]
[TD]12[/TD]
[TD]17[/TD]
[TD]25[/TD]
[TD]29[/TD]
[/TR]
[TR]
[TD]47[/TD]
[TD]12[/TD]
[TD]15[/TD]
[TD]20[/TD]
[TD]21[/TD]
[TD]25[/TD]
[TD]35[/TD]
[TD]38[/TD]
[/TR]
[TR]
[TD]48[/TD]
[TD]1[/TD]
[TD]17[/TD]
[TD]22[/TD]
[TD]27[/TD]
[TD]29[/TD]
[TD]34[/TD]
[TD]38[/TD]
[/TR]
[TR]
[TD]49[/TD]
[TD]1[/TD]
[TD]2[/TD]
[TD]12[/TD]
[TD]26[/TD]
[TD]33[/TD]
[TD]36[/TD]
[TD]37[/TD]
[/TR]
[TR]
[TD]50[/TD]
[TD]3[/TD]
[TD]5[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]19[/TD]
[TD]23[/TD]
[TD]29[/TD]
[/TR]
[TR]
[TD]51[/TD]
[TD]1[/TD]
[TD]5[/TD]
[TD]9[/TD]
[TD]19[/TD]
[TD]27[/TD]
[TD]28[/TD]
[TD]35[/TD]
[/TR]
[TR]
[TD]52[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]6[/TD]
[TD]16[/TD]
[TD]25[/TD]
[TD]27[/TD]
[TD]29[/TD]
[/TR]
</tbody>[/TABLE]


My question is ... is there a formula to figure out which set of numbers to play, that gives the most jackpot wins (all 7 numbers) from this 52 draws.
 
Upvote 0
its incalculable for anything meaningful that you could afford bet on (IMHO, Roulette has better odds 1:36 I think)
 
Upvote 0

Forum statistics

Threads
1,223,921
Messages
6,175,379
Members
452,639
Latest member
RMH2024

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top