def mvn_loglike(x, sigma):
 sigmainv = linalg.inv(sigma)
 logdetsigma = np.log(np.linalg.det(sigma))
 nobs = len(x)
 llf = (- np.dot(x, np.dot(sigmainv, x)))
 llf -= (nobs * np.log((2 * np.pi)))
 llf -= logdetsigma
 llf *= 0.5
 return llf

def mvn_loglike ( x , sigma ) : sigmainv = linalg . inv ( sigma ) logdetsigma = np . log ( np . linalg . det ( sigma ) ) nobs = len ( x ) llf = ( - np . dot ( x , np . dot ( sigmainv , x ) ) ) llf -= ( nobs * np . log ( ( 2 * np . pi ) ) ) llf -= logdetsigma llf *= 0.5 return llf
loglike multivariate normal assumes x is 1d .