Beispiel #1
0
#!/usr/bin/python

import sys
import numpy as np
import scipy.io
from rads.misc import utils
from rads.symbolics.sofic_processor import SoficProcessor


for f in "ap1r2.mat ap2r6.mat ap3r2.mat ap3r4.mat ap4r2.mat ap5r2.mat ap5r3.mat ap6r5.mat ap7r3.mat ap8r2.mat ap8r3.mat ap9r2.mat ap9r3.mat ap11r8.mat ap12r8.mat ap13r8.mat ap14r8.mat ap15r8.mat".split(" "):
    dat = utils.load_matlab_matrix( '/home/raf/Dropbox/projects/plateaus/focm-data/'+f, matname='d')
    print f
    # the [0,0][0,1] is to get the second entry of the cell, i.e. dat.M_inv{2}
    M = dat['M_inv'][0,0][0,1]
    G = utils.cell2dict(dat['G_inv'][0,0][0,1][0])
    sof = SoficProcessor(M,G)
    sof.process()
    print sof
    print 'entropy:', sof.entropy()

# ap1r2.mat
# SoficProcessor on 886 symbols, with 1096 states and 2065 transitions
# entropy: 0.637936814478
# ap2r6.mat
# SoficProcessor on 553 symbols, with 689 states and 1294 transitions
# entropy: 0.637347707344
# ap3r2.mat
# SoficProcessor on 834 symbols, with 999 states and 1870 transitions
# entropy: 0.639166621114
# ap3r4.mat
# SoficProcessor on 649 symbols, with 728 states and 1359 transitions
Beispiel #2
0
from rads.misc import utils
from rads.symbolics.sofic_processor import SoficProcessor

if len(sys.argv) < 3:
    print "usage: python test_sofic.py <data file> [<index_map> <generators>]"
    print "where <index_map> and <generators> default to M and G"
    genn = 'G'
    mapn = 'M'
else:
    genn = sys.argv[2]
    mapn = sys.argv[3]
filename = sys.argv[1]

gens = utils.convert_matlab_gens( filename, genname=genn )
index_map = utils.load_matlab_matrix( filename, matname=mapn ).astype(int)
sof = SoficProcessor( index_map, gens, debug=False )
sof.process()
print sof
print sof.entropy()


# for i in range(ca.shape[0]):
#     gens = utils.cell2dict(ca[i,0])
#     sof = SoficProcessor(ca[i,1],gens)
#     sof.process()
#     print sof
#     print sof.entropy()

# ca = utils.load_matlab_matrix( '/home/raf/Dropbox/henon-tipping-14-run-goodruns.mat', matname='e' )
# ents = []
# for i in range(ca.shape[0]):
Beispiel #3
0
import sys
import numpy as np
import scipy.io
from rads.misc import utils
from rads.symbolics.sofic_processor import SoficProcessor


datcell = utils.load_matlab_matrix('/home/raf/Dropbox/projects/plateaus/focm-data/results-9-2-2007/results_apboxprm_b2_d22.mat', matname='D')

ents = np.zeros(datcell.shape)

for i in range(datcell.shape[0]):
    for j in range(datcell.shape[1]):
        M = datcell[i,j][0,2]
        G = utils.cell2dict(datcell[i,j][0,1][0])
        sof = SoficProcessor(M,G)
        sof.process()
        print sof
        ents[i,j] = sof.entropy()
        print 'entropy:', ents[i,j]

np.savetxt('plateaus_ap_b2_22.txt',ents)

# SoficProcessor on 2 symbols, with 6 states and 10 transitions
# entropy: 0.528048909513
# SoficProcessor on 2 symbols, with 6 states and 10 transitions
# entropy: 0.528048909513
# SoficProcessor on 2 symbols, with 6 states and 10 transitions
# entropy: 0.528048909513
# SoficProcessor on 2 symbols, with 6 states and 10 transitions
# entropy: 0.528048909513
#!/usr/bin/python

import sys
import numpy as np
import scipy.io
from rads.misc import utils
from rads.symbolics.sofic_processor import SoficProcessor


everything = scipy.io.loadmat( '/home/raf/Dropbox/henon-tipping-14-run-goodruns.mat')
ind = everything['index_info']
ents_dft = everything['ents_dft']
ents_max = everything['ents_max']
ents_sof = []
for i in range(ind.shape[0]):
    sof = SoficProcessor(ind[i,1],utils.cell2dict(ind[i,0]))
    sof.process()
    ents_sof.append(sof.entropy())
    print sof, 'entropy:', ents_sof[-1]