Main Content

从高斯混合物分布中构造簇

描述

例子

IDX=群集(通用,,,,Xpartitions the data inX进入kkGaussian mixture components in通用。价值IDX((一世)是观察的群集索引一世并指示该观察值最大的后验概率一世

[[IDX,,,,nlogl] =群集(通用,,,,X还返回高斯混合模型的负loglikelione通用给定数据X

[[IDX,,,,nlogl,,,,p] =群集(通用,,,,X还返回每个高斯混合物中每个高斯混合物的后验概率通用给出每个观察结果X

[[IDX,,,,nlogl,,,,p,,,,日志PDF] =群集(通用,,,,X还返回在每个观察结果中评估的估计概率密度函数(PDF)的对数X

[[IDX,,,,nlogl,,,,p,,,,日志PDF,,,,D2] =群集(通用,,,,X还返回每个观察值的平方mahalanobis距离X到每个高斯混合物中通用

例子

全部收缩

生成随机变体,遵循两个双变量高斯分布的混合物mvnrnd功能。通过使用该模型(GMM)将高斯混合模型(GMM)安装到生成的数据中fitgmdist功能。Then, use the功能将数据划分为由拟合的GMM组件确定的两个簇。

Define the distribution parameters (means and covariances) of two bivariate Gaussian mixture components.

mu1 = [2 2];第一个组件的平均值的%sigma1 = [2 0;0 1];第一个组件的协方差%mu2 = [-2 -1];% Mean of the 2nd componentsigma2 = [1 0; 0 1];第二部分的协方差

从每个组件中生成相等数量的随机变体,并结合两组随机变体。

rng('default'% For reproducibilityr1 = mvnrnd(mu1,sigma1,1000);r2 = mvnrnd(mu2,sigma2,1000);x = [r1;R2];

组合数据集X包含random variates following a mixture of two bivariate Gaussian distribution.

Fit a two-component GMM toX

通用=fitgmdist((X,,,,2);

阴谋X通过使用scatter。可视化拟合模型通用通过使用PDFandfcontour

图散射(x(:,1),x(:,2),10,'。'% Scatter plot with points of size 10抓住on通用pDF = @(x,y) arrayfun(@(x0,y0) pdf(gm,[x0 y0]),x,y); fcontour(gmPDF,[-6 8 -4 6])

Figure contains an axes object. The axes object contains 2 objects of type scatter, functioncontour.

partition the data into clusters by passing the fitted GMM and the data to

IDX=群集(通用,,,,X);

Usegscatter创建由IDX

数字;gScatter(x(::,1),x(:,2),idx);传奇('群集1',,,,“群集2”,,,,'Location',,,,'最好的');

Figure contains an axes object. The axes object contains 2 objects of type line. These objects represent Cluster 1, Cluster 2.

输入参数

全部收缩

高斯混合物分布,也称为高斯混合模型(GMM),指定为通用distribution目的。

您可以创建一个通用distribution对象使用通用distributionorfitgmdist。使用通用distribution创建一个功能通用distribution通过指定分布参数来对象。使用fitgmdist适合一个功能通用distribution模型到给定固定数量的组件的数据。

数据,指定为n-by-m数字矩阵,,,,在哪里n是the number of observations andm是the number of variables in each observation.

为了提供有意义的聚类结果,Xmust come from the same population as the data used to create通用

如果一排X包含, 然后从计算中排除该行。相应的值IDX,,,,p,,,,日志PDF,,,,andD2

数据类型:单身的|双倍的

输出参数

全部收缩

集群索引,返回n-b-1正整数矢量,,,,在哪里n是观察的数量X

IDX((一世)是观察的群集索引一世and indicates the Gaussian mixture component with the largest posterior probability given the observation一世

高斯混合物模型的负loglikelihoodgoomy值通用给定数据X,,,,returned as a numeric value.

posterior probability of each Gaussian mixture component in通用给出每个观察结果X,,,,returned as ann-by-k数字向量,其中n是观察的数量Xandk是the number of mixture components in通用

P(i,j)是后验概率jth高斯混合组件n观察一世,概率(组件j|观察一世)。

估计的PDF的对数,在每个观察结果中进行评估X,,,,returned as ann-b-1数字向量,其中n是观察的数量X

日志PDF((一世)是观察时估计的PDF的对数一世。The函数通过使用每个组件的可能性来计算估计的PDF,给定每个观察值和组件概率。

日志PDF (( 一世 = 日志 j = 1 k l (( C j | o 一世 p (( C j ,,,,

在哪里l((Cj|oj是the likelihood of componentj给定观察一世,,,,andp((Cj是组件的概率j。The函数通过使用的多变量正常PDF计算可能性项j观察时评估的高斯混合物成分一世。组件概率是混合成分的混合比例,ComponentProportion财产的通用

Squared Mahalanobis distance of each observation inX到每个高斯混合物中通用,,,,returned as ann-by-k数字矩阵,,,,在哪里n是观察的数量Xandk是the number of mixture components in通用

D2(i,j)是the squared distance of observation一世to thej高斯混合物组件。

版本历史记录

在R2007B中引入