def data_given_local(local, x_real, y_data, y_err):
	n_group = len(local)/2
	local_c1 = local[:n_group]
	local_c0 = local[n_group:]

	total_loglikelihood = 0.
	for i_group in range(n_group):
		y_model = model(x_real[:,i_group],(local_c0[i_group], local_c1[i_group]))
		loglikelihood = 0. - np.sum( (y_model - y_data[:,i_group])**2. / (2.*y_err[:,i_group]**2.) )
		total_loglikelihood = total_loglikelihood + loglikelihood
	
	return total_loglikelihood
Exemplo n.º 2
0
print 'end:', time.asctime()

### plot
row = 2
col = 4

f,((a00,a01,a02,a03),(a10,a11,a12,a13))=plt.subplots(row,col,figsize=(col*5,row*5))
ax = ((a00,a01,a02,a03),(a10,a11,a12,a13))

#for j in range(col):
	#ax[0][j].plot(np.repeat(hyper_seq[j,:],repeat),'b-')

for i_group in range(n_group):
	#ax[0][0].errorbar(x_real[:,i_group],y_data[:,i_group],yerr = y_err[:,i_group],fmt='.')
	ax[0][0].plot(x_real[:,i_group], y_data[:,i_group],'.')
	ax[0][0].plot(x_real[:,i_group],model(x_real[:,i_group],(local_c0[i_group], local_c1[i_group])),'b-')


ax[0][1].plot(repeat_seq[:i_step],'b-')
ax[0][1].set_xlabel('repeat times')

delta_log = loglike_seq[1:] - loglike_seq[:-1]
ratio  = np.exp(delta_log)
ratio[np.where(ratio>1)[0]] = 1
ax[0][2].plot(ratio[:i_step-1], 'b-')
ax[0][2].set_xlabel('ratio')

ax[0][3].plot(loglike_seq[:i_step],'b-')
ax[0][3].set_xlabel('loglike')