MATLAB: Problem: Undefined function ‘fitgmdist’ for input arguments of type ‘double’

em algorithmfitgmdistmachine learning

Sorry, i have to work with this function 'fitgmdist'. In the description of this function the input variables are X and k. k is the number of clusters, X is a numeric matrix. In particular X, as in Matlab's description of 'fitgmdist'…
" X — Data numeric matrix Data to which the Gaussian mixture model is fit, specified as a numeric matrix.
The rows of X correspond to observations, and columns correspond to variables.
NaNs indicate missing values. The software removes rows of X containing at least one NaN before fitting, which decreases the effective sample size.
Data Types: double".
When i tried to use "fitgmdist(X,k)" Matlab gave me the the error "Undefined function 'fitgmdist' for input arguments of type 'double'". Then i try the example given: " Generate data from a mixture of two bivariate Gaussian distributions.
mu1 = [1 2];
Sigma1 = [2 0; 0 0.5];
mu2 = [-3 -5];
Sigma2 = [1 0;0 1];
rng(1); % For reproducibility
X = [mvnrnd(mu1,Sigma1,1000);mvnrnd(mu2,Sigma2,1000)];
GMModel = fitgmdist(X,2); "
But again the same error. Please, help me. What i have done wrong?

Best Answer

The fitgmdist function is in the Statistics Toolbox. You have to have the toolbox installed to use that function.
Type ver in the Command Window. If you have the Statistics Toolbox installed, it will be listed. I’m not sure how long ago fitgmdist was added to the Statistics Toolbox, so if you have the Toolbox and not the function, you might have to upgrade to a more recent version of the Statistics Toolbox.