资源简介
该文件利用EM算法实现了对高斯混合模型的最大似然参数估计,有文档说明。
代码片段和文件信息
function [weight meanvec stdvec] = EmEstimate(x iternum)
% x is the input observation D-dim vectors * N
% iternum is the given number for EM iterations
% clear all
% dimension of each data point
% load gmm3data.mat
% x = aaData;
D = size(x1);
% number of data points
N = size(x2);
% fix cluster number
K = 3;
% calculate the global mean and std of the data
mean_global = mean(x 2)‘; %1*2
std_global = std(x 1 2)‘; %1*2
% initialize from mean_global std_global
weight = [1/3 1/3 1/3];
meanvec = zeros(K D);
meanvec(1 :) = mean_global - std_global;
meanvec(2 :) = mean_global;
meanvec(3 :) = mean_global + std_global;
stdvec = repmat(std_global K 1);
for step = 1:iternum %i
%% E-step
for k = 1:K
DATA = x‘-repmat(meanvec(k:)N1);
pdf = DATA.^2./(repmat(stdvec(k:)N1)).^2;
pdf = exp(-0.5*sum(pdf2))/(2*pi*stdvec(k1)*stdvec(k2));
gama_pdf(:k) = weight(k)*pdf; %N*3
end
P = (gama_pdf./repmat(sum(gama_pdf2)1K))‘; %3*N
%% M-step
for i = 1:D
for k = 1:K
meanvec(ki) = sum(P(k:).*x(i:))/sum(P(k:));
stdvec(ki) = sqrt(sum(P(k:).*(x(i:)-meanvec(ki)).^2)/sum(P(k:)));
weight(k) = sum(P(k:))/ N;
end
end
end
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 412 2011-11-03 15:42 em\em.mat
文件 1317 2011-11-03 15:44 em\EmEstimate.m
文件 84480 2011-11-28 22:58 em\em.doc
目录 0 2011-11-28 22:57 em
----------- --------- ---------- ----- ----
86209 4
- 上一篇:应用系统集成测试规范
- 下一篇:数字信号处理大作业——编写FFT程序
评论
共有 条评论