### mcmc import time print 'start:', time.asctime() n_step = int(1e4) n_hyper = 3 hyper_prob0 = np.array([0.5, 0.5, 0.5]) local_prob0 = 0.5 * np.ones(3*n_group) hyper_stepsize = 1e-2 * np.ones(n_hyper) local_stepsize = 1e-2 * np.ones(3*n_group) hyper_prob_chain, hyper_chain, local_prob_chain, local_chain, \ loglikelihood_chain, repeat_china, stop_step = \ hbm_joint_cdf( hyper_prob0, hyper_stepsize, local_prob0, local_stepsize, n_step, \ inverse_hyper, inverse_local, \ data_given_local, model, data = [y1, y2], \ trial_upbound = 1e5, random_seed = seed ) print 'end:', time.asctime() ### plot row = 1 col = 3 f, (a0,a1,a2) = plt.subplots(row, col, figsize=(col*5, row*5)) ax = (a0,a1,a2) for j in range(3): ax[j].plot(hyper_chain[:stop_step, j], 'b-') ax[j].set_ylim([0.,10.])
n_hyper = 4 # hyper_c1, hyper_c0, hyper_sigc1, hyper_sigc0 hyper0 = np.array([ 2.*hyper_c1, 2.*hyper_c0, hyper_sigc1, hyper_sigc0]) local0 = 2.*np.hstack((local_c1,local_c0)) hyper_stepsize = np.array([1e-1, 1e-1, 1e-1, 1e-1]) local_stepsize = 1e-1 * np.ones(2*n_group) hyper_chain, local_chain, loglikelihood_chain, repeat_chain, stop_step = \ hbm_joint(hyper0, hyper_stepsize, local0, local_stepsize, n_step, \ hyper_prior, local_given_hyper, data_given_local, data=[x_real,y_data,y_err], \ hyper_domain=hyper_domain, local_domain = None, \ trial_upbound = 1e6, random_seed = seed) ''' hyper_prob0 = np.array([0.3, 0.3, 0.8, 0.8]) local_prob0 = 0.3 * np.ones(2*n_group) hyper_stepsize = 3e-3 * np.ones(n_hyper) local_stepsize = 3e-3 * np.ones(2*n_group) hyper_prob_chain, hyper_chain, local_prob_chain, local_chain, \ loglikelihood_chain, repeat_chain, stop_step = \ hbm_joint_cdf(hyper_prob0, hyper_stepsize, local_prob0, local_stepsize, n_step,\ inverse_hyper, inverse_local, \ data_given_local, model, data=[x_real, y_data, y_err], \ trial_upbound = 1e6, random_seed = seed) ''' print 'end:', time.asctime()