I'm trying to fit an MvNormal
distribution to a matrix of spectral data, but I am getting the following error:
Distributions.fit(MvNormal, myMatrix)
> ERROR: PosDefException: matrix is not positive definite; Cholesky factorization failed.
myMatrix
consists of readings of absorbance (one column per item) at many consecutive wavenumbers (rows). It is not a square matrix and hence it cannot be positive definite.
From what I have seen online, lots of people report error messages of various methods failing at the Cholesky factorisation step in Julia. I understand that this comes from it being more strict than other languages at checking that the PD criterion is met when needed.
Other people (see this post, for example) have managed to solve this issue by making slight changes to the sigma parameter when stating a distribution. However, since I am not creating a distribution in terms of its parameters, but fitting it to a matrix, I am uncertain on what to do.
I would deeply appreciate any suggestions on
- how I could try and make my matrix appropriate for Cholesky factorisation, or
- fit a multivariate normal distribution to my data using any other method or package.