def prop_func_form_params(param1,param2,*arg): """ Returns w(theta_i|theta_i+1), which is here a gaussian distribution with a given covariance and mean. Keyword Arguments: *args are: x_mean -- the mean vector (np.array) Cov -- covariance Matrix (np.matrix) """ return np.log(MH.simple_2D_Gauss(param1-param2,arg[0],arg[1]))
def plot_autocorr(guesses,flag,titles,which_par,burnin_cut,save=0): """ Plots the chains for all parameters, and the priors Keyword Arguments: guesses -- the full list of generated guesses from the MCMC flag -- a list giving 0 for rejected, 1 for accepted, 2 for accepted even if likelihood is lower, and -1 for forbidden values (most probably negative ones) titles -- a list of titles for the plots which_par -- a list of indices, corresponding to the order defined above, exemple [0,2] means ombh2,tau if order is [ombh2,omch2,tau,As,ns,H0] burnin_cut -- cut the first few iterations for computation of the autocorr """ j=0 for i in which_par: print j plt.figure() plt.plot(MH.autocorr(guesses[flag>0,j][burnin_cut:])) plt.title("%s autocorrelation"%titles[i]) plt.ylabel(titles[i]) plt.xlabel("Lag") if save!=0: plt.savefig("plots/Autocorrelation_%s_%s_%d.png"%(save,str(which_par).replace(',','').replace('[','').replace(']','').replace(' ',''),j))#,SafeID)) j+=1
def prop_func(*args): return MH.simple_2D_Gauss(*args)