def CompLikelihood(X,fx,MCPar,Measurement,Extra):
Sigma=Measurement.Sigma*np.ones((X.shape[0]))
of=np.zeros((fx.shape[0],1))
p=np.zeros((fx.shape[0],1))
log_p=np.zeros((fx.shape[0],1))
for ii in xrange(0,fx.shape[0]):
e=Measurement.MeasData-fx[ii,:]
of[ii,0]=np.sqrt(np.sum(np.power(e,2.0))/e.shape[1])
if MCPar.lik==2: # Compute standard uncorrelated and homoscedastic Gaussian log-likelihood
log_p[ii,0]= - ( Measurement.N / 2.0) * np.log(2.0 * np.pi) - Measurement.N * np.log( Sigma[ii] ) - 0.5 * np.power(Sigma[ii],-2.0) * np.sum( np.power(e,2.0) )
p[ii,0]=(1.0/np.sqrt(2*np.pi* Sigma[ii]**2))**Measurement.N * np.exp(- 0.5 * np.power(Sigma[ii],-2.0) * np.sum( np.power(e,2.0) ))
if MCPar.lik==3: # Box and Tiao (1973) log-likelihood formulation with Sigma integrated out based on prior of the form p(sigma) ~ 1/sigma
log_p[ii,0]= - ( Measurement.N / 2.0) * np.log(np.sum(np.power(e,2.0)))
p[ii,0]=np.exp(log_p[ii,0])
return of, p, log_p
评论列表
文章目录