x = allx[:, 0::20, :] # picking every 20th term to get a total of 51 time points t = allt[:, 0::20] # 51 time points, coarse data data_param = prm.data(theta=0.5 * np.random.rand(prm.dof, prm.dim), gvec=sim_param.gvec) print("Data shape:", x.shape) print("Theta shape:", data_param.theta.shape) print("Theta:", data_param.theta) # parvalue number of sub intervals # Note : numsubinterval = 1 => only observed data points, no intermediate brownian bridges em_param = prm.em(tol=0.01, burninpaths=10, mcmcpaths=100, numsubintervals=parvalue, 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),
x = allx[:, 0::20, :] # picking every 20th term to get a total of 51 time points t = allt[:, 0::20] # 51 time points, coarse data data_param = prm.data(theta=0.5 * np.random.rand(prm.dof, prm.dim), gvec=sim_param.gvec) print("Data shape:", x.shape) print("Theta shape:", data_param.theta.shape) print("Theta:", data_param.theta) # parvalue number of sub intervals # Note : numsubinterval = 1 => only observed data points, no intermediate brownian bridges em_param = prm.em(tol=0.01 * prm.dim * prm.dof, 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),
# load data import pickle with open('nem_6D.pkl', 'rb') as f: allx, allt, x_without_noise, euler_param, sim_param = pickle.load(f) data_param = prm.data(theta=0.5 * np.random.rand(prm.dof, prm.dim), gvec=sim_param.gvec) print("Data shape:", allx.shape) print("Theta shape:", data_param.theta.shape) print("Theta:", data_param.theta) """ Default parameters for Expectation-Maximization em_param = param.em(tol = 1e-3, burninpaths = 100, mcmcpaths = 1000, numsubintervals = 10, niter = 100, dt = (allt[0, 1] - allt[0, 0])) """ em_param = prm.em(dt=allt[0, 1] - allt[0, 0]) # call to EM which returns the final error and estimated theta value error_list, theta_list = nb.em(allx, allt, em_param, data_param) # convert the hermite polynomial to simplified polynomial expression # final_parameters = nb.hermite_to_polynomial(theta_list[-1]) print("Error: ", error_list) print("Theta: ", theta_list) # print("Final parameters: ", final_parameters) # save to file with open('6D.pkl', 'wb') as f: pickle.dump( [error_list, theta_list, final_parameters, em_param, data_param], f)