function [LogL,MoFA,Q] = mfa(X,d,C,iso,eq,dia);
%
% [LogL,mfa,Q] = mfa(X,d,C,iso,dia);
%
% X : data matrix (N data points in D dimensions as columns)
% d : latent dimensionality
% C : number of mixtuer components
% iso : use isotropic noise if 1
% eq : use equal noise model for all components
% dia : verbosity. 0=no output, 1=log-likelihood monitoring, 2=posterior plotting
%
% LogL : row vector of log-likelihoods after each EM iteration
% MoFA : structure containing the Mixture of Factor Analyzers
% MoFA.W (D x d x C) : factor loading matrices
% MoFA.M (D x C) : component means
% MoFA.Psi ( D x C ) : component noise variances
% MoFA.mix ( C x 1 ) : mixing weights
% Q : C x N matrix of component posterior probabilities
%
% by Jakob Verbeek, Intelligent Systems Laboratory Amsterdam, University of Amsterdam, 2005.
% http://www.science.uva.nl/~jverbeek
epsilon = 1e-3; % relative log-likelihood increase threshold for convergence
max_iters = 1000; % maximum number of EM iterations
min_iters = 10; % minimum number of EM iterations
[D,N] = size(X);
if dia
fprintf('--> running EM for MoFA\n');
fprintf(' mixture components: %d\n',C);
fprintf(' latent dimensions : %d\n',d);
fprintf(' data: %d points in %d dimensions\n',N,D);
if iso; fprintf(' using isotropic noise model\n');end
if eq; fprintf(' equal noise model in components\n');end
end
% -------- Initialisation
MoFA.mix = ones (C,1)/C; % mixing weights
MoFA.M = randperm(N); MoFA.M = X(:,MoFA.M(1:C)); % means
MoFA.Psi = 100*var(X(:))*ones(D,C); % noise variance
MoFA.W = randn(D,d,C); % factor loadings
X2 = X.^2;
for iter=1:max_iters; % EM loops
[Q, LL,Lats, lat_covs] = mfa_E_step(X,MoFA,X2); % E-step
LogL(iter) = sum(LL);
MoFA = mfa_M_step(X,X2,Q,Lats,lat_covs,iso,eq); % M-step
if iter > 1;
rel_change = (LogL(end)-LogL(end-1)) / abs(mean(LogL(end-1:end)));
if rel_change < 0; fprintf('--> Log likelihood decreased in iteration %d, relative change %f\n',iter,rel_change);end
if dia; fprintf('iteration %3d Logl %.2f relative increment %.6f\n',iter, LogL(end),rel_change);end
if dia>1; clf;set(gcf,'Double','on');imagesc(Q);xlabel('data point index');ylabel('mixture component index');set(gca,'ytick',1:C);colormap gray;colorbar;title('Posterior distributions on mixture components given data point');drawnow;end
if (rel_change < epsilon) & (iter > min_iters); break;end
end
end
mfa.rar_MFA MATLAB_MFA-ILC_data analysis_mfa_mppca
版权申诉
91 浏览量
2022-09-22
20:18:53
上传
评论
收藏 3KB RAR 举报
寒泊
- 粉丝: 75
- 资源: 1万+
最新资源
- 基于matlab实现文档+程序边缘计算任务卸载与资源调度的算法,是论文的源代码,具有价值.rar
- 什么是学生成绩管理系统c++以及学习学生成绩管理系统的意义
- 什么是词向量-以及学习关于了解词向量的意义
- 什么是mybatis动态sql以及学习mybatis动态sql的意义
- 华为数据治理方法论,包括:数据治理框架、数据治理组织架构、数据治理度量评估体系以及华为数据治理案例分享
- 基于matlab实现对表面肌电信号进行归一化处理,并对归一化后的图形显示 .rar
- 基于matlab实现单级倒立摆的 T-S 模型 包括 LMI 程序源码
- 图书管理系统(struts+hibernate+spring+ext).rar
- 基于matlab实现此压缩包包含语音信号处理中的语音变声代码加音频.rar
- STM32使用PWM驱动舵机并通过OLED显示
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