Odd & Even Number Distribution for a 649 Lotto

PAB

Member
Hi everyone,

Does anybody have the FULL Odds & Evens distribution of a 649 Lotto with regard to each of the 6 positions please. It is basically EVERY distribution available for the 13,986,816 combinations of Odd & Even numbers in a 649 Lotto with regard to each of the 6 positions.

This is what I have so far ...

Code:
E	O	O	O	O	O
O	E	O	O	O	O
O	O	E	O	O	O
O	O	O	E	O	O
O	O	O	O	E	O
O	O	O	O	O	E
E	E	O	O	O	O
E	O	E	O	O	O
E	O	O	E	O	O
E	O	O	O	E	O
E	O	O	O	O	E
O	E	E	O	O	O
O	E	O	E	O	O
O	E	O	O	E	O
O	E	O	O	O	E
O	O	E	E	O	O
O	O	E	O	E	O
O	O	E	O	O	E
O	O	O	E	E	O
O	O	O	E	O	E
O	O	O	O	E	E
E	E	E	O	O	O
E	E	O	E	O	O
E	E	O	O	E	O
E	E	O	O	O	E
E	O	E	E	O	O
E	O	E	O	E	O
E	O	E	O	O	E
E	O	O	E	E	O
E	O	O	E	O	E
E	O	O	O	E	E
E	E	E	E	O	O
E	E	E	O	E	O
E	E	E	O	O	E
E	E	O	E	E	O
E	E	O	E	O	E
E	E	O	O	E	E
E	O	E	E	E	O
E	O	E	E	O	E
E	O	E	O	E	E
E	O	O	E	E	E
E	E	E	E	E	O
E	E	E	E	O	E
E	E	E	O	E	E
E	E	O	E	E	E
E	O	E	E	E	E
O	E	E	E	E	E
E	E	E	E	E	E
... but I am falling short of the correct distributions.

Thanks in Advance.
All the Best.
PAB
:wavey:
 

GillesD

Member
Odd / Even distribution

Hi PAB, here is a more complete distribution of even and odd numbers:

O - O - O - O -O - O - X
E - O - O - O -O - O -
O - E - O - O -O - O -
O - O - E - O -O - O -
O - O - O - E -O - O -
O - O - O - O -E - O -
O - O - O - O -O - E -
E - E - O - O -O - O -
E - O - E - O -O - O -
E - O - O - E -O - O -
E - O - O - O -E - O -
E - O - O - O -O - E -
O - E - E - O -O - O -
O - E - O - E -O - O -
O - E - O - O -E - O -
O - E - O - O -O - E -
O - O - E - E -O - O -
O - O - E - O -E - O -
O - O - E - O -O - E -
O - O - O - E -E - O -
O - O - O - E -O - E -
O - O - O - O -E - E -
E - E - E - O -O - O -
E - E - O - E -O - O -
E - E - O - O -E - O -
E - E - O - O -O - E -
E - O - E - E -O - O -
E - O - E - O -E - O -
E - O - E - O -O - E -
E - O - O - E -E - O -
E - O - O - E -O - E -
E - O - O - O -E - E -
O - E - E - E -O - O - X
O - E - E - O -E - O - X
O - E - E - O -O - E - X
O - O - E - E -E - O - X
O - O - E - E -O - E - X
O - O - O - E -E - E - X
E - E - E - E -O - O -
E - E - E - O -E - O -
E - E - E - O -O - E -
E - E - O - E -E - O -
E - E - O - E -O - E -
E - E - O - O -E - E -
E - O - E - E -E - O -
E - O - E - E -O - E -
E - O - E - O -E - E -
E - O - O - E -E - E -
E - E - E - E -E - O -
E - E - E - E -O - E -
E - E - E - O -E - E -
E - E - O - E -E - E -
E - O - E - E -E - E -
O - E - E - E -E - E -
E - E - E - E -E - E -

A X at the end of the line indicates a combination you forgot. This includes the all odd numbers and a few lines with 3 even and 3 odd numbers.

And here is for a 6/49 lottery, the number of combinations for each of the possible ration of odd to even numbers:

0 odd / 6 even: 134,596
1 odd / 5 even: 1,062,600
2 odd / 4 even: 3,187,800
3 odd / 3 even: 4,655,200
4 odd / 2 even: 3,491,400
5 odd / 1 even: 1,275,120
6 odd / 0 even: 177,100
 

Patrick123

Member
Hi PAB,

