Markov Chains

Frank

Member
Thats pretty much what I said in my first post in this thread. Its because the number of chains go up exponentially as each draw is added that I decided to break the chains and just count the ocurrences of each ball after each draw and add them up over history to get the most popular 'following numbers'. :)
 

Frank

Member
Here are screenshots of the Final part
http://www.mediafire.com/download/1d9y4gtbyecq48m/Project_final.rar

Here's a synopsis of what this upgrade entails:-
Currently there are 16 named ranges , when we finish there will be 24 named ranges..

This version displays the current draw (as defined by the top draw) and uses it for conditional formatting of summary tables.

We need to create more room for listing of maxima table options which will start on row 68

The minima table moves down to start on row 100

mintable and maxtable to expand to 22 rows height

Conditional formatting inside these tables to highlight current draw.

New formulas for top 3 balls etc and lowest three balls (counts) and more named ranges.

Add option button groups x 2
2 new macros
modification to an existing macro
link option buttons to macros
...........................................................................................................................................

Start of upgrade instructions
I suggest Using Save As to change the filename of this version, keeping your old version intact.

Before starting, run the macros with a high lookback figure to give decent high values in the 49 x 49 table, the modfications we will make wont like very very low values or columns with only 2 values in them. All will become clear...


The first thing I want to add is a result display, showing the topmost (latest draw from sheet1)
In cell AQ4 enter formula =OFFSET(Sheet1!B5,1,0)
copy this across to cell AV4. This should display the latest result. You can format this by boxes and add a label in cell AM4 "Latest result"


So to move on with this we wil need to make our two summary tables, mintable and maxtable taller because we will get more results with the new options we will have. Before we can do this we need to create more space by adding rows to sheet2. We need the tables 22 rows high.
So insert new rows above row 62 until the top of the maxima table is now located on row 68.

Now to increase the depth of the maxima table, (remember its a named range) the trick is to insert new rows somewhere in the middle of the table for example add new rows say on row 83 so that the table including headings now covers rows 68 to 91.If you check you will find that the whole results table is still a named range, it has updated itself. It should be 22 rows high. The border around the table should remain unbroken by the insertion of rows, if not you will need to repair it.


After this insert new rows above the top of the mintable so that the top of the table is now on row 100.

Similarly, add new rows in the middle of the mintable say at row 114, until its size covers rows 100 to row 123. As before, check the named range mintable has increased to match.

By doing this we have made room for some more formulas and the new option button groups.


We also need a bit more room below the mintable, the gap btween it and our find drawnumbers panel is a bit narrow. Click on row 126 and add about 6 rows to give a bigger gap. My find numbers panel now starts on row 134.
----------------------------------------------------------------------------------------------------------------------------------------------

OPTIONAL:..Now we have larger summary tables, it would be nice if the latest result turned the appropriate columns pink (or whatever colour you wish to use as a highlight).
For this we need the dreaded conditional formatting, I can only tell you the method for Excel 2010 here.

Click in cell C70
Select conditional formatting >Manage rules>New Rule>use a formula to determine which cells to format >format values where this formula is true

enter in the box...
=OR($AQ$4=C$69,$AR$4=C$69,$AS$4=C$69,$AT$4=C$69,$AU$4=C$69,$AV$4=C$69)
Format background colour of your choice .. I used pale pink. Click OK ....the dialog that remains should show what you just did, the colour you picked, and a box that says "applies to" ....
you need to change the contents to =$C$70:$AY$91
click OK to exit
That should do it................... you should see six highlighted columns

Same method for the Mintable
Click cell C102
select conditional formatting >Manage rules>New Rule>use a formula to determine which cells to format >format values where this formula is true
in the box enter
=OR($AQ$4=C$101,$AR$4=C$101,$AS$4=C$101,$AT$4=C$101,$AU$4=C$101,$AV$4=C$101)

click OK and the dialog thats lefts hould show what you just did, the colour you picked, and a box that says "applies to" ....
You need to change the contents to =$C$102:$AY$123
click OK to exit.

That should do it you should see six highlighted columns per table

-------------------- continued --------------------------------------------------------------------------------------------------------
 

Frank

