source: distools/disnorm.m @ 11

Last change on this file since 11 was 10, checked in by bduin, 14 years ago
File size: 1.2 KB
Line 
1%DISNORM Normalization of a dissimilarity matrix
2%
3%       V = disnorm(D,OPT)
4%   F = E*V
5%
6% INPUT
7%   D    NxN dissimilarity matrix or dataset, which sets the norm
8%   E    Matrix to be normalized
9%       OPT  'max' : maximum dissimilarity is set to 1 by global rescaling
10%                  'mean': average dissimilarity is set to 1 by global rescaling (default)
11%
12% OUTPUT
13%   V   Fixed mapping
14%   F   Normalized dissimilarity data
15%
16% DEFAULT
17%   OPT = 'mean'
18%
19
20% Copyright: Elzbieta Pekalska, ela.pekalska@googlemail.com
21% Faculty EWI, Delft University of Technology and
22% School of Computer Science, University of Manchester
23
24
25function V = disnorm(D,opt)
26if nargin < 2,
27        opt = 'mean';
28end
29
30if nargin == 0 | isempty(D)
31  V = mapping(mfilename,{opt});
32  V = setname(V,'Disnorm');
33  return
34end
35
36%DEFINE mapping
37if isstr(opt)
38        discheck(D);
39        opt = lower(opt);
40        if strcmp(opt,'mean')
41                n = size(D,1);
42                m = sum(sum(+D))/(n*(n-1));
43        elseif strcmp(opt,'max')
44                m = max(D(:));
45        else
46                error('Wrong OPT.')
47        end
48        if nargout > 1
49                D = D./m;
50        end     
51    V = mapping(mfilename,'trained',{m},[],size(D,2),size(D,2));
52        return;
53end
54
55
56% APPLY mapping
57if ismapping(opt)
58        opt = getdata(opt,1);
59        V = D./opt;
60        return;
61end                     
62       
Note: See TracBrowser for help on using the repository browser.