As the number is either Odd or Even, and you are drawing 6 numbers, this would equate to 2^6 or 64 possible combinations.

I put together a quick little program that will allow you to get the distribution percentages of odd/even or prime/non-prime for any lotto range and draw size.

You can get it here: LotDist

Regards
Patrick
 

GillesD

Member
Distribution of Even / Odd numbers in a 6/49 lottery

You are quite right Patrick, there are 64 possibilities with 6 numbers and your small program made me realize my error. The values obtained when running your program appear to be right although some of your percentages are negative which I do not understand.
Since your data is not in sequential order and I could not copy your data to an Excel spreadsheet to check the totals, I made a macro that generated the following data:

Even/Odd - # comb. - - % - - # times - - %
000000 - - 134,596 - - 0.96% - - 20 - - 0.81%
000001 - - 177,100 - - 1.27% - - 28 - - 1.13%
000010 - - 177,100 - - 1.27% - - 36 - - 1.46%
000011 - - 177,100 - - 1.27% - - 29 - - 1.17%
000100 - - 177,100 - - 1.27% - - 34 - - 1.38%
000101 - - 230,230 - - 1.65% - - 39 - - 1.58%
000110 - - 177,100 - - 1.27% - - 30 - - 1.22%
000111 - - 177,100 - - 1.27% - - 42 - - 1.70%
001000 - - 177,100 - - 1.27% - - 39 - - 1.58%
001001 - - 230,230 - - 1.65% - - 42 - - 1.70%
001010 - - 230,230 - - 1.65% - - 34 - - 1.38%
001011 - - 230,230 - - 1.65% - - 39 - - 1.58%
001100 - - 177,100 - - 1.27% - - 31 - - 1.26%
001101 - - 230,230 - - 1.65% - - 38 - - 1.54%
001110 - - 177,100 - - 1.27% - - 25 - - 1.01%
001111 - - 177,100 - - 1.27% - - 37 - - 1.50%
010000 - - 177,100 - - 1.27% - - 27 - - 1.09%
010001 - - 230,230 - - 1.65% - - 43 - - 1.74%
010010 - - 230,230 - - 1.65% - - 38 - - 1.54%
010011 - - 230,230 - - 1.65% - - 30 - - 1.22%
010100 - - 230,230 - - 1.65% - - 47 - - 1.90%
010101 - - 296,010 - - 2.12% - - 41 - - 1.66%
010110 - - 230,230 - - 1.65% - - 37 - - 1.50%
010111 - - 230,230 - - 1.65% - - 43 - - 1.74%
011000 - - 177,100 - - 1.27% - - 25 - - 1.01%
011001 - - 230,230 - - 1.65% - - 51 - - 2.07%
011010 - - 230,230 - - 1.65% - - 35 - - 1.42%
011011 - - 230,230 - - 1.65% - - 45 - - 1.82%
011100 - - 177,100 - - 1.27% - - 28 - - 1.13%
011101 - - 230,230 - - 1.65% - - 38 - - 1.54%
011110 - - 177,100 - - 1.27% - - 29 - - 1.17%
011111 - - 177,100 - - 1.27% - - 40 - - 1.62%
100000 - - 177,100 - - 1.27% - - 23 - - 0.93%
100001 - - 230,230 - - 1.65% - - 54 - - 2.19%
100010 - - 230,230 - - 1.65% - - 45 - - 1.82%
100011 - - 230,230 - - 1.65% - - 41 - - 1.66%
100100 - - 230,230 - - 1.65% - - 34 - - 1.38%
100101 - - 296,010 - - 2.12% - - 63 - - 2.55%
100110 - - 230,230 - - 1.65% - - 38 - - 1.54%
100111 - - 230,230 - - 1.65% - - 47 - - 1.90%
101000 - - 230,230 - - 1.65% - - 37 - - 1.50%
101001 - - 296,010 - - 2.12% - - 42 - - 1.70%
101010 - - 296,010 - - 2.12% - - 46 - - 1.86%
101011 - - 296,010 - - 2.12% - - 59 - - 2.39%
101100 - - 230,230 - - 1.65% - - 38 - - 1.54%
101101 - - 296,010 - - 2.12% - - 60 - - 2.43%
101110 - - 230,230 - - 1.65% - - 26 - - 1.05%
101111 - - 230,230 - - 1.65% - - 45 - - 1.82%
110000 - - 177,100 - - 1.27% - - 24 - - 0.97%
110001 - - 230,230 - - 1.65% - - 49 - - 1.98%
110010 - - 230,230 - - 1.65% - - 42 - - 1.70%
110011 - - 230,230 - - 1.65% - - 45 - - 1.82%
110100 - - 230,230 - - 1.65% - - 51 - - 2.07%
110101 - - 296,010 - - 2.12% - - 50 - - 2.03%
110110 - - 230,230 - - 1.65% - - 32 - - 1.30%
110111 - - 230,230 - - 1.65% - - 39 - - 1.58%
111000 - - 177,100 - - 1.27% - - 39 - - 1.58%
111001 - - 230,230 - - 1.65% - - 37 - - 1.50%
111010 - - 230,230 - - 1.65% - - 49 - - 1.98%
111011 - - 230,230 - - 1.65% - - 45 - - 1.82%
111100 - - 177,100 - - 1.27% - - 28 - - 1.13%
111101 - - 230,230 - - 1.65% - - 40 - - 1.62%
111110 - - 177,100 - - 1.27% - - 37 - - 1.50%
111111 - - 177,100 - - 1.27% - - 24 - - 0.97%

