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 slwhiten_from_cov
Home > sltoolbox > stat > slwhiten_from_cov.m

slwhiten_from_cov

PURPOSE ^

SLWHITEN_FROM_COV Compute the whitening transform from covariance matrix

SYNOPSIS ^

function W = slwhiten_from_cov(C, method, varargin)

DESCRIPTION ^

SLWHITEN_FROM_COV Compute the whitening transform from covariance matrix

 $ Syntax $
   - W = slwhiten_from_cov(C)
   - W = slwhiten_from_cov(C, method, ...)

 $ Arguments $
   - C:        the covariance matrix
   - method:   the method for computing the whitening transform
   - W:        the computed whitening transform matrix

 $ Description $
   - W = slwhiten_from_cov(C) computes the whitening matrix from C using 
     default method ('std').
   - W = slwhiten_from_cov(C, method, r) computes the whitening matrix 
     from C using specific method and the extra parameters. Please
     refer to slinvevals for the available methods and corresponding
     parameters.

 $ Remarks $
   - C should be a positive semidefinite matrix.

 $ History $
   - Created by Dahua Lin on Apr 30th, 2006
   - Modified by Dahua Lin on Sep 10, 2006
       - replace slmul by slmulvec to increase efficiency

CROSS-REFERENCE INFORMATION ^

This function calls:
  • slmulvec SLMULVEC multiplies a vector to columns or rows of a matrix
  • slsymeig SLSYMEIG Compute the eigenvalues and eigenvectors for symmetric matrix
  • slinvevals SLINVEVALS Compute the reciprocals of eigenvalues in a robust way
This function is called by:
  • slgembed SLGEMBED Solves the general graph-based embedding
  • sldlda SLDLDA Performs Direct Linear Discriminant Analysis
  • slfld SLFLD Performs Fisher Linear Discriminant Analysis

SOURCE CODE ^

0001 function W = slwhiten_from_cov(C, method, varargin)
0002 %SLWHITEN_FROM_COV Compute the whitening transform from covariance matrix
0003 %
0004 % $ Syntax $
0005 %   - W = slwhiten_from_cov(C)
0006 %   - W = slwhiten_from_cov(C, method, ...)
0007 %
0008 % $ Arguments $
0009 %   - C:        the covariance matrix
0010 %   - method:   the method for computing the whitening transform
0011 %   - W:        the computed whitening transform matrix
0012 %
0013 % $ Description $
0014 %   - W = slwhiten_from_cov(C) computes the whitening matrix from C using
0015 %     default method ('std').
0016 %   - W = slwhiten_from_cov(C, method, r) computes the whitening matrix
0017 %     from C using specific method and the extra parameters. Please
0018 %     refer to slinvevals for the available methods and corresponding
0019 %     parameters.
0020 %
0021 % $ Remarks $
0022 %   - C should be a positive semidefinite matrix.
0023 %
0024 % $ History $
0025 %   - Created by Dahua Lin on Apr 30th, 2006
0026 %   - Modified by Dahua Lin on Sep 10, 2006
0027 %       - replace slmul by slmulvec to increase efficiency
0028 %
0029 
0030 %% parse and verify input arguments
0031 
0032 if ndims(C) ~= 2 || size(C, 1) ~= size(C, 2)
0033     error('sltoolbox:invaliddims', 'C should be a square matrix');
0034 end
0035 
0036 if nargin < 2
0037     method = 'std';
0038     params = {};
0039 else
0040     params = varargin;
0041 end
0042 
0043 
0044 %% compute
0045 
0046 [evs, U] = slsymeig(C);
0047 revs = slinvevals(evs, method, params{:})';
0048 
0049 if strcmp(method, 'std') 
0050     si = find(revs > 0);
0051     revs = revs(si);
0052     U = U(:, si);
0053 end
0054 
0055 W = slmulvec(U, sqrt(revs), 2);
0056 
0057

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

Contact us at files@mathworks.com