Member
continued ...........................

We need some formulas for the benefit of the macros which will list the ball count maxima, the second maxima and third maxima values per ball. these will fit nicely now on rows60 , 61 and 62.
in cell C60 enter formula:- =MAX(C8:C56) copy this along the row to AY60

the next formula is an ARRAY FORMULA so you enter it by holding down the ctrl and shift keys whilst also pressing <enter>
in cell C61 enter formula =MAX(IF(ISNA(MATCH(C8:C56,C$59:C59,0)),C8:C56))

if you have done it correctly you will see :- {=MAX(IF(ISNA(MATCH(C8:C56,C$59:C59,0)),C8:C56))} curly brackets appear to show its an array formula.

In cell C62 is another ARRAY FORMULA ..enter . =IF(ISERROR(LARGE(C8:C56,COUNTIF(C8:C56,">="&LARGE(C8:C56, COUNTIF(C8:C56, MAX(C8:C56)) + 1))+1)),"N/A",LARGE(C8:C56,COUNTIF(C8:C56,">="&LARGE(C8:C56, COUNTIF(C8:C56, MAX(C8:C56)) + 1))+1))

Again if youve done the three key entry method you will see .... {=IF(ISERROR(LARGE(C8:C56,COUNTIF(C8:C56,">="&LARGE(C8:C56, COUNTIF(C8:C56, MAX(C8:C56)) + 1))+1)),"N/A",LARGE(C8:C56,COUNTIF(C8:C56,">="&LARGE(C8:C56, COUNTIF(C8:C56, MAX(C8:C56)) + 1))+1))}

The reason these are so compilcated is because you cant use the LARGE function to find second and third largest when there are repeats in the list, it doesn't work properly !

If you opted to have an autofilter across the top of the 49 x49 table then these three results should match the top 3 returned by the filter.

These two new formulas need copying across their rows to column AY and they should show sensible readings PROVIDED that the 49 x 49 table above hasn't got a max value less than 1 in it or hasn't got 3 different values in it. Otherwise you will see N/A in some cells. (If 1 is the max, the second max is 0 ..there is no third max ! ) Thats why high values and lots of different values work better here.

As usual, the two newest formula rows need named ranges, so the macros can read them
Name cell B60 next1
Name cell B61 next2
Note that we already have a named range called max which the macros can use, we don't need another. You can label the three cells B60,B61, B62 Max, next1 and next2.


Now for new formulas beneath the mintable :

in cell C126 enter the formula =MIN(C8:C56)

in cell C127 enter the ARRAY formula =MIN(IF(ISNA(MATCH(C8:C56,C$126:C126,0)),C8:C56)) ...should end up with the { } around it (ctrl+shift+enter).

in cell C128 enter the ARRAY formula =IF(ISERR(SMALL(C8:C56,COUNTIF(C8:C56,"<="&SMALL(C8:C56, COUNTIF(C8:C56, MIN(C8:C56))
+1))+1)),"N/A",SMALL(C8:C56,COUNTIF(C8:C56,"<="&SMALL(C8:C56, COUNTIF(C8:C56, MIN(C8:C56)) +1))+1))

again if you entered it correctly you'll see it surrounded by curly brackets. { }

These should return sensibe figures for Min, next higher count, and next higher again. Copy the formulas across their rows to column AY. Again if you get any N/A results they should only happen where the figures in the 49 x49 table don't have three different values in that column.

If you opted to have an autofilter across the top of the 49 x49 table then these three results should match the bottom 3 returned by the filter.

As usual, the two newest formula rows need named ranges, so the macros can read them
Name cell B127 min1
Name cell B128 min2
Note that we already have a named range called min which the macros can use, we don't need another. you can label the three cells B126,B127, B128 Min, min1 and min2

Now there will be times when some cells on Rows 61,62 127,128 will display N/A and the macros need to know this and take action. So we need to check for this condition. If any one cell across those rows contains N/A, we can detect it. We only need to check for the 3rd highest and lowest having this problem.

So in cell AZ62 enter the formula =COUNTIF(C62:AY62,"=N/A") . Name this cell maxerror.

