Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numpy.linalg.linalg.LinAlgError: Singular matrix #6

Closed
ravi0912 opened this issue Jun 21, 2018 · 2 comments
Closed

numpy.linalg.linalg.LinAlgError: Singular matrix #6

ravi0912 opened this issue Jun 21, 2018 · 2 comments

Comments

@ravi0912
Copy link

ravi0912 commented Jun 21, 2018

Hi,
I'm using this library and restricting the mean update. I had initialized the gmm.mean, amp and covar.
My data is 1d and integer. I'm trying to fit gmm curve in this data.
This is the error I'm getting : LinAlgError: Singular matrix

gmm = pygmmis.GMM(K=3, D=1) # K components, D dimensions
gmm.amp = np.array([0.33,0.33,0.33])
gmm.mean = np.array([[7],[14],[30]])
gmm.covar = np.array([[[2]],[[3]],[[5]]])
logL, U = pygmmis.fit(gmm, t_data,init_method='none',frozen={"amp":[],"mean":[0,1,2],"covar":[]})

@pmelchior
Copy link
Owner

I just checked your code with random integer test data, and it works. Singular matrices can arise, depending on your data, if one or multiple components have their covariances go to zero. This is more of a concern for integer data, so I suggest that you add the parameter w=1 (or some other suitable number) to provide a lower bound on the diagonal elements of the covariance matrix.

@ravi0912
Copy link
Author

Thanks, it is really helpful.. Solved my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants