Beispiel #1
0
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 19 10:26:13 2019

@author: Jerry
"""

from GRN import DynamicModel, Recoder, MonteCarloSimulator

N = 2000
alpha = 0.003
avgDegree = 3
temperature = 0.00
totalSteps = 50
binDist = 20
numSim = 20
dm = DynamicModel(temperature, N, avgDegree, alpha)
re = Recoder(dm, totalSteps, binDist, False)
simulator = MonteCarloSimulator(dm, totalSteps, numSim)
matShape = (simulator.numSim, re.dynModel.P)

simulator.simulation()

compute_observable_matrix = Recoder.observable_matrix(
    re, simulator, matShape, True)(Recoder.hamming_overlap)
print("computing observable matrix...")
compute_observable_matrix()
print("Done. Now drawing...")
re.draw_distance_matrix()
Beispiel #2
0
        dm._init_memMat()
        print("now is in " + reg_p + " and " + reg_c + " regime...")

        matShape = (totalSteps, dm.P)
        compute_EA_overlap_matrix = Recoder.observable_matrix(
            re, simulator, matShape,
            needPatternInfo=True)(Recoder.mattis_overlap_)
        #        re.binDistTimes = 100
        #        re.distribution_interaction()
        #        figName = 'distribution_interaction_'+reg_p+'_'+reg_c+'.png'
        #        re.ax.figure.savefig(figFile+figName)

        re.binDistTimes = 100
        simulator.simRes = []
        for k in range(totalSteps):
            simulator.simulation(runByStep=True)
            simulator.simRes.append(simulator.dynModel.sysArr)

        compute_EA_overlap_matrix()
        re.fx = re.disMat[-1:, :].flatten()
        varLastSteps = np.var(re.disMat[-10, 0].flatten())
        mean = np.mean(re.fx)
        var = np.var(re.fx)
        textstr = '\n'.join(
            (r'$\mu=%.9f$' % (mean, ), r'$\sigma=%.9f$' % (var, ),
             r'variance over last ten steps=%.9f' % (varLastSteps, )))
        re.bar()
        re.ax.text(0.05,
                   0.95,
                   textstr,
                   transform=re.ax.transAxes,