function [ d ] = sizeOfVariance( eigvals, t_d ) % % This function implements the size of variance method for selecting the % number of significant principle components. The method takes any % principal components that are larger than a precentage of the total variance. % Taken from page 38 of % % Exploratory Data Analysis with MATLAB % by Martinez and Martinez. % % Written by: % -- % John L. Weatherwax 2005-08-14 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- if( nargin < 2 ) t_d = 0.7; end % make sure we have a row vector (with postive values): eigvals = abs(eigvals(:).'); % Sort eigenvalues in decreasing order: [ eigvals ] = sort( eigvals ); eigvals = fliplr( eigvals ); % Compute the mean of the variances: mVar = mean( eigvals ); inds = fliplr( find( eigvals > ( mVar * t_d ) ) ); % Send out the first: d = inds(1);