X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/16dcc.git/blobdiff_plain/7e1869395799899be33ae9c59d7ddf936d3d5907..8dfce25f59a57787b53e1ba55971a5c4f8d5993f:/evalPRNG/compareFonctionMixingTime.py diff --git a/evalPRNG/compareFonctionMixingTime.py b/evalPRNG/compareFonctionMixingTime.py index 2e6b0f5..6d6e602 100644 --- a/evalPRNG/compareFonctionMixingTime.py +++ b/evalPRNG/compareFonctionMixingTime.py @@ -27,7 +27,7 @@ def dec(ch,n): def MarkovMatrixUnPas(fbin,n,p2n,lp2nm1): - print p2n + #print p2n MM = np.zeros((p2n,p2n)) # diagonal for i in lp2nm1 : @@ -59,7 +59,7 @@ def MarkovMatrixUnPas(fbin,n,p2n,lp2nm1): def MarkovMatrixSaut(fbin,n,p2n,lp2nm1): - print p2n + #print p2n MM = np.zeros((p2n,p2n)) # diagonal for i in lp2nm1 : @@ -142,19 +142,19 @@ def traite_f(f,dev): M = np.zeros((p2n,p2n)) np.copyto(M,MM) - MMs = MarkovMatrixSaut(fbin,n,p2n,lp2nm1) - Ms = np.zeros((p2n,p2n)) - np.copyto(Ms,MMs) - - - error = 1 cpt = 2 - while error > dev : + while error > dev and cpt < 1000: M = np.dot(M,MM) error =max([sqrt(sum([(M[i,j] - float(1)/p2n)**2 for i in range(p2n)])) for j in range(p2n)]) #print cpt, error, M cpt +=1 + + + """ + MMs = MarkovMatrixSaut(fbin,n,p2n,lp2nm1) + Ms = np.zeros((p2n,p2n)) + np.copyto(Ms,MMs) error = 1 @@ -167,8 +167,8 @@ def traite_f(f,dev): #print cpt, error, M cpts +=1 - - + """ + cpts=1 return n, cpt-1, cpts-1 @@ -219,15 +219,17 @@ def main(): brut=[] cpt = 0 for f in lf: - dev = 1E-15 + #print "cpt",cpt + dev = 1E-14 n,cptM,cptS = traite_f(f,dev) brut +=[(f,cptM,cptS)] + cpt+=1 """ print f, n,cptM,cptS #print 8*n*n + 4*n*log(n+1)#,8*n*n + (n+2)*(log(n)+2) #print "Pour "+str(n)+" bits et pour eps="+str(dev)+", appels a rand moy pr 1 bit genere.", print cpt - cpt+=1 + brut.sort(cmp=compareMarche) f,cptM,cptS = brut[0] @@ -262,6 +264,7 @@ def options(): parser = OptionParser() parser.add_option("-i", "--input", dest="i", help="file of sequences") + (options, args) = parser.parse_args() if (options.i != None): rf = options.i