Beispiel #1
0
def get_bgibbs_stats(np_file = '../Result/Regular_Gibbs_ferrof_80000.npy', max_lag = 500, start = 20000):
    energies = np.load(np_file)
    E_samples = energies[0]
    total_acf = np.zeros(max_lag+1)
    for energy in energies:
	total_acf += map(lambda i: utils.compute_acf(energy[start:], i), xrange(max_lag+1))
    
    average_acf = total_acf/float(len(energies))
    
    return E_samples, average_acf
Beispiel #2
0
    def plot_acf(self, max_lag = 500, start = 0):
        plot_name = "acf"

        import matplotlib.pyplot as plt

        fig = plt.figure()
        ax = fig.add_subplot(1, 1, 1)
        ax.plot(map(lambda i: utils.compute_acf(self.E_samples[start:], i),
                    xrange(max_lag+1)))
        ax.set_ylim(0, 1)
        ax.set_xlim(0, max_lag)
        self.save_current_plot(plot_name)
Beispiel #3
0
    def acf_plot_multi_energies(self, energies, max_lag=500, res_num=0):
        total_acf = zeros(max_lag + 1)
        for energy in energies:
            total_acf += map(lambda i: utils.compute_acf(energy[1:], i), xrange(max_lag + 1))

        total_acf = total_acf / float(len(energies))

        plt.figure()
        plt.plot(total_acf)
        plt.ylim(ymax=1.0)
        plt.ylim(ymin=0.0)

        plt.grid(True)
        save_current_plot(self.rbm.name, "Acf_total", self.name + "_s" + str(self.n), res_num)
Beispiel #4
0
def get_sard_tests_stats(graph_name = 'ISG3D_UAI', policy_num = 1000, res_num = 0, max_lag = 500, hdf5_fn='adaptive_saw.h5'):
    node = "/%s/%s/p%d/r%d" % (graph_name, 'SARD_EGO', policy_num, res_num)

    
    h5file = t.openFile(hdf5_fn, mode = "a")
    group = h5file.getNode(node)

    E_samples = group.E_samples[:]
    rewards = group.rewards[:]
    
    nadaptations = group.nadaptations.read()
    nruns_per_param_update = group.nruns_per_param_update.read()

    acf = map(lambda i: utils.compute_acf(E_samples[nruns_per_param_update*nadaptations:], i), xrange(max_lag+1))

    h5file.close()
    
    return E_samples, acf, [rewards[nruns_per_param_update*n+1][0] for n in xrange(nadaptations)]
Beispiel #5
0
    def plots(self, max_lag=500, res_num=0, energies=None, save_plots=False):
        if energies is None:
            energies = self.energies
        plt.figure()
        plt.plot(energies)
        if save_plots:
            save_current_plot(self.rbm.name, "E_samples", self.name + "_" + str(self.n), res_num)

        plt.figure()
        plt.plot(map(lambda i: utils.compute_acf(energies[1:], i), xrange(max_lag + 1)))
        plt.ylim(ymax=1.0)
        plt.ylim(ymin=0.0)

        plt.grid(True)
        if save_plots:
            save_current_plot(self.rbm.name, "Acf", self.name + "_s" + str(self.n), res_num)

        if not save_plots:
            plt.show()
Beispiel #6
0
def get_gibbs_stats(np_file = '../Result/Regular_Gibbs_ferrof_80000.npy', max_lag = 500, start = 20000):
    E_samples = np.load(np_file)
    acf = map(lambda i: utils.compute_acf(E_samples[start:], i), xrange(max_lag+1))
    
    return E_samples, acf
Beispiel #7
0
def get_sw_stats(matfile_name='../Result/ferro_frus_sw80000_nonzero_h_temp1.mat', E_sample_key = 'energy_vec', max_lag = 500, start = 20000):
    import scipy.io as sio
    matfile = sio.loadmat(matfile_name)
    acf = map(lambda i: utils.compute_acf(matfile['energy_vec'][start:], i), xrange(max_lag+1))
    
    return matfile[E_sample_key], acf
Beispiel #8
0
    def compute_acf(self, max_lag = 500, subsample = 1):
	self.acf = map(lambda i: utils.compute_acf(self.energies[::subsample], i), xrange(max_lag+1))
Beispiel #9
0
    sard_unif_test = tests.SARD_Unif_Test(**testspec_sard_unif)
    sard_unif_test.run()

    plt.figure()
    plt.subplot(311)
    line1 = plt.plot(sard_unif_test.MH_ratios, 'b*')

    plt.subplot(312)
    line2 = plt.plot(sard_unif_test.E_samples, '-b')
    plt.grid(True)
    
    
    max_lag = 500
    plt.subplot(313)
    plt.plot(map(lambda i: utils.compute_acf(sard_unif_test.E_samples[1:], i), xrange(max_lag+1)))
    plt.grid(True)
    plt.ylim(ymax=1.0)
    plt.ylim(ymin=0.0)
    
    plt.show()
    
else:
    #=====================================================
    # Run SARDONICS with parameter adaptation
    #=====================================================
    
    # Total number of moves (including the moves during adaptation)
    nmoves = 10**5

    # Set total number of adaptation