Rank: 36580 based on 0 downloads (last 30 days) and 0 files submitted
photo

Yashodhan Athavale

E-mail

Personal Profile:
Professional Interests:
Financial Engineering & Forecasting

 

Watch this Author's files

 

Comments and Ratings by Yashodhan View all
Updated File Comments Rating
25 Jan 2010 EM_GM An expectation maximization algorithm for learning a multi-dimensional Gaussian mixture. Author: Patrick Tsui

I tried modifying the code a little bit, by including the following lines of code,

function [W,M,V] = Init_EM(X,k)
[n,d] = size(X);
[Ci,C] = kmeans(X,k,'Start','cluster', ...
    'Maxiter',100, ...
    'EmptyAction','drop', ...
    'Display','off'); % Ci(nx1) - cluster indeices; C(k,d) - cluster centroid (i.e. mean)
while sum(isnan(C))>0,
    [Ci,C] = kmeans(X,k,'Start','cluster', ...
        'Maxiter',100, ...
        'EmptyAction','drop', ...
        'Display','off');
end
M = C';

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Use this routine if the cluster matrix is of variable length and contains
% Scan the cluster index matrix Ci for NaN values, and remove them
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
temp1=Ci(:,1); % Scan the entire matrix column
temp2=isnan(temp1); % Find the rows with NaN values
index_active=find(temp2~=1); % Find the rows with actual values
Ci_new=temp1(index_active); %#ok<FNDSB>
[r,c]=size(Ci_new); % Determine the size of the newly scanned matrix.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Vp = repmat(struct('count',0,'X',zeros(r,c)),1,k);
for i=1:r % Separate cluster points
    Vp(Ci_new(i)).count = Vp(Ci_new(i)).count + 1;
    Vp(Ci_new(i)).X(Vp(Ci_new(i)).count,:) = X(i,:);
end

V = zeros(d,d,k);
for i=1:k,
    W (i) = Vp(i).count/r;
    % Find the covariance ignoring the NaNs
    V(:,:,i) = nancov(Vp(i).X(1:Vp(i).count,:));
end
%%%%%%%%%%%%%%%%%%%%%%%%
%%%% End of Init_EM %%%%
%%%%%%%%%%%%%%%%%%%%%%%%

I worked, giving me the estimates. But still I am getting some warnings with "Empty rows of data".

07 Jul 2009 EM_GM An expectation maximization algorithm for learning a multi-dimensional Gaussian mixture. Author: Patrick Tsui

I have a multidimensional file in Microsoft Excel. I imported the sheet into X, and executed [W,M,V,L] = EM_GM(X,3,[],[],1,[]);

I am getting the following errors,

[W,M,V,L] = EM_GM(X,1,[],[],1,[])
Warning: Ignoring rows of X with missing data.
> In kmeans at 127
  In EM_GM>Init_EM at 261
  In EM_GM at 74
??? Attempted to access C(1,2); index out of bounds because numel(C)=1.

Error in ==> kmeans>distfun at 722
            D(:,i) = D(:,i) + (X(:,j) - C(i,j)).^2;

Error in ==> kmeans at 329
    D = distfun(X, C, distance, 0);

Error in ==> EM_GM>Init_EM at 261
[Ci,C] = kmeans(X,k,'Start','cluster', ...

Error in ==> EM_GM at 74
    [W,M,V] = Init_EM(X,k); L = 0;

Please Help....!!! thanks in advance..... :)

Top Tags Applied by Yashodhan
finance
Files Tagged by Yashodhan
Updated   File Tags Downloads
(last 30 days)
Comments Rating
27 Jul 2009 Screenshot Expectation-Maximization algorithm for bi-variate Normal Inverse Gaussian distribution Expectation-Maximization (EM) algorithm for bi-variate Normal Inverse Gaussian (biNIG) distribution Author: Karol Binkowski finance, statistics, simulation, expectation maximizat..., probability, em 9 2
  • 2.0
2.0 | 2 ratings

Contact us at files@mathworks.com