function [Err,sPropTotal,sPropMunits,sPropComps] = som_distortion3(sM,D,rad) %SOM_DISTORTION3 Map distortion measures. % % [sE,Err] = som_distortion3(sM,[D],[rad]); % % sE = som_distortion3(sM); % % Input and output arguments ([]'s are optional): % sM (struct) map struct % [D] (matrix) a matrix, size dlen x dim % (struct) data or map struct % by default the map struct is used % [rad] (scalar) neighborhood radius, looked from sM.trainhist % by default, or = 1 if that has no valid values % % Err (matrix) size munits x dim x 3 % distortion error elements (quantization error, % neighborhood bias, and neighborhood variance) % for each map unit and component % sPropTotal (struct) .n = length of data % .h = mean neighborhood function value % .err = errors % sPropMunits (struct) .Ni = hits per map unit % .Hi = sum of neighborhood values for each map unit % .Err = errors per map unit % sPropComps (struct) .e1 = total squared distance to centroid % .eq = total squared distance to BMU % .Err = errors per component % % See also SOM_QUALITY. % Contributed to SOM Toolbox 2.0, January 3rd, 2002 by Juha Vesanto % Copyright (c) by Juha Vesanto % http://www.cis.hut.fi/projects/somtoolbox/ % Version 2.0beta juuso 030102 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% arguments % map [munits dim] = size(sM.codebook); % neighborhood radius if nargin<3, if ~isempty(sM.trainhist), rad = sM.trainhist(end).radius_fin; else rad = 1; end end if rad0); v(i) = c(i)./nn(i); return; function vis figure som_show(sM,'color',{Hi,'Hi'},'color',{Ni,'hits'},... 'color',{Ed,'distortion'},'color',{Eqx,'qxerror'},... 'color',{Enb,'N-bias'},'color',{Env,'N-Var'}); ed = Eqx + Enb + Env; i = find(ed>0); eqx = 0*ed; eqx(i) = Eqx(i)./ed(i); enb = 0*ed; enb(i) = Enb(i)./ed(i); env = 0*ed; env(i) = Env(i)./ed(i); figure som_show(sM,'color',Hi,'color',Ni,'color',Ed,... 'color',eqx,'color',enb,'color',env);