I am calculating the log-likelihood of multivariate Gaussian distribution. I am getting a positive log-likelihood.
Density function
$$f(x_1,...,x_n)=\frac{1}{\sqrt{(2\pi)^n|\Sigma|}}\text{exp}{\{-\frac{1}{2}(x-\mu)^\text{T} \Sigma^{-1}(x-\mu)\}}$$ where $|\Sigma|$ is positive definite.
Log-likelihood $$\text{log}(L)= - \frac{1}{2}\text{log}(|\Sigma|) - \frac{1}{2} (x-\mu)^{-\text{T}} \Sigma ^{-1} (x-\mu) - \frac{n}{2}\text{log}(2\pi)$$
Suppose
x = [0.0000000 0.9411407 0.9971905 0.9987736 0.9988251]
Mean: $\mu=\vec{0}$
Covariance matrix: $\Sigma$,
K=
[,1] [,2] [,3] [,4] [,5]
[1,] 0.842916377 0.61430825 0.2378030 0.04889546 0.005339994
[2,] 0.614308254 0.84291638 0.6143083 0.23780289 0.048895481
[3,] 0.237802952 0.61430825 0.8429164 0.61430817 0.237802952
[4,] 0.048895461 0.23780289 0.6143082 0.84291638 0.614308339
[5,] 0.005339994 0.04889548 0.2378030 0.61430834 0.842916377
covariance matrix is positive definite. We can do Cholesky decomposition: chol(K)
Ignoring the last term in log-likelihood with $2\pi$, it's a normalizing constant.
Calculating log-likelihood,
First term: $- \frac{1}{2}(|\Sigma|)$=2.642797.
Second term: $(x-\mu)^{-\text{T}} \Sigma ^{-1} (x-\mu)$=-1.857256.
First + Second=0.7855412
Why is it positive 0.7855412? Log-likelihood should be a negative number. What is wrong? Thanks!