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

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
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

DRAWNUMBER 1NUMBER 2NUMBER 3NUMBER 4NUMBER 5NUMBER 6NUMBER 7
12357263135
27121321243338
314621232834
410141719212627
58122232343738
6151521263038
711141923242729
81467102736
98141722233539
101161826273438
11361924343539
121101118192834
1314912131437
1411122324313235
15281117283236
1610172125273134
175212425343738
189202531323639
198232425293538
2014162327363839
21481727283738
2246912181933
236161823263033
2411151927333438
25271021242629
26891517272938
271121822282939
28161113212439
291111931333435
30241415303135
316101319253638
3267811121738
3336910152333
34491724293435
359101922233739
3623911131415
37381215232534
3812131620242535
395101620222930
402111415282932
4111111214262836
4214161826272839
439111330313238
449202325273336
451161926283238
4613712172529
4712152021253538
481172227293438
49121226333637
503578192329
5115919272835
5245616252729

<colgroup><col><col span="7"></colgroup><tbody>
</tbody>


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,214,377
Messages
6,119,182
Members
448,872
Latest member
lcaw

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