rng('default') % For reproducibility
mu1 = [1 2]; % Mean of the 1st component
sigma1 = [2 0; 0 .5]; % Covariance of the 1st component
mu2 = [-3 -5]; % Mean of the 2nd component
sigma2 = [1 0; 0 1]; % Covariance of the 2nd component
各成分から同じ個数の確率変量を生成し、2 組の確率変量を結合します。
r1 = mvnrnd(mu1,sigma1,1000);
r2 = mvnrnd(mu2,sigma2,1000);
X = [r1; r2];
結合したデータ セット X には、2 つの二変量ガウス分布の混合に従う確率変量が含まれています。
2 成分の GMM を X に当てはめます。
gm = fitgmdist(X,2)
gm =
Gaussian mixture distribution with 2 components in 2 dimensions
Component 1:
Mixing proportion: 0.500000
Mean: -2.9617 -4.9727
Component 2:
Mixing proportion: 0.500000
Mean: 0.9539 2.0261