In cell AZ128 enter the formula =COUNTIF(C128:AY128,"=N/A") . Name this cell minerror.

Hopefully these will now have a zero in them, meaning all is well with the finding top and bottom 3

Now the moment has come ... to insert 2 sets of option group buttons. One for maxtable and one for mintable. Each group will have 3 buttons one above the other, such that button1 returns a 1, button 2 returns a 2, button 3 returns a 3. It is important to create them in this order.


First option button group
(Because I will be linking all 3 to cell AH66 and covering it up by the buttons )
I first created abackground colour in the cells where the button group would live, a kind of light grey range AF64:AI67 so thats 4 rows high 4 cols wide.
draw your option group box (which will contain the buttons) over the range AF64:AI67 make it bigger if you like. Now draw your option buttons in order starting from the top. Link all three to cell AH66. If you prefer to choose another cell to link to outside the group to make the result easier to see, then do so. This linked cell must be named choice1.

I located mine inside the group outline, then changed the font to make it invisible (after testing).

Change the text on button1 to read Top3, change button 2 text to Top2, button3 text to Max only.
The option group text can read Max choices.

Test your buttons, when you pick Top3 you get a 1, pick top2 you get a 2, pick Max only you get a 3.

Second option button group
(Because I will be linking to cell AH98 and covering it up by the buttons )
I first created a background colour in the cells where the button group would live, a kind of light grey range AF96:AI99 so thats 4 rows high 4 cols wide.
draw your option group box (which will contain the buttons) over the range AF96:AI99 make it bigger if you like. Now draw your option buttons in order starting from the top. Link all three to cell AH98. If you prefer to choose another cell to link to outside the group, then do so. This linked cell must be named choice.

Change the text on button1 to read Bottom3, change button 2 text to Bottom2, button3 text to Minima only. The option group text can read Minima choices.
Test your buttons, when you pick Bottom3 you get a 1, pick Bottom2 you get a 2, pick Minima only you get a 3.


Okay.. I think we are ready for 2 modified macros. The option buttons will set and run macros CreateVariableMaxlist and CreateVariableMinlist.

continued in the next post.................
 

Frank

Member
These macros will read the settings on the option groups and refer to our new formulas to decide what to list in the boxes. Leave the old macros CreateMaxlist, CreateMinlist, ........just add these new ones on the same module.

Sub CreateVariableMaxList()
Dim i, j, count As Integer
Dim maxima(49, 49) As Integer 'the balls which are equal to the max in the column
Dim flag, Top3, top2, errorflag As Boolean
flag = False
Top3 = False
top2 = False
errorflag = False

If Range("choice1").Value = 1 Then Top3 = True
If Range("choice1").Value = 2 Then top2 = True


Application.ScreenUpdating = False
Range("readout").Select
For j = 1 To 49 ' ballnumber across left to right

count = 0
For i = 1 To 49 ' top result in column

If ActiveCell.Offset(i, j - 1) = Range("max").Offset(0, j) Then ' top result in column
count = count + 1
If count > 22 Then flag = True

maxima(j, count) = ActiveCell.Offset(i, -1).Value


End If

If Top3 Then

If Range("maxerror").Value > 0 Then ' there is no 3rd highest
errorflag = True
GoTo top3error
End If


If ActiveCell.Offset(i, j - 1) = Range("next1").Offset(0, j) Then 'second top result
count = count + 1
If count > 22 Then flag = True

maxima(j, count) = ActiveCell.Offset(i, -1).Value

End If

If ActiveCell.Offset(i, j - 1) = Range("next2").Offset(0, j) Then 'third top result
count = count + 1
If count > 22 Then flag = True

maxima(j, count) = ActiveCell.Offset(i, -1).Value

End If

End If 'top3


If top2 Then
If Range("maxerror").Value > 0 Then ' there is no 3rd highest
errorflag = True
GoTo top3error
End If

If ActiveCell.Offset(i, j - 1) = Range("next1").Offset(0, j) Then 'second top result
count = count + 1
If count > 22 Then flag = True

maxima(j, count) = ActiveCell.Offset(i, -1).Value

End If

End If 'top2


top3error:

Next i


Next j

