fitgmdist
Fit a Gaussian mixture model with k components to data. Each row of data is a data sample. Each column is a variable.
Optional parameters are:
For ’randSample’, ’plus’ and ’cluster’, the initial variance of each component is the variance of the entire data sample.
If a row of data is used to represent samples that are similar but not identical, then the second column of weight indicates the variance of those original samples. Specifically, in the EM algorithm, the contribution of row i towards the variance is set to at least weight(i,2), to prevent spurious components with zero variance.
See also: gmdistribution, kmeans
Source Code: fitgmdist
## Generate a two-cluster problem
C1 = randn (100, 2) + 2;
C2 = randn (100, 2) - 2;
data = [C1; C2];
## Perform clustering
GMModel = fitgmdist (data, 2);
## Plot the result
figure
[heights, bins] = hist3([C1; C2]);
[xx, yy] = meshgrid(bins{1}, bins{2});
bbins = [xx(:), yy(:)];
contour (reshape (GMModel.pdf (bbins), size (heights)));
|
Angle_Theta = [ 30 + 10 * randn(1, 10), 60 + 10 * randn(1, 10) ]';
nbOrientations = 2;
initial_orientations = [38.0; 18.0];
initial_weights = ones (1, nbOrientations) / nbOrientations;
initial_Sigma = 10 * ones (1, 1, nbOrientations);
start = struct ("mu", initial_orientations, "Sigma", initial_Sigma, ...
"ComponentProportion", initial_weights);
GMModel_Theta = fitgmdist (Angle_Theta, nbOrientations, "Start", start , ...
"RegularizationValue", 0.0001)
Gaussian mixture distribution with 2 components in 1 dimension(s)
Clust 1: weight 0.542486
Mean: 62.488
Variance:136.71
Clust 2: weight 0.457514
Mean: 24.8305
Variance:101.91
AIC=185.463 BIC=190.442 NLogL=87.7315 Iter=53 Cged=1 Reg=0.0001
|