The information in each column is:
- column #1: the sequence of even (0) and odd (1) numbers
- column #2: the number of combinations for that sequence for all possible combinations
- column #3: the relative percentage over the 13,983,816 combinations
- column #4: the number of times that sequence occurred in the first 2,469 draws of the Canadain Lotto 6/49
- column #5: the relative percentage over those 2,469 draws
 

PAB

Member
Thanks GillesD & Patrick123 for the replies,

I finally figured out ALL 64 distributions of Odd/Even numbers by going through and doing it by hand.

GillesD,
Whould it be possible for you to post the macro to produce the distribution of Odd/Even numbers please.
I have written a program that produces the EXACT same results as yourself. The only thing is that it takes about five minutes to run.

Thanks in Advance.
All the Best.
PAB
:wavey:
 

Patrick123

Member
Hi GillesD,

Thanks for pointing it out. I've added a copy button that will copy the grid to the clipboard to paste into Excel.

Regards
Patrick
 

GillesD

Member
Answers and questions

To PAB:

- Although my program does it in a little less than a minute, it may be related to the computer used. Also I think this program is one of the worst I have come up with. It produces the right results but I consider it quite "code intensive". I will look at it and try to improve it before posting it.

To Patrick:

- I ran your program with the Copy option but at the end, nothing came out (that I could see that is). Any problem with it?

- Also an EXE program with options (number of balls, draw size, 2 types of distribution) is quite interesting, I found it rather slow for a 6/49 lottery. In what language did you program it?
 

PAB

Member
Thanks GillesD,

I have produced the following results using my program which differ slightly with yours ...

