Code covered by the BSD License  

Highlights from
Statistical Learning Toolbox

from Statistical Learning Toolbox by Dahua Lin
Functions for statistical learning, pattern recognition and computer vision, covering many topics.

Description of slcmds
Home > sltoolbox > manifold > slcmds.m

slcmds

PURPOSE ^

SLMDS Performs Classical Multidimensional scaling

SYNOPSIS ^

function [X, spectrum] = slcmds(D, d, w, ty)

DESCRIPTION ^

SLMDS Performs Classical Multidimensional scaling

 $ Syntax $
   - X = slcmds(D, d)
   - X = slcmds(D, d, w)
   - X = slcmds(D, d, w, 'sqr')
   - [X, spectrum] = slcmds(...)

 $ Arguments $
   - D:        The pairwise distance matrix (n x n)
   - d:        The dimension of the embedding space
   - w:        The weights of samples (1 x n or [])
   - X:        The embedded samples (d x n)

 $ Description $
   - X = slcmds(D, d) performs classic multidimensional scaling to
     pursue an embedding space of d-dimension and the vector 
     representation in that space of the objects, such that the 
     distances are optimally preserved.

   - X = slcmds(D, d, w) If w is not empty, it performs classic 
     multidimensional scaling on weighted samples. 

   - X = slcmds(D, d, w, 'sqr') indicates that D contains the square
     of distances.

   - [X, spectrum] = slcmds(...) additionally outputs the spectrum of
     the embedded space
     
 $ History $
   - Created by Dahua Lin, on Sep 8th, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
  • sldists2kernels SLDISTS2KERNELS Computes the inner products from distances
  • slkernelembed SLKERNELEMBED Finds an embedding space to preserve inner products
  • raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
This function is called by:
  • slisomap SLISOMAP Performs ISOMAP manifold embedding

SOURCE CODE ^

0001 function [X, spectrum] = slcmds(D, d, w, ty)
0002 %SLMDS Performs Classical Multidimensional scaling
0003 %
0004 % $ Syntax $
0005 %   - X = slcmds(D, d)
0006 %   - X = slcmds(D, d, w)
0007 %   - X = slcmds(D, d, w, 'sqr')
0008 %   - [X, spectrum] = slcmds(...)
0009 %
0010 % $ Arguments $
0011 %   - D:        The pairwise distance matrix (n x n)
0012 %   - d:        The dimension of the embedding space
0013 %   - w:        The weights of samples (1 x n or [])
0014 %   - X:        The embedded samples (d x n)
0015 %
0016 % $ Description $
0017 %   - X = slcmds(D, d) performs classic multidimensional scaling to
0018 %     pursue an embedding space of d-dimension and the vector
0019 %     representation in that space of the objects, such that the
0020 %     distances are optimally preserved.
0021 %
0022 %   - X = slcmds(D, d, w) If w is not empty, it performs classic
0023 %     multidimensional scaling on weighted samples.
0024 %
0025 %   - X = slcmds(D, d, w, 'sqr') indicates that D contains the square
0026 %     of distances.
0027 %
0028 %   - [X, spectrum] = slcmds(...) additionally outputs the spectrum of
0029 %     the embedded space
0030 %
0031 % $ History $
0032 %   - Created by Dahua Lin, on Sep 8th, 2006
0033 %
0034 
0035 %% parse and verify input arguments
0036 
0037 if nargin < 2
0038     raise_lackinput('slcmds', 2);
0039 end
0040 
0041 if ndims(D) ~= 2 || size(D, 1) ~= size(D, 2)
0042     error('sltoolbox:invalidarg', ...
0043         'The D should be a square matrix');
0044 end
0045 n = size(D, 1);
0046 
0047 if d >= n
0048     error('sltoolbox:exceedbound', ...
0049         'The dimension d should be less than the number of samples n');
0050 end
0051 
0052 if nargin < 3
0053     w = [];
0054 else
0055     if ~isempty(w)
0056         if ~isequal(size(w), [1, n])
0057             error('sltoolbox:sizmismatch', ...
0058                 'If w is specified, it should be an 1 x n row vector');
0059         end
0060     end
0061 end
0062 
0063 if nargin >= 4 && strcmpi(ty, 'sqr')
0064     is_sqr = true;
0065 else
0066     is_sqr = false;
0067 end
0068 
0069 
0070 %% compute
0071 
0072 if ~is_sqr
0073     K = sldists2kernels(D);
0074 else
0075     K = sldists2kernels(D, 'sqr');
0076 end
0077 
0078 [X, spectrum] = slkernelembed(K, d, w);
0079 
0080 
0081 
0082 
0083 
0084     
0085     
0086 
0087

Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003

Contact us at files@mathworks.com