If errorflag = True Then MsgBox ("Cannot do top 3, insufficient difference, doing max only")

'READOUT
Application.Calculation = xlCalculationManual
Range("maxtable").ClearContents

Range("maxlist").Select
For i = 1 To 22 ' 20 (count value) being max number of possible numbers having that maxima
For j = 1 To 49
If Range("max").Offset(0, j) = 0 Then
ActiveCell.Offset(i, j) = 0
Else
ActiveCell.Offset(i, j) = maxima(j, i)
End If
Next
Next
If flag = True Then

MsgBox "Listing of maxima has Too many equal results. You need to look back more draws to reduce them"

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

End Sub

Sub CreateVariableMinList()

Dim i, j, count As Integer
Dim minima(49, 49) As Integer 'the balls which are equal to the max in the column
Dim flag, bottom3, bottom2, errorflag1 As Boolean

flag = False
bottom2 = False
bottom3 = False
errorflag1 = False

If Range("choice").Value = 1 Then bottom3 = True
If Range("choice").Value = 2 Then bottom2 = True

Application.ScreenUpdating = False
Range("readout").Select
For j = 1 To 49 ' ballnumber across left to right

count = 0
For i = 1 To 49 ' result in column

If ActiveCell.Offset(i, j - 1) = Range("min").Offset(0, j) Then
count = count + 1
If count > 22 Then flag = True

minima(j, count) = ActiveCell.Offset(i, -1).Value



End If

If bottom3 = True Then

If Range("minerror").Value > 0 Then ' there is no 3rd lowest
errorflag1 = True
GoTo bottom3error
End If


If ActiveCell.Offset(i, j - 1) = Range("min1").Offset(0, j) Then
count = count + 1
If count > 22 Then flag = True

minima(j, count) = ActiveCell.Offset(i, -1).Value



End If

If ActiveCell.Offset(i, j - 1) = Range("min2").Offset(0, j) Then
count = count + 1
If count > 22 Then flag = True

minima(j, count) = ActiveCell.Offset(i, -1).Value



End If
End If 'bottom3

If bottom2 = True Then

If Range("minerror").Value > 0 Then ' there is no 3rd lowest
errorflag1 = True
GoTo bottom3error
End If

If ActiveCell.Offset(i, j - 1) = Range("min1").Offset(0, j) Then
count = count + 1
If count > 22 Then flag = True

minima(j, count) = ActiveCell.Offset(i, -1).Value


End If


End If 'bottom2

bottom3error:

Next i


Next j

If errorflag1 = True Then MsgBox ("Cannot do bottom 3, insufficient difference, doing min only")

'READOUT
Application.Calculation = xlCalculationManual
Range("mintable").ClearContents

Range("minlist").Select
For i = 1 To 22 ' 22 (count value) being max number of possible numbers having that maxima
For j = 1 To 49
If Range("min").Offset(0, j) = 0 Then
ActiveCell.Offset(i, j) = 0
Else
ActiveCell.Offset(i, j) = minima(j, i)
End If
Next
Next
If flag = True Then
MsgBox "Listing of minima has Too many equal results. You need to look back more draws to reduce them"
End If
Application.Calculation = xlCalculationAutomatic

Application.ScreenUpdating = True
End Sub

' end of macros

Currently the button on sheet 1 runs the old macros, so the existing macro count_most_followons() needs to be edited at the very end to remove the 2 calls to the old macros and replace with the new.

currently it reads:-
Application.ScreenUpdating = True
readout
CreateMaxList
CreateMinList
End Sub

change it to read:-

Application.ScreenUpdating = True
readout
CreateVariableMaxList
CreateVariableMinList
Find_drawnumbers
End Sub

Note that I have also added a call to Find_drawnumbers, this refreshes the list when the whole table is updated.

Before running the macros, be aware that some choices you make may not be available (remember the N/A we can get if there are not enough different values in the list ?) you may get a message telling you that your choice isn't available so you got just the minima (or maxima) instead.
Now make some selections in your option groups and click the button on sheet 1 to run all the macros. hopefully the 2 summary tables will do your bidding!

