Lottery Lotto Gambling Software Systems Forum Index Lottery Lotto Gambling Software Systems
Software for lotto, lottery software founded on theory of probability, mathematics.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 



Hit Table generation......
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    Lottery Lotto Gambling Software Systems Forum Index -> Software Systems Theory
View previous topic :: View next topic  
Author Message
thornc



Joined: 22 Aug 2006
Posts: 72
Location: Here...

PostPosted: Mar 03, 2007 09:27    Post subject: Hit Table generation...... Reply with quote

or "The balance between time and strategies III"

Take the following code:
Code:

#!/usr/bin/env python
#
# Hit table generation...
# Needs a correctly formatted config file to work.
#
# example: config.ini
# [config]
# input_file=c649.txt
# top_recent=False
# output_file=out.txt
# nums=6
# max_nums=49
# look_back=100
#
#
# Copyright (c) 2007 C.Lopes aka thornc. (except on given functions)
#
# Released under the MIT License.
# http://www.opensource.org/licenses/mit-license.php
#


import sys,os

_N = '\n'
_SEP = '-'*60+_N


class ConfDict(dict):
    def __init__(self,**kw):
        dict.__init__(self,kw)
    def __getattr__(self,name):
        return self[name]
    def __setattr__(self, name, value):
        self.__setitem__(name,value)
    def __str__(self):
        state = ["%s=%r" % (attribute, value) for (attribute, value) in self.items()]
        return '\n'.join(state)
   
def fact(n):
   if n<=0: return 1
   out = long(1)
   for x in xrange(1,n+1):
      out *= x
   return out
   
def comb(n,k):
   return ( fact(n) )/( (fact(k))*(fact(n-k) ) )

# Taken from Python cookbook   
def xuniqueCombinations(items, n):
    if n==0: yield []
    else:
        for i in xrange(len(items)-n+1):
            for cc in xuniqueCombinations(items[i+1:],n-1):
                yield [items[i]]+cc

# Taken from Python cookbook
def histogram(seq,h_d={}):
    for x in seq:
        h_d[x]=h_d.setdefault(x,0)+1
    return h_d

def histlist(pastHist, newNums):
    h = histogram(newNums,pastHist)
    l = zip( h.values(), h.keys() )
    l.sort()
    l.reverse()
    return h,l

def hits(comb,line):
    return tuple(set(comb) & set(line))

def hitCount(comb,line):
    return len(hits(comb,line))

def sortList(aList):
   aList.sort()
   return aList
   
def usage():
   a=\
"""
%s <Config file name>
--
"""%(os.path.basename(sys.argv[0]),)
   sys.stderr.write(a)
   
def readConfigFile(confFile):
    import ConfigParser
   
    conf = ConfDict()
    try:
        cp = ConfigParser.ConfigParser()
        cp.read(confFile)
        conf.input_file=cp.get("config","input_file")
        conf.output_file=cp.get("config","output_file")
        conf.nums=cp.getint("config","nums")
        conf.max_nums=cp.getint("config","max_nums")
        conf.look_back=cp.getint("config","look_back")
        conf.top_recent=cp.getboolean("config","top_recent" )
    except Exception,e:
        sys.stderr.write("Problems reading config file\n")
        sys.stderr.write(e.message)
        sys.exit(3)
   
    return conf

def checkConfig(config):
    if not os.path.exists(config.input_file):
        sys.stderr.write("Input file ('%s') doesn't exist!\n"%(config.input_file,))
        sys.exit(4)
    if config.nums>config.max_nums:
        sys.stderr.write("Nums (%d) can not be bigger than Max_Nums (%d)!\n"%(config.nums,config.max_nums))
        sys.exit(4)
       
def getGroupBounds(cfg):
    from math import ceil
    bounds=[cfg.nums]
    bounds.append( cfg.max_nums - int( ceil (cfg.max_nums * 0.50) ) )
    return bounds
   
def readInputData(cfg):
    inFile = open(cfg.input_file,'ra')
    data = inFile.readlines()
    inFile.close()
   
    allLines = [ map(int,y) for y in [ x.split() for x in data ] ]
    if cfg.top_recent:
        allLines.reverse()
   
    return allLines