Code:
Dist	Comb	%	Expected 1 in
OOOOOO	177,100	1.27	78.96	Draws
OOOOOE	177,100	1.27	78.96	Draws
OOOOEO	230,230	1.65	60.74	Draws
OOOEOO	230,230	1.65	60.74	Draws
OOOOEE	177,100	1.27	78.96	Draws
OOOEOE	230,230	1.65	60.74	Draws
OOOEEO	230,230	1.65	60.74	Draws
OOOEEE	177,100	1.27	78.96	Draws
OOEOOO	230,230	1.65	60.74	Draws
OOEOOE	230,230	1.65	60.74	Draws
OOEOEO	296,010	2.12	47.24	Draws
OOEEOO	230,230	1.65	60.74	Draws
OOEOEE	230,230	1.65	60.74	Draws
OOEEOE	230,230	1.65	60.74	Draws
OOEEEO	230,230	1.65	60.74	Draws
OOEEEE	177,100	1.27	78.96	Draws
OEOOOO	230,230	1.65	60.74	Draws
OEOOOE	230,230	1.65	60.74	Draws
OEOOEO	296,010	2.12	47.24	Draws
OEOEOO	296,010	2.12	47.24	Draws
OEOOEE	230,230	1.65	60.74	Draws
OEOEOE	296,010	2.12	47.24	Draws
OEOEEO	296,010	2.12	47.24	Draws
OEOEEE	230,230	1.65	60.74	Draws
OEEOOO	230,230	1.65	60.74	Draws
OEEOOE	230,230	1.65	60.74	Draws
OEEOEO	296,010	2.12	47.24	Draws
OEEEOO	230,230	1.65	60.74	Draws
OEEOEE	230,230	1.65	60.74	Draws
OEEEOE	230,230	1.65	60.74	Draws
OEEEEO	230,230	1.65	60.74	Draws
OEEEEE	177,100	1.27	78.96	Draws
EOOOOO	177,100	1.27	78.96	Draws
EOOOOE	177,100	1.27	78.96	Draws
EOOOEO	230,230	1.65	60.74	Draws
EOOEOO	230,230	1.65	60.74	Draws
EOOOEE	177,100	1.27	78.96	Draws
EOOEOE	230,230	1.65	60.74	Draws
EOOEEO	230,230	1.65	60.74	Draws
EOOEEE	177,100	1.27	78.96	Draws
EOEOOE	230,230	1.65	60.74	Draws
EOEOEO	296,010	2.12	47.24	Draws
EOEEOO	230,230	1.65	60.74	Draws
EOEOOO	230,230	1.65	60.74	Draws
EOEOEE	230,230	1.65	60.74	Draws
EOEEOE	230,230	1.65	60.74	Draws
EOEEEO	230,230	1.65	60.74	Draws
EOEEEE	177,100	1.27	78.96	Draws
EEOOOO	177,100	1.27	78.96	Draws
EEOOOE	177,100	1.27	78.96	Draws
EEOOEO	230,230	1.65	60.74	Draws
EEOEOO	230,230	1.65	60.74	Draws
EEOOEE	177,100	1.27	78.96	Draws
EEOEOE	230,230	1.65	60.74	Draws
EEOEEO	230,230	1.65	60.74	Draws
EEOEEE	177,100	1.27	78.96	Draws
EEEOOO	177,100	1.27	78.96	Draws
EEEOOE	177,100	1.27	78.96	Draws
EEEOEO	230,230	1.65	60.74	Draws
EEEEOO	177,100	1.27	78.96	Draws
EEEOEE	177,100	1.27	78.96	Draws
EEEEOE	177,100	1.27	78.96	Draws
EEEEEO	177,100	1.27	78.96	Draws
EEEEEE	134,596	0.96	103.89	Draws
Totals	13,983,816 100.00

I look forward to looking at your macro. I will clean my code up and post it also.

Thanks in Advance.
All the Best.
PAB
:wavey:
 

GillesD

Member
Even / Odd distribution

PAB, what do you mean by:

PAB said:
I have produced the following results using my program which differ slightly with yours ...
Is it the program itself or more likely the resullts? I found your results identical to mine but you have to remember that I use a zero (0) to identify an even number and a one (1) for an odd number while you use the letters O and E for Odd and Even.

My macro (not very elegant but it works) is:

Option Explicit

Dim A As Integer, B As Integer, C As Integer, D As Integer, E As Integer, F As Integer
Dim nVal As Double, nSum(64) As Double, I As Integer

