jmschrei / pomegranate

Fast, flexible and easy to use probabilistic modelling in Python.
http://pomegranate.readthedocs.org/en/latest/
MIT License
3.38k stars 590 forks source link

[Question] "Variances must be positive" Error When Using `Normal().fit(data)` and Adding Beta Distribution Support #1112

Open Des11111 opened 3 months ago

Des11111 commented 3 months ago

Hi Jacob,

I encountered a ValueError while trying to fit a Normal(covariance_type='diag').fit() distribution to my data. The error message states, "Variances must be positive." Meanwhile when I was trying to use Normal(covariance_type='full').fit(), it raised error that "RuntimeError: linalg.cholesky: The input tensor A must have at least 2 dimensions."

My dataset has a shape of 2000x2, with each column approximately normally distributed. I just cannot figure out why the covariance could be negative. One dimension of my dataset is like: image

Another question is that I searched the package documentation but couldn't find a method to fit a Beta distribution. Is there a solution or workaround available for fitting a Beta distribution to my data?

Thank you in advance for any assistance you can provide.

Best, Ruoxiao

Des11111 commented 3 months ago

Alright, I believe I have found the solution to the first problem. It appears that some of my data samples are too small, which causes their distribution to deviate significantly from what is expected for a normal distribution.