Beispiel #1
0
    inference.run_evaluation()

    # Do statistics for the current inference
    Ra_stat[i, 0], Ra_stat[i, 1], Ra_stat[i, 2], Ra_stat[
        i, 3], Ra_stat[4], Ra_stat[5] = stat(Ra)
    gpas_stat[i, 0], gpas_stat[i, 1], gpas_stat[i, 2], gpas_stat[
        i, 3], gpas_stat[4], gpas_stat[5] = stat(gpas)
    cm_stat[i, 0], cm_stat[i, 1], cm_stat[i, 2], cm_stat[
        i, 3], cm_stat[4], cm_stat[5] = stat(cm)

    # Plot some single joint distribution
    if i == num_of_iter - 1:
        print(inference)
        fullplot(inference)
        plot_joint(inference, Ra, gpas)
        plot_joint(inference, Ra, cm)
        plot_joint(inference, cm, gpas)

    print("\n\n")

runningTime = (time.time() - startTime) / 60
lasted = "The Ra-gpas-cm ball-and-stick simulation was running for %f minutes\n" % runningTime
configuration = "--\n"
setup1 = 'Multi compartment simulation; White noise sigma=7; ramp stimulus; Ra parameter; dt=0.1\n'
setup2 = 'Multi compartment simulation; White noise sigma=7; ramp stimulus; gpas parameter; dt=0.1\n'
setup3 = 'Multi compartment simulation; White noise sigma=7; ramp stimulus; cm parameter; dt=0.1\n'
header1 = "Number of simulations: " + str(
    num_of_iter) + '\n' + setup1 + configuration + lasted
header2 = "Number of simulations: " + str(
    num_of_iter) + '\n' + setup2 + configuration + lasted
Beispiel #2
0
            delimiter='\t')


if __name__ == "__main__":
    # load_statistics(50, ["Ra", "cm", "gpas"], "/Users/Dani/TDK/parameter_estim/stim_protocol2/ramp/loglikelihood",
    #                "/Users/Dani/TDK/parameter_estim/stim_protocol2/ramp")

    cm = np.loadtxt(
        "/Users/Dani/TDK/parameter_estim/stim_protocol2/zap/100/loglikelihood/cm(0).txt",
        dtype=str)
    gpas = np.loadtxt(
        "/Users/Dani/TDK/parameter_estim/stim_protocol2/zap/100/loglikelihood/gpas(0).txt",
        dtype=str)
    Ra = np.loadtxt(
        "/Users/Dani/TDK/parameter_estim/stim_protocol2/zap/100/loglikelihood/Ra(0).txt",
        dtype=str)
    ll = np.loadtxt(
        "/Users/Dani/TDK/parameter_estim/stim_protocol2/zap/100/loglikelihood/loglikelihood(0).txt"
    )

    inf = load_inference(
        ll, "/Users/Dani/TDK/parameter_estim/stim_protocol2/zap/100", Ra, cm,
        gpas)
    inf.run_evaluation()
    print(inf)
    from module.plot import fullplot, plot_joint

    plot_joint(inf, inf.p.params[0], inf.p.params[1])
    plot_joint(inf, inf.p.params[0], inf.p.params[2])
    plot_joint(inf, inf.p.params[1], inf.p.params[2])
    fullplot(inf)
Beispiel #3
0
# 2.) Set up parameter set
cm_gpas = ParameterSet(cm, gpas)

# 3.) Sythetic data
t, v = stick_and_ball()
exp_v = white(noise, v)

# 4.) Set up inference
inf = IndependentInference(
    model=stick_and_ball,
    noise_std=noise,
    target_trace=exp_v,
    parameter_set=cm_gpas,
    working_path=
    "/home/terbed/PROJECTS/SPE/parameter-inference/module/examples/output",
    speed='max',
    save=False)

# 5.) Run inference
if __name__ == "__main__":
    inf.run_sim()

# 6.) Run evaluation
inf.run_evaluation()

print("KL divergence test: %f" % inf.KL)

# 7.) Plot solution
print(inf)
plot_joint(inf, cm, gpas)
fullplot(inf)
Beispiel #4
0
 def joint_plot(self):
     # Plot joints
     for item in self.p.margin_ax:
         plot.plot_joint(self, self.p.params[item[0]],
                         self.p.params[item[1]])
Beispiel #5
0
            # load list of matrices with stat
            for j, stat in enumerate(params_stat):
                stat_list[j][i - m, 0], stat_list[j][i - m, 1], stat_list[j][i - m, 2], stat_list[j][i - m, 3], \
                stat_list[j][i - m, 4], stat_list[j][i - m, 5] = stat

        # Plot last signle result at the end
        if i == n - 1:
            # Marginal plots
            print(inf)

            # Fullplot
            fullplot(inf)

            # Joint plots (BRUTEFORCE for 3 parameter solution!)
            plot_joint(inf, current_params[0], current_params[1])
            plot_joint(inf, current_params[0], current_params[2])
            plot_joint(inf, current_params[1], current_params[2])

    # Plot results
    for q, item in enumerate(stat_list):
        print("Result saved to: " + working_path + "/" + p_names[q] +
              "_stat.txt")
        np.savetxt(
            working_path + "/" + p_names[q] + "_stat.txt",
            item,
            header='\nsigma\tfit_err\trdiff\taccuracy\tsharper\tbroadness',
            delimiter='\t')

    # Save plots
    for idx, item in enumerate(stat_list):