Sub Test()
nVal = 0
For I = 1 To 64
nSum(I) = 0
Next I
For A = 1 To 44
For B = A + 1 To 45
For C = B + 1 To 46
For D = C + 1 To 47
For E = D + 1 To 48
For F = E + 1 To 49
vNb = vNb + 1
Select Case A
Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49
nVal = 100000
End Select
Select Case B
Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49
nVal = nVal + 10000
End Select
Select Case C
Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49
nVal = nVal + 1000
End Select
Select Case D
Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49
nVal = nVal + 100
End Select
Select Case E
Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49
nVal = nVal + 10
End Select
Select Case F
Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49
nVal = nVal + 1
End Select
If nVal = 0 Then nSum(1) = nSum(1) + 1
If nVal = 1 Then nSum(2) = nSum(2) + 1
If nVal = 10 Then nSum(3) = nSum(3) + 1
If nVal = 11 Then nSum(4) = nSum(4) + 1
If nVal = 100 Then nSum(5) = nSum(5) + 1
If nVal = 101 Then nSum(6) = nSum(6) + 1
If nVal = 110 Then nSum(7) = nSum(7) + 1
If nVal = 111 Then nSum(8) = nSum(8) + 1
If nVal = 1000 Then nSum(9) = nSum(9) + 1
If nVal = 1001 Then nSum(10) = nSum(10) + 1
If nVal = 1010 Then nSum(11) = nSum(11) + 1
If nVal = 1011 Then nSum(12) = nSum(12) + 1
If nVal = 1100 Then nSum(13) = nSum(13) + 1
If nVal = 1101 Then nSum(14) = nSum(14) + 1
If nVal = 1110 Then nSum(15) = nSum(15) + 1
If nVal = 1111 Then nSum(16) = nSum(16) + 1
If nVal = 10000 Then nSum(17) = nSum(17) + 1
If nVal = 10001 Then nSum(18) = nSum(18) + 1
If nVal = 10010 Then nSum(19) = nSum(19) + 1
If nVal = 10011 Then nSum(20) = nSum(20) + 1
If nVal = 10100 Then nSum(21) = nSum(21) + 1
If nVal = 10101 Then nSum(22) = nSum(22) + 1
If nVal = 10110 Then nSum(23) = nSum(23) + 1
If nVal = 10111 Then nSum(24) = nSum(24) + 1
If nVal = 11000 Then nSum(25) = nSum(25) + 1
If nVal = 11001 Then nSum(26) = nSum(26) + 1
If nVal = 11010 Then nSum(27) = nSum(27) + 1
If nVal = 11011 Then nSum(28) = nSum(28) + 1
If nVal = 11100 Then nSum(29) = nSum(29) + 1
If nVal = 11101 Then nSum(30) = nSum(30) + 1
If nVal = 11110 Then nSum(31) = nSum(31) + 1
If nVal = 11111 Then nSum(32) = nSum(32) + 1
If nVal = 100000 Then nSum(33) = nSum(33) + 1
If nVal = 100001 Then nSum(34) = nSum(34) + 1
If nVal = 100010 Then nSum(35) = nSum(35) + 1
If nVal = 100011 Then nSum(36) = nSum(36) + 1
If nVal = 100100 Then nSum(37) = nSum(37) + 1
If nVal = 100101 Then nSum(38) = nSum(38) + 1
If nVal = 100110 Then nSum(39) = nSum(39) + 1
If nVal = 100111 Then nSum(40) = nSum(40) + 1
If nVal = 101000 Then nSum(41) = nSum(41) + 1
If nVal = 101001 Then nSum(42) = nSum(42) + 1
If nVal = 101010 Then nSum(43) = nSum(43) + 1
If nVal = 101011 Then nSum(44) = nSum(44) + 1
If nVal = 101100 Then nSum(45) = nSum(45) + 1
If nVal = 101101 Then nSum(46) = nSum(46) + 1
If nVal = 101110 Then nSum(47) = nSum(47) + 1
If nVal = 101111 Then nSum(48) = nSum(48) + 1
If nVal = 110000 Then nSum(49) = nSum(49) + 1
If nVal = 110001 Then nSum(50) = nSum(50) + 1
If nVal = 110010 Then nSum(51) = nSum(51) + 1
If nVal = 110011 Then nSum(52) = nSum(52) + 1
If nVal = 110100 Then nSum(53) = nSum(53) + 1
If nVal = 110101 Then nSum(54) = nSum(54) + 1
If nVal = 110110 Then nSum(55) = nSum(55) + 1
If nVal = 110111 Then nSum(56) = nSum(56) + 1
If nVal = 111000 Then nSum(57) = nSum(57) + 1
If nVal = 111001 Then nSum(58) = nSum(58) + 1
If nVal = 111010 Then nSum(59) = nSum(59) + 1
If nVal = 111011 Then nSum(60) = nSum(60) + 1
If nVal = 111100 Then nSum(61) = nSum(61) + 1
If nVal = 111101 Then nSum(62) = nSum(62) + 1
If nVal = 111110 Then nSum(63) = nSum(63) + 1
If nVal = 111111 Then nSum(64) = nSum(64) + 1
nVal = 0
Next F
Next E
Next D
Next C
Next B
Next A
Range("A1").Select
For I = 1 To 64
ActiveCell.Offset(I, 2).Value = nSum(I)
Next I
End Sub

In the sheet where you want the reults to appear, enter the values 0 to 65 in cells A2 to A65. In cell B2, enter the formula =DEC2BIN(A2;6) and copy it down. This will give you 000000 to 111111, representing the various distributions of even numbers (0) and odd numbers (1).
 

PAB

Member
Thanks for the reply and code GillesD,

I approached it in a slightly different way using the "Mod" operator. Probably overkill I know but it did produce the required results. I will tidy up my code and post it.
I would also like to calculate the last digits distribution. How could your code be modified to accomodate this please.

Thanks in Advance.
All the Best.
PAB
:wavey:
 

Patrick123

Member
Hi GillesD,

I used Delphi. It was a fairly quick routine, not optimised at all. What adds to the slowness, is the feature where you can select the number of balls in the draw. Thus instead of hard-coding a six-level nested loop, I used a recursive routine:

Code:
procedure TfrmMain.GetBall(Start, Pos: Integer);
var
  i: Integer;
