mu1 = [2 2]; % Mean of the 1st component
sigma1 = [2 0; 0 1]; % Covariance of the 1st component
mu2 = [-2 -1]; % Mean of the 2nd component
sigma2 = [1 0; 0 1]; % Covariance of the 2nd component
各成分から同じ個数の確率変量を生成し、2 組の確率変量を結合します。
rng('default') % For reproducibility
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.500765
Mean: -1.9675 -0.9654
Component 2:
Mixing proportion: 0.499235
Mean: 1.9657 2.0342