To make the option buttons even more useful we can make them drive our new macros directly on selection. To do this we need to assign a macro to each option button, thats three buttons set to drive CreateVariableMaxList and three buttons set to drive CreateVariableMinList.

Lets do The option group for the Maxlist first..
To do this its a bit fiddly because you have to prime the right click menu first by right clicking on any cell on the spreadsheet, up comes a long menu.. Immediately right click on the first option button and a similar menu will appear, one choice will be Assign macro, choose Assign macro and from the list choose CreateVariableMaxList. thats one done. repeat for the other 2 buttons in this group , same macro.

Now move down to the Minlist option group and repeat the procedure, remember to assign all 3 buttons to CreateVariableMinList

Now test this by making some choices with the buttons .. do they update immediately ? Good.

All that remains are some dynamic labels for the two tables, which show what is being displayed right now.

If you merge cells K66:AC67 and enter this formula:- =IF(choice1=1,"TOP 3 BALLS IN TABLE",IF(choice1=2,"TOP 2 BALLS ONLY","TOP BALLS ONLY"))

and Merge cells K98:AC99 and enter this formula:- =IF(choice=1,"BOTTOM 3 BALLS IN TABLE",IF(choice=2,"BOTTOM 2 BALLS ONLY","MINIMUM ONLY"))

That's all folks, I'm off to the pub !
 

HalfBee

Member
WARNING: Just a shout out that when you download Frank's project...
Mediafire might pop up nasty things to download in addition to what you want. Another of those bogus media players that wants to install itself :(

Just FYI (what do you expect for a free service)
 

bloubul

Member
HalfBee

You way wrong my friend. I have been using their service 2005 and had never had any problems.

Frank
Thanks for the next part.

BlouBul :cool:
 

HalfBee

Member
bloubul said:
HalfBee

You way wrong my friend. I have been using their service 2005 and had never had any problems.


BlouBul :cool:

I agree... I don't blame the service, only their advertisers...
Anything that pops up a new windows demanding I download an upgrade for a program I don't have or use and then makes it difficult to get rid of the notice is not playing by the polite rules we expect from legitimate companies.

Sorry, but those types of ads really push my button... I've had to repair too many computers that allowed such things to hold their computers hostage. Didn't say not to use that service, just wanted to give a warning...

We now return you to your regularly scheduled forum thread :)

HalfBee
 

Frank

Member
Well its still quiet, so nobody attempted the last part at all then ??? Did I waste my time posting it ?
 

HalfBee

Member
The time wasn't wasted, just takes a while to digest and impliment.

Excel isn't my environment, but the theory translates easy enough.
I'd like to hear more theory or ways to use the results achieved.

Trying to make a stable platform for 5-6-7 ball lotteries that I can use to
do specialty processing like Markovs, eliminators, etc. So keep throwing out
new ideas to try...

HalfBee
 

bloubul

Member
Hi Frank

No time wasted. I've been in hospital for 2 weeks. So I did not get around to the last project. As soon as I'm fit I will take it on.

BlouBul :cool:
 

patron

Member
Get well bloubul...
Frank, i've make the last step and everything works fine...
Now it's up to us to dig usefull data...
Thank's again for your time and for your macro
 

bloubul

Member
Hi Frank,

Thanks for your well wishes. Your instructions was great, but I'm short of 2 name ranges, will you please upload a screen dump with all the name ranges.

Thank you to patron.

BlouBul :cool:
 

Frank

Member
Ho Bloubul, I hope you are well. Here is the screen dump of the 24 named ranges and their locations....

http://www.mediafire.com/view/7j108gbkjsd3i5w/named_ranges.PNG
 

bloubul

Member
Hi Frank

Well I'm up and about. I have redone the whole scenario, but I run into trouble with the last bit. I'm unable to link the cells and I cannot format the control buttons. Please help me out I'm dead in the water.

BlouBul :cool:
 

Frank

Member
bloubul said:
Hi Frank

Well I'm up and about. I have redone the whole scenario, but I run into trouble with the last bit. I'm unable to link the cells and I cannot format the control buttons. Please help me out I'm dead in the water.

BlouBul :cool:
Hi Bloubul,

I have replied via email.

Regards,
Frank
 

Sidebar

Top