begin
  jj[Pos] := Start;
  if Pos >= RzSpinEdit2.IntValue then begin
    if cmbOdd.ItemIndex = 1 then
      GetPStats
    else
      GetStats;
     Exit;
  end;
  for i := Start+1 to RzSpinEdit1.IntValue - (RzSpinEdit2.IntValue -1 - pos) do begin
    GetBall(i,Pos+1);
    if StopIt then
      break;
  end;
end;


Regards
Patrick
 

PAB

Member
Hi GillesD,

Your code is certainly a lot quicker than mine. I think the reason for this is I have a LOT of formatting in my code for the outputed cells.
I like the =DEC2BIN(A2,6) engineering function that converts "Decimal" to "Binary", very neat. For anybody wanting to use this the Analysis ToolPak needs to be installed.

A couple of questions please :-
Could you please explain the reason for the following in the Case statements -:
nVal = 100000
nVal = 10000
nVal = 1000
nVal = 100
nVal = 10
nVal = 1

I changed the ";" to "," for the english version in the formula =DEC2BIN(A2;6).
I omitted the vNb = vNb + 1 because is not needed.
Out of interest, why have you used the nVal = 0 twice in your code.

Thanks in Advance.
All the Best.
PAB
:wavey:
 

GillesD

Member
Answers to PAB

A - You were right to change the "," to ";" in the function DEC2BIN; my Excel is configured to take a "," as the separator between arguments in a function and I forgot to change it in my post.

B - True the line vNb = vNb + 1 is not needed; I had put it there initialy to verify that I was going through all 13,983,816 combinations and forgot to remove it.

C - I like to declare the initial value for my variables, so the line nVal = 0 at the beginning, even if a variable in VBA takes a NUL value to start. The second line nVal = 0 is there to reset nVal after a combination (A, B, C, D E and F) has been processed.

D - With the CASE statement, the variable nVal is incremented by a multiple of 10 if a number in the combination (A to F) is odd. So in the end, a combination like 2, 14, 18, 28, 30 and 46 has a nVal value of 0, a combination like 1, 14, 15, 28, 37 and 46 has a nVal value of 101010 and a combination like 1, 13, 19, 25, 31 and 47 has a nVal value of 111111. Then the appropriate nSum(x) value is increased by 1 in a series of IF statements.

I could add that all CASE statements are not fully exact (like A can not take values of 47 and 49) but copying line was certainly faster this way.

E - For last digit distribution, I will think about it and come back to you.
 

church62

Member
I Need excel help

This may not be the right place for this question.
I would like to have an excel spreadsheet that
I can input a lotterys draw history and that can
tell me the best range of 21 numbers to play based on the past history of the lottery.

This should work with Super 7 Canada
that draws 7 balls from 1 to 47 + a bonus ball.

Thank you for your help in advance.:confused:
 

PAB

Member
Hi church62,

If you mean the top 21 numbers that have appeared the most times in the FULL history then you can use the "LARGE" function to produce these ...

Code:
=LARGE(range_start:range_end,position)
... where range_start could be cell A1, range_end could be cell F99 and position is the number you want to achieve.
So, for your example, assuming that the FULL history of draws are in cells A1:F999, enter the formulas :-

Code:
=LARGE(A1:F999,1)
=LARGE(A1:F999,2)
=LARGE(A1:F999,3)
=LARGE(A1:F999,4)
=LARGE(A1:F999,5)
=LARGE(A1:F999,6)
=LARGE(A1:F999,7)
=LARGE(A1:F999,8)
=LARGE(A1:F999,9)
=LARGE(A1:F999,10)
=LARGE(A1:F999,11)
=LARGE(A1:F999,12)
=LARGE(A1:F999,13)
=LARGE(A1:F999,14)
=LARGE(A1:F999,15)
=LARGE(A1:F999,16)
=LARGE(A1:F999,17)
=LARGE(A1:F999,18)
=LARGE(A1:F999,19)
=LARGE(A1:F999,20)
=LARGE(A1:F999,21)
If this is NOT what you want, I suggest you start a new thread in "Questions & Answers".

Hope this helps.
All the Best.
PAB
:wavey:
 

PAB

Member
Hi GillesD,

I have had a play around with the program and come up with the following.
I have built in the DEC2BIN function and included a bit of error checking.
For anybody wanting to run this, the DEC2BIN is classed as an engineering category function that converts Decimal numbers to Binary. It is incorporated in the Analysis ToolPak - VBA Add-In which MUST be installed.
Copy this code into a standard module and run it.

