コード例 #1
0
estimated_theta = prm.theta_transformations(theta=theta_list[-1],
                                            theta_type='hermite')
true_theta = prm.theta_transformations(theta=dc.true_theta(sim_param),
                                       theta_type='ordinary')

print("\n Estimated ordinary: ", np.transpose(estimated_theta.ordinary),
      "\n True ordinary: ", np.transpose(true_theta.ordinary))

print("\n Estimated hermite: ", np.transpose(estimated_theta.hermite),
      "\n True hermite: ", np.transpose(true_theta.hermite))

threshold = np.array([0., 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5])
ordinary_errors = []
hermite_errors = []
for th in threshold:
    ordinary_errors.append(
        pfn.compute_errors(true_theta.ordinary, estimated_theta.ordinary, th))
    hermite_errors.append(
        pfn.compute_errors(true_theta.hermite, estimated_theta.hermite, th))

print("\n")

# save to file
with open('2d.pkl', 'wb') as f:
    pickle.dump([
        x, t, error_list, theta_list, gammavec_list, estimated_theta,
        true_theta, threshold, ordinary_errors, hermite_errors, em_param,
        data_param, euler_param, sim_param
    ], f)
コード例 #2
0
print("Data shape:", x.shape)
print("Theta shape:", data_param.theta.shape)
print("Theta:", data_param.theta)

em_param = prm.em(tol=0.01, burninpaths=10, mcmcpaths=100, numsubintervals=5, niter=100, dt=(allt[0, 1] - allt[0, 0]))

# call to EM which returns the final error and estimated theta value
error_list, theta_list, gammavec_list = em(x, t, em_param, data_param)

estimated_theta = prm.theta_transformations(theta=theta_list[-1], theta_type='hermite')
true_theta = prm.theta_transformations(theta=dc.true_theta(sim_param), theta_type='ordinary')

print("\n Estimated ordinary: ", np.transpose(estimated_theta.ordinary), "\n True ordinary: ", np.transpose(true_theta.ordinary))

print("\n Estimated hermite: ", np.transpose(estimated_theta.hermite), "\n True hermite: ", np.transpose(true_theta.hermite))

threshold = np.array([0., 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5])
ordinary_errors = []
hermite_errors = []
for th in threshold:
    ordinary_errors.append(pfn.compute_errors(true_theta.ordinary, estimated_theta.ordinary, th))
    hermite_errors.append(pfn.compute_errors(true_theta.hermite, estimated_theta.hermite, th))

print("\n")

# save to file
with open('./varying_num_timeseries/ts_' + str(parvalue) + '.pkl','wb') as f:
    pickle.dump([x, t, error_list, theta_list, gammavec_list, estimated_theta, true_theta, threshold, ordinary_errors, hermite_errors, em_param, data_param, euler_param, sim_param], f)