def main():
    if len(sys.argv) != 2:
        usage()
        sys.exit(1) 
    confFile = sys.argv[1]
    if not os.path.exists(confFile):
        usage()
        sys.stderr.write("Config file supplied doesn't exist\n")
        sys.exit(2)
       
    cfg = readConfigFile(confFile)
    checkConfig(cfg)
   
   
    print "HitTable Generator"
    print "------------------"
    print "Config:"
    print cfg
    print "------------------"   
   
    bounds = getGroupBounds(cfg)
   
    outFile = open(cfg.output_file,"wa")
   
    allLines = readInputData(cfg)
   
    allNums = []
    for line in allLines[:-1*cfg.look_back]:
        allNums += [x for x in line]
     
    histHits = []
    histReport = []
    h = histogram(allNums,{})
    for i in xrange(-1*cfg.look_back,-1,1):
        line = allLines[i]
        line.sort()   
        h,l = histlist(h, line )
       
        g1 = [ y for (x, y) in l[ 0:bounds[0] ] ]
        g1.sort()
        g1l = len(g1)
        g1h = hitCount(g1, allLines[i+1])
        g2 = [ y for (x, y) in l[ bounds[0]:bounds[1] ] ]
        g2.sort()
        g2l = len(g2)
        g2h = hitCount(g2, allLines[i+1])
        g3 = [ y for (x, y) in l[ bounds[1]: ] ]
        g3.sort()
        g3l = len(g3)
        g3h = hitCount(g3, allLines[i+1])

        tmp=" ".join([str(d) for d in [g1h,g2h,g3h]] )
        histHits.append(tmp)
        tmp = " ".join([ "%-3d"%(abs(i),),"\t"," ".join([ "%02d"%(x,) for x in line]),"\t",tmp,"\t\t", "%12d"%(comb(g1l,g1h)*comb(g2l,g2h)*comb(g3l,g3h),)])+_N
        histReport.append(tmp)
       
    histReport.reverse()
    outFile.write("\n\n\tHit Table Report Generator\n")
    outFile.write(_SEP)     
    outFile.write("\tInput: %s \t Output: %s\n\tType: %d/%d \tLook Back: %d\n" %(cfg.input_file,cfg.output_file,cfg.nums,cfg.max_nums,cfg.look_back))   
    outFile.write(_SEP)   
    outFile.write("D.Back\tNumbers\t\t\t\t\tGrouping\tCombinations\n")
    outFile.write(_SEP)   
    outFile.writelines(histReport)
     
    hout,lout = histlist({},histHits)   

    outFile.write(_N)
    outFile.write(_N)
    outFile.write(_N)
    outFile.write("\tHits per Group Histogram\n")
    outFile.write("-"*30+_N)
    outFile.write("\tHits\tGrouping\n")
    outFile.write("-"*30+_N)
    outFile.write('\n'.join(["\t%02d  \t%s" % (count, num) for (count, num) in lout])+_N)
   
    h,l  = histlist(h,allLines[-1])
   
    g1 = [ y for (x, y) in l[ 0:bounds[0] ] ]
    g1.sort()
    g1l = len(g1)
    g2 = [ y for (x, y) in l[ bounds[0]:bounds[1] ] ]
    g2.sort()
    g2l = len(g2)
    g3 = [ y for (x, y) in l[ bounds[1]: ] ]
    g3.sort()

    outFile.write(_N)
    outFile.write(_N)
    outFile.write(_N)
    outFile.write("\tGroups:\n")
    outFile.write("-"*30+_N)
    outFile.write(' '.join([ str(x) for x in g1])+_N)
    outFile.write(' '.join([ str(x) for x in g2])+_N)
    outFile.write(' '.join([ str(x) for x in g3])+_N)
   
    outFile.close()
    print "Output ('%s') generated!"%(cfg.output_file,)

if __name__=="__main__":
    main()
         