Code:
Option Explicit

Const minVal As Integer = 1
Const maxVal As Integer = 49
Const TotalComb As Long = 13983816

Sub Odd_and_Even()

Dim A As Integer, B As Integer, C As Integer, D As Integer, E As Integer, F As Integer
Dim nVal As Double
Dim nSum(64) As Double
Dim i As Integer
Dim j As Integer

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

For i = 1 To 64
  nSum(i) = 0
Next i

For A = minVal To maxVal - 5
  For B = A + 1 To maxVal - 4
    For C = B + 1 To maxVal - 3
      For D = C + 1 To maxVal - 2
        For E = D + 1 To maxVal - 1
          For F = E + 1 To maxVal
            
            Select Case A
              Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, _
                35, 37, 39, 41, 43, 45, 47, 49
              nVal = 100000
            End Select
            Select Case B
              Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, _
                35, 37, 39, 41, 43, 45, 47, 49
              nVal = nVal + 10000
            End Select
            Select Case C
              Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, _
                35, 37, 39, 41, 43, 45, 47, 49
              nVal = nVal + 1000
            End Select
            Select Case D
              Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, _
                35, 37, 39, 41, 43, 45, 47, 49
              nVal = nVal + 100
            End Select
            Select Case E
              Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, _
                35, 37, 39, 41, 43, 45, 47, 49
              nVal = nVal + 10
            End Select
            Select Case F
              Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, _
                35, 37, 39, 41, 43, 45, 47, 49
              nVal = nVal + 1
            End Select
              
            If nVal = 0 Then nSum(1) = nSum(1) + 1
            If nVal = 1 Then nSum(2) = nSum(2) + 1
            If nVal = 10 Then nSum(3) = nSum(3) + 1
            If nVal = 11 Then nSum(4) = nSum(4) + 1
            If nVal = 100 Then nSum(5) = nSum(5) + 1
            If nVal = 101 Then nSum(6) = nSum(6) + 1
            If nVal = 110 Then nSum(7) = nSum(7) + 1
            If nVal = 111 Then nSum(8) = nSum(8) + 1
            If nVal = 1000 Then nSum(9) = nSum(9) + 1
            If nVal = 1001 Then nSum(10) = nSum(10) + 1
            If nVal = 1010 Then nSum(11) = nSum(11) + 1
            If nVal = 1011 Then nSum(12) = nSum(12) + 1
            If nVal = 1100 Then nSum(13) = nSum(13) + 1
            If nVal = 1101 Then nSum(14) = nSum(14) + 1
            If nVal = 1110 Then nSum(15) = nSum(15) + 1
            If nVal = 1111 Then nSum(16) = nSum(16) + 1
            If nVal = 10000 Then nSum(17) = nSum(17) + 1
            If nVal = 10001 Then nSum(18) = nSum(18) + 1
            If nVal = 10010 Then nSum(19) = nSum(19) + 1
            If nVal = 10011 Then nSum(20) = nSum(20) + 1
            If nVal = 10100 Then nSum(21) = nSum(21) + 1
            If nVal = 10101 Then nSum(22) = nSum(22) + 1
            If nVal = 10110 Then nSum(23) = nSum(23) + 1
            If nVal = 10111 Then nSum(24) = nSum(24) + 1
            If nVal = 11000 Then nSum(25) = nSum(25) + 1
            If nVal = 11001 Then nSum(26) = nSum(26) + 1
            If nVal = 11010 Then nSum(27) = nSum(27) + 1
            If nVal = 11011 Then nSum(28) = nSum(28) + 1
            If nVal = 11100 Then nSum(29) = nSum(29) + 1
            If nVal = 11101 Then nSum(30) = nSum(30) + 1
            If nVal = 11110 Then nSum(31) = nSum(31) + 1
            If nVal = 11111 Then nSum(32) = nSum(32) + 1
            If nVal = 100000 Then nSum(33) = nSum(33) + 1
            If nVal = 100001 Then nSum(34) = nSum(34) + 1
            If nVal = 100010 Then nSum(35) = nSum(35) + 1
            If nVal = 100011 Then nSum(36) = nSum(36) + 1
            If nVal = 100100 Then nSum(37) = nSum(37) + 1
            If nVal = 100101 Then nSum(38) = nSum(38) + 1
            If nVal = 100110 Then nSum(39) = nSum(39) + 1
            If nVal = 100111 Then nSum(40) = nSum(40) + 1
            If nVal = 101000 Then nSum(41) = nSum(41) + 1
            If nVal = 101001 Then nSum(42) = nSum(42) + 1
            If nVal = 101010 Then nSum(43) = nSum(43) + 1
            If nVal = 101011 Then nSum(44) = nSum(44) + 1
            If nVal = 101100 Then nSum(45) = nSum(45) + 1
            If nVal = 101101 Then nSum(46) = nSum(46) + 1
            If nVal = 101110 Then nSum(47) = nSum(47) + 1
            If nVal = 101111 Then nSum(48) = nSum(48) + 1
            If nVal = 110000 Then nSum(49) = nSum(49) + 1
            If nVal = 110001 Then nSum(50) = nSum(50) + 1
            If nVal = 110010 Then nSum(51) = nSum(51) + 1
            If nVal = 110011 Then nSum(52) = nSum(52) + 1
            If nVal = 110100 Then nSum(53) = nSum(53) + 1
            If nVal = 110101 Then nSum(54) = nSum(54) + 1
            If nVal = 110110 Then nSum(55) = nSum(55) + 1
            If nVal = 110111 Then nSum(56) = nSum(56) + 1
            If nVal = 111000 Then nSum(57) = nSum(57) + 1
            If nVal = 111001 Then nSum(58) = nSum(58) + 1
            If nVal = 111010 Then nSum(59) = nSum(59) + 1
            If nVal = 111011 Then nSum(60) = nSum(60) + 1
            If nVal = 111100 Then nSum(61) = nSum(61) + 1
            If nVal = 111101 Then nSum(62) = nSum(62) + 1
            If nVal = 111110 Then nSum(63) = nSum(63) + 1
            If nVal = 111111 Then nSum(64) = nSum(64) + 1
            
            nVal = 0
              
          Next F
        Next E
      Next D
    Next C
  Next B
Next A

Range("B2").Select
With ActiveCell
  .Offset(0, 0).Value = "Total Odd (1) & Even (0) Combinations by Distribution"
  .Offset(1, 0).Value = "Distribution"
  .Offset(1, 1).Value = "Combinations"
  .Offset(1, 2).Value = "Percent"
  .Offset(1, 3).Value = "Expected 1 in"
  .Offset(1, 4).Value = "Draws"
  .Offset(0, 0).Resize(1, 5).BorderAround xlContinuous
  .Offset(1, 0).Resize(1, 5).Borders.LineStyle = xlContinuous
  .Offset(1, 1).Resize(1, 5).HorizontalAlignment = xlRight
  For j = 0 To 63
    For i = 1 To 64
      .Offset(j + 2, 0) = "'" & Application.Run("ATPVBAEN.XLA!DEC2BIN", j, 6)
      .Offset(i + 1, 1).Value = nSum(i)
      .Offset(i + 1, 2).Value = 100 / TotalComb * nSum(i)
      .Offset(i + 1, 3).Value = TotalComb / nSum(i)
      .Offset(i + 1, 4).Value = "Draws"
      .Offset(j + 2, 0).Errors(xlNumberAsText).Ignore = True
      .Offset(i + 1, 1).NumberFormat = "#,###,##0"
      .Offset(i + 1, 2).NumberFormat = "##0.00"
      .Offset(i + 1, 3).NumberFormat = "0.00"
      .Offset(i + 1, 4).HorizontalAlignment = xlRight
      .Offset(j + 2, 0).Resize(1, 5).Borders.LineStyle = xlContinuous
      .Offset(j + 3, 1).FormulaR1C1 = "=Sum(R4C3:R[-1]C)"
      .Offset(j + 3, 1).Formula = .Offset(j + 3, 1).Value
      .Offset(j + 3, 2).FormulaR1C1 = "=Sum(R4C4:R[-1]C)"
      .Offset(j + 3, 2).Formula = .Offset(j + 3, 2).Value
    Next i
  Next j
  .Offset(j + 2, 0).Value = "Totals"
  .Offset(j + 2, 1).NumberFormat = "#,###,##0"
  .Offset(j + 2, 2).NumberFormat = "##0.00"
  .Offset(j + 2, 0).Resize(1, 3).Borders.LineStyle = xlContinuous
  Columns("B:F").ColumnWidth = 12
End With

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

Have Fun!.
All the Best.
PAB
:wavey:
 

PAB

Member
Hi GillesD,

PAB said:
I would also like to calculate the last digits distribution. How could your code be modified to accomodate this please.
I have set up a new thread for this.

All the Best.
PAB
:wavey:
 

Sidebar

Top