mc_func.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:CRN_ProbabilisticInversion 作者: elaloy 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号