Paste it into a file named for example HitTable.py (NOTE spaces/tabs matter); download and install Python (if you don't have it yet) and run this with something like:
Quote:

HitTable.py config.ini


I have tested this on Windows XP + Python 2.5; but it should work with any version of Python and OS.
I don't exclude the possibility that there might be some unfound bugs...

Have fun and ask feel free to ask questions....
_________________
Just ME here....
Back to top
View user's profile Send private message
thornc



Joined: 22 Aug 2006
Posts: 72
Location: Here...

PostPosted: Mar 03, 2007 09:29    Post subject: Reply with quote

Here's a sample output....

Code:



   Hit Table Report Generator
------------------------------------------------------------
   Input: c649.txt     Output: out.txt
   Type: 6/49    Look Back: 100
------------------------------------------------------------
D.Back   Numbers               Grouping   Combinations
------------------------------------------------------------
2       04 06 15 33 38 40     1 1 4             1366200
3       05 06 17 21 31 46     1 2 3             2111400
4       13 20 31 36 43 46     1 2 3             2111400
5       10 24 35 40 41 45     2 3 1              306000
6       08 13 23 37 41 42     1 2 3             2111400
7       04 08 11 27 37 47     0 2 4             1935450
8       10 13 24 27 37 39     1 2 3             2111400
9       02 06 09 11 14 37     0 1 5              956340
10      06 09 17 20 22 40     0 0 6              177100
11      06 11 20 26 34 35     1 1 4             1366200
12      24 40 45 47 48 49     1 2 3             2111400
13      05 07 09 30 39 40     2 2 2              688500
14      01 02 03 19 25 41     0 3 3             1876800
15      09 16 19 41 46 49     0 3 3             1876800
16      19 20 33 43 45 47     0 4 2              918000
17      04 14 17 20 38 48     3 2 1               76500
18      10 14 18 40 45 49     0 3 3             1876800
19      04 05 12 24 38 45     1 2 3             2111400
20      04 06 19 22 23 45     1 2 3             2111400
21      02 09 12 29 33 37     1 2 3             2111400
22      07 22 24 30 38 46     0 1 5              956340
23      08 11 22 27 33 36     0 4 2              918000
24      04 11 18 20 29 44     1 1 4             1366200
25      02 06 12 18 22 29     0 4 2              918000
26      08 32 33 43 46 49     0 1 5              956340
27      05 09 14 31 37 46     1 3 2             1468800
28      01 18 20 23 41 47     1 1 4             1366200
29      03 08 14 28 31 39     1 3 2             1468800
30      01 11 22 25 39 41     1 0 5              318780
31      05 08 34 37 44 47     0 2 4             1935450
32      03 05 06 07 26 40     2 1 3              621000
33      03 04 20 38 42 48     0 3 3             1876800
34      06 23 30 33 37 41     0 4 2              918000
35      02 18 24 25 30 40     0 2 4             1935450
36      01 10 26 38 39 47     0 2 4             1935450
37      09 33 37 38 42 49     1 3 2             1468800
38      02 04 25 29 41 43     0 3 3             1876800
39      06 18 25 34 45 49     1 2 3             2111400
40      09 14 22 45 47 49     2 1 3              621000
41      08 12 24 30 34 35     2 0 4              189750
42      15 20 33 37 39 45     1 1 4             1366200
43      12 13 22 26 37 45     1 1 4             1366200
44      01 10 18 24 31 46     0 2 4             1935450
45      15 23 38 40 41 49     1 2 3             2111400
46      06 11 19 20 32 39     0 4 2              918000
47      10 30 41 43 45 47     0 3 3             1876800
48      05 13 14 29 39 40     2 3 1              306000
49      19 30 32 33 38 41     0 2 4             1935450
50      13 22 31 32 34 48     0 5 1              214200
51      03 08 20 26 37 46     2 1 3              621000
52      03 09 10 14 17 19     0 3 3             1876800
53      01 09 15 26 29 32     0 1 5              956340
54      01 09 10 24 32 35     0 4 2              918000
55      04 07 16 23 27 39     0 2 4             1935450
56      09 10 19 43 47 49     1 2 3             2111400
57      03 04 08 25 41 48     2 1 3              621000
58      03 10 21 23 33 44     0 2 4             1935450
59      13 15 28 29 33 47     0 2 4             1935450
60      02 13 19 25 30 32     1 1 4             1366200
61      06 26 27 33 41 42     0 3 3             1876800
62      13 16 21 42 46 49     1 3 2             1468800
63      03 07 15 38 43 47     0 3 3             1876800
64      02 06 09 20 43 44     2 2 2              688500
65      08 13 21 22 24 39     1 2 3             2111400
66      13 17 21 33 41 42     0 1 5              956340
67      06 26 30 38 44 45     0 3 3             1876800
68      11 14 29 33 42 44     0 5 1              214200
69      02 21 22 29 34 35     0 3 3             1876800
70      11 19 36 41 46 49     1 1 4             1366200
71      03 05 19 20 34 47     0 4 2              918000
72      02 20 26 29 37 45     2 2 2              688500
73      04 17 34 39 41 46     0 3 3             1876800
74      11 14 20 25 31 36     1 3 2             1468800
75      10 11 36 38 46 48     1 2 3             2111400
76      18 23 32 34 41 46     0 3 3             1876800
77      11 12 14 27 34 48     1 3 2             1468800
78      08 20 21 27 36 48     2 1 3              621000
79      11 14 34 40 42 43     1 3 2             1468800
80      09 15 18 34 35 45     3 1 2              108000
81      01 15 18 19 29 37     1 1 4             1366200
82      15 18 22 31 43 49     0 2 4             1935450
83      09 19 20 24 36 48     2 0 4              189750
84      02 10 11 16 42 43     0 3 3             1876800
85      03 17 36 44 45 48     1 2 3             2111400
86      06 28 30 31 34 48     0 3 3             1876800
87      01 17 24 29 34 46     2 1 3              621000
88      04 29 35 40 43 45     1 2 3             2111400
89      01 25 35 36 37 44     2 2 2              688500
90      21 22 23 24 48 49     0 3 3             1876800
91      03 07 16 18 29 49     0 1 5              956340
92      02 03 09 21 26 29     0 2 4             1935450
93      11 14 15 29 31 47     0 2 4             1935450
94      01 06 08 10 15 20     2 0 4              189750
95      10 19 20 35 36 38     0 2 4             1935450
96      04 06 08 12 34 38     0 4 2              918000
97      01 14 23 35 47 49     1 3 2             1468800
98      17 23 24 33 35 41     1 1 4             1366200
99      08 12 17 23 36 38     0 1 5              956340
100     01 06 31 37 44 45     0 3 3             1876800



   Hits per Group Histogram
------------------------------
   Hits   Grouping
------------------------------
   17     0 3 3
   15     1 2 3
   13     0 2 4
   10     1 1 4
   08     1 3 2
   08     0 4 2
   07     0 1 5
   06     2 1 3
   04     2 2 2
   03     2 0 4
   02     2 3 1
   02     0 5 1
   01     3 2 1
   01     3 1 2
   01     1 0 5
   01     0 0 6



   Groups:
------------------------------
31 34 40 43 45 47
1 4 7 19 20 21 26 27 29 30 32 36 38 41 42 44 46 49
2 3 5 6 8 9 10 11 12 13 14 15 16 17 18 22 23 24 25 28 33 35 37 39 48





Cool
_________________
Just ME here....
Back to top
View user's profile Send private message
marcher
Site Admin


Joined: 19 May 2006
Posts: 530

PostPosted: Mar 03, 2007 12:25    Post subject: Reply with quote

Cristi:

Great job, man! Your frequency report looks very clear. Somehow you use a different terminology. Nevertheless, the report should be very clear to most computer users.

I am not investing any time in learning Python, or any other language in addition to BASIC. I think I figured out the parpaluck in your program (number of drawings for determining the 3 frequency groups). It should be calculated here in your sample code:

max_nums * 0.50 (e.g. 49 * .5 = 25 draws for parpaluck)

You could add another parameter in the config file for the parpaluck.

You have this at the end:

Groups:
------------------------------
31 34 40 43 45 47
1 4 7 19 20 21 26 27 29 30 32 36 38 41 42 44 46 49
2 3 5 6 8 9 10 11 12 13 14 15 16 17 18 22 23 24 25 28 33 35 37 39 48

Those should be the frequency groups for drawing #100. The frequency groups change — not from draw to draw, but they change several times within 100 drawings analyzed.

Now, you can write the code for decades!!! It is much simpler.

And THEN! You write code to look for strategies; e.g. 1-2-3 for frequency and 1-1-2-1-1 for decades.

Many people will be even more thankful to you. I am sure many people are already thankful for your code and programming lessons. I know, you are a system engineer not a programmer (two different computing jobs). But you know how to program very clearly. My source code is badly formatted and largely undocumented! I want it that way, because a good programmer should be paranoid as well!

You already wrote the code to generate the combinations. You can write a command-and-control program to put together the report generators, strategy checking, and combinations generators.

You do a good service to Python.

Boa suerte!

Ion Saliu,
Python-Constrictor At-Large
The best free software downloads site

PS
How about a new programming language: BOA?
IS
Back to top
View user's profile Send private message
chelmi



Joined: 11 Sep 2006
Posts: 64

PostPosted: Mar 03, 2007 13:17    Post subject: Hit Table Report Generator Reply with quote

thornc wrote:
Here's a sample output....

Here is mine for a 5/50 game. Just to say it works even for a neophyte!

here is my config.ini file, located in the same folder as the HitTable.py and the C550.txt

Thanks for this unvaluable new tool!



[config]
input_file=c550.txt
top_recent=False
output_file=out.txt
nums=5
max_nums=50
look_back=100





Code:




   Hit Table Report Generator
------------------------------------------------------------
   Input: c550.txt     Output: out.txt
   Type: 5/50    Look Back: 100
------------------------------------------------------------
D.Back   Numbers               Grouping   Combinations
------------------------------------------------------------
2       03 07 11 26 40     0 1 4              253000
3       03 13 16 19 37     0 2 3              437000
4       04 19 31 35 43     0 3 2              342000
5       01 13 21 22 41     0 3 2              342000
6       16 28 29 44 50     3 1 1                5000
7       10 28 30 48 49     0 3 2              342000
8       20 28 35 43 44     0 2 3              437000
9       03 19 36 39 41     0 3 2              342000
10      07 13 15 18 40     0 1 4              253000
11      12 14 16 25 49     0 3 2              342000
12      02 18 36 37 39     1 3 1              142500
13      11 14 17 21 43     0 1 4              253000
14      18 30 35 45 48     1 3 1              142500
15      16 22 32 34 43     0 3 2              342000
16      07 09 18 21 43     1 2 2              285000
17      12 22 26 27 45     1 2 2              285000
18      07 13 17 27 48     1 3 1              142500
19      03 07 18 37 39     0 3 2              342000
20      06 32 36 37 45     0 1 4              253000
21      14 17 25 33 47     0 1 4              253000
22      04 06 19 36 47     1 2 2              285000
23      01 09 15 23 45     0 1 4              253000
24      04 19 27 37 38     2 2 1               47500
25      05 17 21 23 38     0 2 3              437000
26      21 26 42 43 47     2 1 2               60000
27      05 16 31 49 50     1 1 3              230000
28      22 25 26 39 45     0 2 3              437000
29      14 23 24 33 45     2 1 2               60000
30      13 29 36 41 42     1 2 2              285000
31      06 16 19 38 49     0 2 3              437000
32      13 20 23 27 45     0 2 3              437000
33      04 11 15 25 33     1 3 1              142500
34      07 10 15 25 33     1 2 2              285000
35      06 10 34 45 46     1 1 3              230000
36      14 18 23 32 46     0 0 5               53130
37      07 18 20 42 49     1 3 1              142500
38      11 41 42 43 46     0 2 3              437000
39      02 18 31 37 39     0 1 4              253000
40      06 07 31 33 44     0 2 3              437000
41      01 05 21 40 47     0 1 4              253000
42      04 13 31 38 45     2 0 3               23000
43      04 06 20 29 44     0 2 3              437000
44      01 03 10 31 48     0 2 3              437000
45      01 37 38 41 47     1 1 3              230000
46      05 20 21 47 50     1 0 4               63250
47      06 08 19 21 41     1 1 3              230000
48      03 15 16 31 37     1 1 3              230000
49      05 12 30 44 47     0 3 2              342000
50      01 03 18 25 36     0 2 3              437000
51      10 20 39 44 47     2 1 2               60000
52      18 35 36 38 42     0 1 4              253000
53      02 12 13 28 47     0 2 3              437000
54      08 22 35 46 50     0 3 2              342000
55      04 07 14 16 36     1 1 3              230000
56      04 07 12 24 26     0 2 3              437000
57      01 08 18 23 29     0 3 2              342000
58      02 28 38 43 46     2 2 1               47500
59      13 31 40 41 47     0 1 4              253000
60      05 24 31 39 43     0 2 3              437000
61      09 13 18 39 50     0 2 3              437000
62      21 24 30 38 44     0 3 2              342000
63      06 23 31 42 46     1 2 2              285000
64      05 13 31 43 48     1 1 3              230000
65      03 07 14 17 26     0 2 3              437000
66      02 27 37 40 46     0 3 2              342000
67      03 13 14 33 35     0 1 4              253000
68      13 16 26 30 40     0 3 2              342000
69      09 12 30 40 48     0 4 1              121125
70      08 10 18 21 31     0 3 2              342000
71      05 24 37 42 46     1 2 2              285000
72      08 23 30 39 46     0 1 4              253000
73      15 21 24 34 49     1 1 3              230000
74      06 13 17 18 44     1 2 2              285000
75      25 26 32 40 46     0 3 2              342000
76      05 22 43 45 49     1 2 2              285000
77      16 23 24 26 30     1 0 4               63250
78      10 11 17 42 47     1 4 0               24225
79      02 18 24 27 46     0 2 3              437000
80      08 23 32 42 47     0 3 2              342000
81      02 23 42 46 48     1 1 3              230000
82      04 38 42 47 49     1 0 4               63250
83      04 20 22 24 25     0 0 5               53130
84      03 15 24 41 44     2 2 1               47500
85      17 20 38 43 48     0 2 3              437000
86      02 24 25 39 42     0 2 3              437000
87      14 24 27 32 33     1 1 3              230000
88      09 11 14 36 37     0 4 1              121125
89      07 21 28 30 31     0 3 2              342000
90      11 27 35 48 50     1 3 1              142500
91      16 18 26 39 50     0 3 2              342000
92      04 12 13 16 34     0 3 2              342000
93      14 16 21 29 43     0 3 2              342000
94      08 10 11 30 32     1 3 1              142500
95      01 05 23 42 45     0 3 2              342000
96      07 10 15 32 48     2 0 3               23000
97      01 09 21 47 48     0 2 3              437000
98      03 04 17 20 28     2 1 2               60000
99      07 17 23 30 36     0 3 2              342000
100     01 28 31 38 45     1 2 2              285000



   Hits per Group Histogram
------------------------------
   Hits   Grouping
------------------------------
   22     0 3 2
   20     0 2 3
   12     0 1 4
   10     1 2 2
   10     1 1 3
   07     1 3 1
   04     2 1 2
   03     2 2 1
   03     1 0 4
   02     2 0 3
   02     0 4 1
   02     0 0 5
   01     3 1 1
   01     1 4 0



   Groups:
------------------------------
1 21 22 23 25
9 11 12 13 14 15 16 17 18 19 20 24 26 27 28 29 30 31 32 35
2 3 4 5 6 7 8 10 33 34 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50






Cool
Back to top
View user's profile Send private message
thornc



Joined: 22 Aug 2006
Posts: 72
Location: Here...

PostPosted: Mar 03, 2007 13:28    Post subject: Reply with quote

I was going to post a executive summary of the script, but I think that a reply to marcher is in order first....


marcher wrote:

I think I figured out the parpaluck in your program (number of drawings for determining the 3 frequency groups). It should be calculated here in your sample code:

max_nums * 0.50 (e.g. 49 * .5 = 25 draws for parpaluck)

You could add another parameter in the config file for the parpaluck.

I don't use the concept of "parpaluck" in this program; the frequency is calculated on all draws of the history file given. I might add the concept in the future once I have looked at it carefully.

marcher wrote:

You have this at the end:
(...)
Those should be the frequency groups for drawing #100. The frequency groups change — not from draw to draw, but they change several times within 100 drawings analyzed.

The idea here is that one can copy&paste these into a new file and feed it to the other script I posted....


marcher wrote:

Now, you can write the code for decades!!! It is much simpler.

And THEN! You write code to look for strategies; e.g. 1-2-3 for frequency and 1-1-2-1-1 for decades.

Maybe, who knows... it all depends on my available time.

marcher wrote:

Boa suerte!

Thanks.... but I think you mixed Portuguese and Spanish on the same sentence... Smile it should be "Boa sorte" (PT) , "Buena suerte" (SP) or better yet "Buona fortuna" (IT) [although Italians actually use a different expression which I refuse to use for environmental reasons!]

marcher wrote:

How about a new programming language: BOA?

Don't know that one.... I googled it but didn't find anything special!


Basically this new script goes back "look_back" draws in the "input_file", calculates the the histogram/frequency table for all draws up to then and then starts calculating groups, hits per group and updating the histogram up to the last draw (most recent). For this last draw the corresponding groups are reported.
The rationale being that you look at how the distribution looked like for the past draws (summarized in the histogram/frequency table) and given the next groups decide what could be the next distribution.....
_________________
Just ME here....
Back to top
View user's profile Send private message
marcher
Site Admin


Joined: 19 May 2006
Posts: 530

PostPosted: Mar 03, 2007 14:22    Post subject: Reply with quote

Cristi:

My frequency system is founded on the parpaluck. Every draw generates a specific frequency grouping based on the parpaluck. I wrote more about it in Ommni’s thread, where you also participate.

I take Chelmi’s configuration file for his Euromillions game. He only considers the 5 regular numbers out of 50. p = 5/50 = 1/10. The parpaluck can be 10, or 20, or 15, or even 50. I would add a ‘parpaluck’ line in the config file:

Quote:
[config]
input_file=c550.txt
top_recent=False
output_file=out.txt
nums=5
max_nums=50
look_back=100
parpaluck=10



Changing the parpaluck will change the bias of the 1-2-3 frequency strings. The bias towards the smaller frequency groups is the most favorable for the player.

I dimension the arrays in my software this way:

ReDim Lotto_1(look_back+parpaluck), Lotto_2(look_back+parpaluck), etc.

(Lotto_1 is the lotto number 1 in the draw, Lotto_2 is the 2nd lotto number, etc.)

Then, the program takes each drawing analyzed and calculates the frequency groups for the specific parpaluck. Sometimes I calculate the frequency ‘tables’ for the previous drawing, instead of the current one.

The generator dimensions data the same way, but generates the frequency groups only for lotto draw #1 (the top line) in the data file. The parpaluck must be the same in the report generator and the combination generator.

For Powerball and Euromillions the frequency groups are calculated only for the last 1 (or 2) numbers in the draw.

Code:
-----------------------------------------------------------------
D.Back   Numbers         Reg Groups   Star Groups   Combinations
-----------------------------------------------------------------
                           1  2  2      0 2 0 



Boa fortuna!
Back to top
View user's profile Send private message
marcher
Site Admin


Joined: 19 May 2006
Posts: 530

PostPosted: Mar 03, 2007 14:52    Post subject: Reply with quote

I forgot to mention.

The parpaluck is very important!

It is likely that the generator will not generate the winning combination even if the correct 1-2-3 frequency string would hit. The 1-2-3 groups are specific to each lotto drawing. Actually, you don’t know when a 1-2-3 hits because the frequency ‘tables’ are not draw-dependent (in the Python report generator).

I don’t know if I am clear in this regard. I just did a test for my lotto 6/49 game. I ran the ‘Check strategy hits’ function with various parpalucks. You can look at the SkipDecades.EXE programs. So, I see the strategy report (‘Check strategy’ function). I know that the strategy hit in, say, 5 drawings. I know exactly the drawings. I run the ‘Check strategy hits’ function and generate the winning combination in every winning situation. That is true only if I use the same parpaluck as in the ‘Check strategy’ function. If I change the parpaluck, the ‘Check strategy hits’ function will miss the winning combination — more often than not.

I disabled the combination generation in the SkipDecades.EXE programs. But the code is still in there (commented out). I always test the winning combinations whenever I make changes to my software. I remember all too well the MDIEditor headaches of the 2006 summer!
Back to top
View user's profile Send private message
chelmi



Joined: 11 Sep 2006
Posts: 64

PostPosted: Mar 03, 2007 15:58    Post subject: Hit Table generation...... Reply with quote

marcher wrote:
Cristi:

My frequency system is founded on the parpaluck. Every draw generates a specific frequency grouping based on the parpaluck. I wrote more about it in Ommni’s thread, where you also participate.

I take Chelmi’s configuration file for his Euromillions game. He only considers the 5 regular numbers out of 50. p = 5/50 = 1/10. The parpaluck can be 10, or 20, or 15, or even 50. I would add a ‘parpaluck’ line in the config file:

Quote:
[config]
input_file=c550.txt
top_recent=False
output_file=out.txt
nums=5
max_nums=50
look_back=100
parpaluck=10




In case you add the parpaluck function into your latest python, I suggest this can be done as a variable input (at the keyboard), not a fixed value in the config file.

Chelmi

ps: The Boa and the python belong both to the same reptile specie.
Back to top
View user's profile Send private message
chelmi



Joined: 11 Sep 2006
Posts: 64

PostPosted: Mar 03, 2007 18:00    Post subject: Re: Hit Table generation...... Reply with quote

chelmi wrote:
marcher wrote:
Cristi:

My frequency system is founded on the parpaluck. Every draw generates a specific frequency grouping based on the parpaluck. I wrote more about it in Ommni’s thread, where you also participate.

I take Chelmi’s configuration file for his Euromillions game. He only considers the 5 regular numbers out of 50. p = 5/50 = 1/10. The parpaluck can be 10, or 20, or 15, or even 50. I would add a ‘parpaluck’ line in the config file:

Quote:
[config]
input_file=c550.txt
top_recent=False
output_file=out.txt
nums=5
max_nums=50
look_back=100
parpaluck=10




In case you add the parpaluck function into your latest python, I suggest this can be done as a variable input (at the keyboard), not a fixed value in the config file.

Chelmi

ps: The Boa and the python belong both to the same reptile specie.


ps2
Changing the loop_back value does NOT produce different groups of frequency.
I made various trials with different values from 2 to 100 and always obtained the same 3 groups composition.
Any explanation?
Regards
Back to top
View user's profile Send private message
thornc



Joined: 22 Aug 2006
Posts: 72
Location: Here...

PostPosted: Mar 03, 2007 19:44    Post subject: Re: Hit Table generation...... Reply with quote

chelmi wrote:

Changing the loop_back value does NOT produce different groups of frequency.
I made various trials with different values from 2 to 100 and always obtained the same 3 groups composition.
Any explanation?


No, the loop_back simply indicates how many draws to produce the report for.... you should see a change in the histogram and that's it! I will consider adding a parameter to select how many draws to use for the hit table calculation!

PS: What did you think about the eclipse today? Pretty nice isn't it, it's the reason why I am still here to post at this time.
_________________
Just ME here....
Back to top
View user's profile Send private message
chelmi



Joined: 11 Sep 2006
Posts: 64

PostPosted: Mar 04, 2007 03:42    Post subject: Re: Hit Table generation...... Reply with quote

thornc wrote:
chelmi wrote:

Changing the loop_back value does NOT produce different groups of frequency.
I made various trials with different values from 2 to 100 and always obtained the same 3 groups composition.
Any explanation?


No, the loop_back simply indicates how many draws to produce the report for.... you should see a change in the histogram and that's it! I will consider adding a parameter to select how many draws to use for the hit table calculation!

PS: What did you think about the eclipse today? Pretty nice isn't it, it's the reason why I am still here to post at this time.


Understood!
Thanks for your help.
I did'nt see the eclipse; probably local for your place.
http://www.chez.com/lepithec/eclipse/ is a french site dedicated to eclipses. Nice photos.
Back to top
View user's profile Send private message
thornc



Joined: 22 Aug 2006
Posts: 72
Location: Here...

PostPosted: Mar 04, 2007 06:10    Post subject: Re: Hit Table generation...... Reply with quote

chelmi wrote:

I did'nt see the eclipse; probably local for your place.
http://www.chez.com/lepithec/eclipse/ is a french site dedicated to eclipses. Nice photos.

Well it was visible almost allover the world... at least that's what for example bbc says.
_________________
Just ME here....
Back to top
View user's profile Send private message
chelmi



Joined: 11 Sep 2006
Posts: 64

PostPosted: Mar 04, 2007 06:33    Post subject: Re: Hit Table generation...... Reply with quote

thornc wrote:
chelmi wrote:

I did'nt see the eclipse; probably local for your place.
http://www.chez.com/lepithec/eclipse/ is a french site dedicated to eclipses. Nice photos.

Well it was visible almost allover the world... at least that's what for example bbc says.


It was visible from 23:20 to 2:10 last night in Paris

Back to your last code:
Instead of printing the combination number for each past draw line (which is repeating the same information numerous times, I suggest to print it on each line of the histogram. I tried to modify your code; without success. Which lines would you modify? (if you have time, now that the eclipse is gone!)
Regards
Back to top
View user's profile Send private message
marcher
Site Admin


Joined: 19 May 2006
Posts: 530

PostPosted: Mar 04, 2007 12:05    Post subject: Reply with quote

A few remarks on functionality in software.

Thornc’s software works with a configuration file. A config file has the advantage of expediting the process. The user doesn’t have to type the parameters at the screen prompt. This approach works well when the parameters do not change.

More often than not, the parameters change. I prefer the approach of typing at a logical series of prompts. The most obvious case here is the parpaluck, a parameter that can change from run to run. Also, total number of drawings used can change from run to run. Furthermore, different data files can be loaded from run to run. It is inconvenient to terminate the program, edit the configuration file, then run the program again…and so on.

Lately, my software tries to make it easy for the user. The programs offer default entries that can be edited as well. The parameters can be changed and run with the same data file; or, a different data file can be loaded.

Now, again, the very important parpaluck.

Thornc’s Python code is a worthy achievement. But, in its current format, it cannot be applied to my lotto system based on three frequency groups. The software is correct only for draw #1 in the data file and a parpaluck = 100. To get correct results for other drawings, the user must exit the program, then delete line #1 in the data file. Run the program again still for 100 ‘look backs’. The new results are correct only for the new line #1, which represents the draw #2 in the actual lotto file. It becomes tedious for 100 draws…

The combination generator is correct for a parpaluck = 100. But the user still needs the skips of a particular strategy. The program can do still better by replacing the ‘parpaluck = 100’ with N (e.g. 49 for lotto 6/49; or 50 in Euromillions): ‘look_back=49’.

The report generator displays the number of possible combinations for every 1-2-3 frequency situation. That’s the method I prefer. It is repetitious, but the user does not have to memorize the number of possible combinations or to look up a frequency table. You can see immediately how many combinations to expect.

Even one more approach in functionality I came up with lately. There should be three output options: to screen, to file, and ‘count combinations only’. The latter option is similar to the ‘Check strategy hits’ in the SkipDecades.EXE programs. The ‘count only’ function is much faster and doesn’t gobble up a disk. MDIEditor and Lotto WE would have greatly benefited from such an option.

Parpaluck,
Functionally At-Large
Lottery Strategy, Systems Based On Number Frequency

I updated the page to give Cristiano Lopes (a.k.a. thornc, a.k.a. Critser) the credit he deserves. I know for sure that many programmers have devoured Cristi’s source code! Yet, no other programmers are contributing. That’s the sad reality of open-source software: Take-it-all but give-nothing! I won’t be surprised to see or hear about software that generates lotto combinations based on frequency groups. It’s gonna happen sooner rather than later — and it’ll cost an arm and a leg.

.


Last edited by marcher on Mar 04, 2007 12:57; edited 1 time in total
Back to top
View user's profile Send private message
thornc



Joined: 22 Aug 2006
Posts: 72
Location: Here...

PostPosted: Mar 04, 2007 12:46    Post subject: Reply with quote

Code:

#!/usr/bin/env python
#
# Hit table generation...
# Needs a correctly formatted config file to work.
#
# example: config.ini
# [config]
# input_file=c649.txt
# top_recent=False
# output_file=out_%(look_back)s_%(look_at)s.txt
# nums=6
# max_nums=49
# look_back=200
# look_at=50
#
#
# Copyright (c) 2007 C.Lopes aka thornc. (except on given functions)
#
# Released under the MIT License.
# http://www.opensource.org/licenses/mit-license.php
#


import sys,os

_N = '\n'
_SEP = '-'*60+_N


class ConfDict(dict):
    def __init__(self,**kw):
        dict.__init__(self,kw)
    def __getattr__(self,name):
        return self[name]
    def __setattr__(self, name, value):
        self.__setitem__(name,value)
    def __str__(self):
        state = ["%s=%r" % (attribute, value) for (attribute, value) in self.items()]
        return '\n'.join(state)
   
def fact(n):
   if n<=0: return 1
   out = long(1)
   for x in xrange(1,n+1):
      out *= x
   return out
   
def comb(n,k):
   return ( fact(n) )/( (fact(k))*(fact(n-k) ) )

# Taken from Python cookbook   
def xuniqueCombinations(items, n):
    if n==0: yield []
    else:
        for i in xrange(len(items)-n+1):
            for cc in xuniqueCombinations(items[i+1:],n-1):
                yield [items[i]]+cc

# Taken from Python cookbook
def histogram(seq,h_d={}):
    for x in seq:
        h_d[x]=h_d.setdefault(x,0)+1
    return h_d

def histlist(pastHist, newNums):
    h = histogram(newNums,pastHist)
    l = zip( h.values(), h.keys() )
    l.sort()
    l.reverse()
    return h,l

def hits(comb,line):
    return tuple(set(comb) & set(line))

def hitCount(comb,line):
    return len(hits(comb,line))

def sortList(aList):
   aList.sort()
   return aList
   
def usage():
   a=\
"""
%s <Config file name>
--
"""%(os.path.basename(sys.argv[0]),)
   sys.stderr.write(a)
   
def readConfigFile(confFile):
    import ConfigParser
   
    conf = ConfDict()
    try:
        cp = ConfigParser.ConfigParser()
        cp.read(confFile)
        conf.input_file=cp.get("config","input_file")
        conf.output_file=cp.get("config","output_file")
        conf.nums=cp.getint("config","nums")
        conf.max_nums=cp.getint("config","max_nums")
        conf.look_back=cp.getint("config","look_back")
        conf.look_at=cp.getint("config","look_at")
        conf.top_recent=cp.getboolean("config","top_recent" )
    except Exception,e:
        sys.stderr.write("Problems reading config file\n")
        sys.stderr.write(e.message)
        sys.exit(3)
   
    return conf

def checkConfig(config):
    if not os.path.exists(config.input_file):
        sys.stderr.write("Input file ('%s') doesn't exist!\n"%(config.input_file,))
        sys.exit(4)
    if config.nums>config.max_nums:
        sys.stderr.write("Nums (%d) can not be bigger than Max_Nums (%d)!\n"%(config.nums,config.max_nums))
        sys.exit(4)
       
def getGroupBounds(cfg):
    from math import ceil
    bounds=[cfg.nums]
    bounds.append( cfg.max_nums - int( ceil (cfg.max_nums * 0.50) ) )
    return bounds
   
def readInputData(cfg):
    inFile = open(cfg.input_file,'ra')
    data = inFile.readlines()
    inFile.close()
   
    allLines = [ map(int,y) for y in [ x.split() for x in data ] ]
    if cfg.top_recent:
        allLines.reverse()
   
    return allLines

def getNumsLines(lines,i,j):
    nums=[]
    for line in lines[i:j]:
        nums += [x for x in line]
    return nums

def getEmpyHist(cfg):
    return dict( zip( range(1,cfg.max_nums+1),[0]*(cfg.max_nums+1) ) )

def main():
    if len(sys.argv) != 2:
        usage()
        sys.exit(1) 
    confFile = sys.argv[1]
    if not os.path.exists(confFile):
        usage()
        sys.stderr.write("Config file supplied doesn't exist\n")
        sys.exit(2)
       
    cfg = readConfigFile(confFile)
    checkConfig(cfg)
   
   
    print "HitTable Generator"
    print "------------------"
    print "Config:"
    print cfg
    print "------------------"   
   
    bounds = getGroupBounds(cfg)
   
    outFile = open(cfg.output_file,"wa")
   
    allLines = readInputData(cfg)
   
    allNums = getNumsLines(allLines,-1*(cfg.look_back+cfg.look_at),-1*cfg.look_back)
     
    histHits = []
    histReport = []
    for i in xrange(-1*cfg.look_back,-1,1):
        line = allLines[i]
        line.sort()   
        allNums = getNumsLines(allLines,-1*cfg.look_at+i,i)
        h,l = histlist(getEmpyHist(cfg),allNums)
       
        g1 = [ y for (x, y) in l[ 0:bounds[0] ] ]
        g1.sort()
        g1l = len(g1)
        g1h = hitCount(g1, allLines[i+1])
        g2 = [ y for (x, y) in l[ bounds[0]:bounds[1] ] ]
        g2.sort()
        g2l = len(g2)
        g2h = hitCount(g2, allLines[i+1])
        g3 = [ y for (x, y) in l[ bounds[1]: ] ]
        g3.sort()
        g3l = len(g3)
        g3h = hitCount(g3, allLines[i+1])

        tmp=" ".join([str(d) for d in [g1h,g2h,g3h]] )
        histHits.append(tmp)
        tmp = " ".join([ "%-3d"%(abs(i),),"\t"," ".join([ "%02d"%(x,) for x in line]),"\t",tmp,"\t\t", "%12d"%(comb(g1l,g1h)*comb(g2l,g2h)*comb(g3l,g3h),)])+_N
        histReport.append(tmp)
       
    histReport.reverse()
    outFile.write("\n\n\tHit Table Report Generator\n")
    outFile.write(_SEP)     
    outFile.write("\tInput: %s \t Output: %s\n\tType: %d/%d \tLook Back: %d\tLook At: %d\n" %(cfg.input_file,cfg.output_file,cfg.nums,cfg.max_nums,cfg.look_back,cfg.look_at))   
    outFile.write(_SEP)   
    outFile.write("D.Back\tNumbers\t\t\t\t\tGrouping\tCombinations\n")
    outFile.write(_SEP)   
    outFile.writelines(histReport)
     
    hout,lout = histlist({},histHits)   

    outFile.write(_N)
    outFile.write(_N)
    outFile.write(_N)
    outFile.write("\tHits per Group Histogram\n")
    outFile.write("-"*30+_N)
    outFile.write("\tHits\tGrouping\n")
    outFile.write("-"*30+_N)
    outFile.write('\n'.join(["\t%02d  \t%s" % (count, num) for (count, num) in lout])+_N)
   
    allNums = getNumsLines(allLines,-1*cfg.look_at+i,i)
    h,l = histlist(getEmpyHist(cfg),allNums)
   
    g1 = [ y for (x, y) in l[ 0:bounds[0] ] ]
    g1.sort()
    g1l = len(g1)
    g2 = [ y for (x, y) in l[ bounds[0]:bounds[1] ] ]
    g2.sort()
    g2l = len(g2)
    g3 = [ y for (x, y) in l[ bounds[1]: ] ]
    g3.sort()

    outFile.write(_N)
    outFile.write(_N)
    outFile.write(_N)
    outFile.write("\tGroups:\n")
    outFile.write("-"*30+_N)
    outFile.write(' '.join([ str(x) for x in g1])+_N)
    outFile.write(' '.join([ str(x) for x in g2])+_N)
    outFile.write(' '.join([ str(x) for x in g3])+_N)
   
    outFile.close()
    print "Output ('%s') generated!"%(cfg.output_file,)

if __name__=="__main__":
    main()
         


This should solve one of the problems... the look_at parameter is the number of draws the program will use to calculate the histogram/frequency table on.
_________________
Just ME here....
Back to top
View user's profile Send private message
Advertisement






PostPosted: Feb 09, 2010 11:01    Post subject:

Back to top
Display posts from previous:   
Post new topic   Reply to topic    Lottery Lotto Gambling Software Systems Forum Index -> Software Systems Theory All times are GMT - 5 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Google




Powered by phpBB © 2001, 2005 phpBB Group

Forum hosted by phpBB now!
RSS 0.92 RSS feed | Forum directory | Set up a free forum! | Get a free Blog!
Support forum