Error in using fitgmdist : xmust have more rows than x

6 views (last 30 days)
Hi, I'm try to use fitgmdist to cluster high dimensional data with size of 128*128. Using
gmfit = fitgmdist(data,3,' CovarianceType','full','RegularizationValue',0.1);
Then error occurs:
X must have more rows than columns.
How can I fix this?
Thanks.

Accepted Answer

Archita P
Archita P on 5 Jun 2017
The reason for this error is the explicit check that happens on the dimensions. "fitgmdist" uses the EM algorithm, which requires enough number of observations to fit Gaussian models with invertible covariance matrices. In order for the covariance matrix to be invertible, there must be more observations(rows) than variables(columns).
You can find more information about working with ill-conditioned matrices with "fitgmdist" in the Tips section at:
It is possible to get around the issue of matrices not being invertible by using regularization or a diagonal covariance matrix. To use this workaround with more columns than rows, you will also have to remove/comment-out the following sanity check on line 29 to 31 in the MATLAB\<Release>\toolbox\stats\stats\@gmdistribution\fit.m file:
if n <= d error(message('stats:gmdistribution:TooFewN')); end
Please note that modification to these files can possibly lead to unexpected behavior of MATLAB in the future.
  2 Comments
A. P. B.
A. P. B. on 7 Jun 2017
In the case of square matrix it is also possible to convert the matrix to a vector and perform the fitgmdist for Gaussian Mixture Modelling. It solved my error.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!