def mvn_loglike_chol(x, sigma):
 sigmainv = np.linalg.inv(sigma)
 cholsigmainv = np.linalg.cholesky(sigmainv).T
 x_whitened = np.dot(cholsigmainv, x)
 logdetsigma = np.log(np.linalg.det(sigma))
 nobs = len(x)
 from scipy import stats
 print('scipy.stats')
 print(np.log(stats.norm.pdf(x_whitened)).sum())
 llf = (- np.dot(x_whitened.T, x_whitened))
 llf -= (nobs * np.log((2 * np.pi)))
 llf -= logdetsigma
 llf *= 0.5
 return (llf, logdetsigma, (2 * np.sum(np.log(np.diagonal(cholsigmainv)))))

def mvn_loglike_chol ( x , sigma ) : sigmainv = np . linalg . inv ( sigma ) cholsigmainv = np . linalg . cholesky ( sigmainv ) . T x_whitened = np . dot ( cholsigmainv , x ) logdetsigma = np . log ( np . linalg . det ( sigma ) ) nobs = len ( x ) from scipy import stats print ( 'scipy.stats' ) print ( np . log ( stats . norm . pdf ( x_whitened ) ) . sum ( ) ) llf = ( - np . dot ( x_whitened . T , x_whitened ) ) llf -= ( nobs * np . log ( ( 2 * np . pi ) ) ) llf -= logdetsigma llf *= 0.5 return ( llf , logdetsigma , ( 2 * np . sum ( np . log ( np . diagonal ( cholsigmainv ) ) ) ) )
loglike multivariate normal assumes x is 1d .