%MDS_STRESS - Sammon stress between dissimilarity matrices % % E = MDS_STRESS(Q,DS,D) % % INPUT % Q Indicator of the Sammon stress; Q = -2,-1,0,1,2 % DS Original distance matrix % D Approximated distance matrix % % OUTPUT % E Sammon stress % % DESCRIPTION % Computes the Sammon stress between the original distance matrix Ds % and the approximated distance matrix D, expressed as follows: % % E = 1/(sum_{i eps) values to be included % for the computation of the stress I = 1:mk; nanindex = find(isnan(Ds(:)) | isnan(D(:))); if ~isempty(nanindex), I(nanindex) = []; end O = []; if m == k & (length(intersect(find(D(:) < eps), 1:m+1:(mk))) == m), O = 1:m+1:mk; Ds(O) = 1; D (O) = 1; mm = m - 1; else mm = k; end if isratio, II = setdiff(I,O); alpha = sum((Ds(II).^q).*D(II).^2)/sum((Ds(II).^(q+1)).*D(II)); Ds = alpha*Ds; else alpha = 1; end c = sum(Ds(I).^(q+2)) - length(O); if q ~= 0, e = sum(Ds(I).^q .* ((Ds(I)-D(I)).^2))/c; else e = sum(((Ds(I)-D(I)).^2))/c; end return;