def mvn_nloglike_obs(x, sigma):
 sigmainv = linalg.inv(sigma)
 cholsigmainv = linalg.cholesky(sigmainv)
 x_whitened = np.dot(cholsigmainv, x)
 logdetsigma = np.log(np.linalg.det(sigma))
 sigma2 = 1.0
 llike = (0.5 * (((np.log(sigma2) - (2.0 * np.log(np.diagonal(cholsigmainv)))) + ((x_whitened ** 2) / sigma2)) + np.log((2 * np.pi))))
 return (llike, (x_whitened ** 2))

def mvn_nloglike_obs ( x , sigma ) : sigmainv = linalg . inv ( sigma ) cholsigmainv = linalg . cholesky ( sigmainv ) x_whitened = np . dot ( cholsigmainv , x ) logdetsigma = np . log ( np . linalg . det ( sigma ) ) sigma2 = 1.0 llike = ( 0.5 * ( ( ( np . log ( sigma2 ) - ( 2.0 * np . log ( np . diagonal ( cholsigmainv ) ) ) ) + ( ( x_whitened ** 2 ) / sigma2 ) ) + np . log ( ( 2 * np . pi ) ) ) ) return ( llike , ( x_whitened ** 2 ) )
loglike multivariate normal assumes x is 1d .