I am implementing the Gaussian distribution model on some data, if the sigma(covariance matrix) is singular, then it's not invertible, and will result in the failure in calculating the probability. I think add an Identity matrix to the sigma will make the sigma invertible, but that will make the model not fits the data.
Is there a way to make the sigma matrix invertible and keep the model fitting data?
Have a set of data: (x1, x2)_1 , (x1, x2)_2 , ... , (x1, x2)_i . where x1 and x2 are continues real numbers and some (x1, x2) can appear serval times, And I assumpt that those data follow Guassian distribution, and then can calculate the mean vector as (mean(x1), mean(x2)), and then calculate the covariance matrix as usual. And in some case the covariance matrix may be singular, I think add some random small shifts to it can make it nonsingular, but I don't know how to do it correctly so that the model can still fit data well.