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

slinvevals

PURPOSE ^

SLINVEVALS Compute the reciprocals of eigenvalues in a robust way

SYNOPSIS ^

function revs = slinvevals(evals, method, r)

DESCRIPTION ^

SLINVEVALS Compute the reciprocals of eigenvalues in a robust way

 $ Syntax $
   - revs = slinvevals(evals)
   - revs = slinvevals(evals, method, r)

 $ Description $
   - revs = slinvevals(evals) computes the reciprocals of eigenvalues in
     the default way: using the default method and its corresponding
     default r value.
   
   - revs = slinvevals(evals, method, r) computes the reciprocals of 
     eigenvalues in a user-specified way.
     \*
     \t   Table 1. The methods of computing eigenvalue reciprocals
          name      &        revs
          'std'     & For effective eigenvalues, their reciprocals are
                      computed as usual; for the rest ones, their 
                      reciprocals are set to zeros. r values here is 
                      the ratio of minimum allowable effective eigenvalues
                      to the maximum eigenvalue. default r = 1e-7;
          'reg'     & Regularize the eigenvalues before computing their
                      reciprocals. By regularization, a small positive 
                      value is added to all eigenvalues. r value here is
                      the ratio of the addend to the maximum eigenvalue.
                      default r = 1e-6.
          'bound'   & Enforce lower bound to eigenvalues before computing
                      their reciprocals. The eigenvalues below the lower
                      bound is set to the lower bound value. r value here
                      is the ratio of the lower bound to the maximum 
                      eigenvalue. default r = 1e-6.
          'gapprox' & Computing the reciprocals of the eigenvalues in the
                      way of optimal non-singular approximation of 
                      Gaussian distribution. r values here is the ratio
                      of the minimum effective eigenvalues to the
                      maximum eigenvalue. The eigenvalues below are 
                      considered to be corresponding to isometric noises.
                      default r = 1e-6.
     \*

 $ Remarks $
   - The eigenvalues should be a column vector with values arranged in 
     a descending order.

 $ History $
   - Created by Dahua Lin on Apr 30th, 2006

CROSS-REFERENCE INFORMATION ^

This function calls:
This function is called by:
  • slgaussinv SLGAUSSINV Computes the inverse of variance/covariance in Gaussian model
  • slinvcov SLINVCOV Compute the inverse of an covariance matrix
  • slwhiten_from_cov SLWHITEN_FROM_COV Compute the whitening transform from covariance matrix
  • slwhiten_from_samples SLWHITEN_FROM_SAMPLES Compute the whitening matrix from sample matrix

SOURCE CODE ^

0001 function revs = slinvevals(evals, method, r)
0002 %SLINVEVALS Compute the reciprocals of eigenvalues in a robust way
0003 %
0004 % $ Syntax $
0005 %   - revs = slinvevals(evals)
0006 %   - revs = slinvevals(evals, method, r)
0007 %
0008 % $ Description $
0009 %   - revs = slinvevals(evals) computes the reciprocals of eigenvalues in
0010 %     the default way: using the default method and its corresponding
0011 %     default r value.
0012 %
0013 %   - revs = slinvevals(evals, method, r) computes the reciprocals of
0014 %     eigenvalues in a user-specified way.
0015 %     \*
0016 %     \t   Table 1. The methods of computing eigenvalue reciprocals
0017 %          name      &        revs
0018 %          'std'     & For effective eigenvalues, their reciprocals are
0019 %                      computed as usual; for the rest ones, their
0020 %                      reciprocals are set to zeros. r values here is
0021 %                      the ratio of minimum allowable effective eigenvalues
0022 %                      to the maximum eigenvalue. default r = 1e-7;
0023 %          'reg'     & Regularize the eigenvalues before computing their
0024 %                      reciprocals. By regularization, a small positive
0025 %                      value is added to all eigenvalues. r value here is
0026 %                      the ratio of the addend to the maximum eigenvalue.
0027 %                      default r = 1e-6.
0028 %          'bound'   & Enforce lower bound to eigenvalues before computing
0029 %                      their reciprocals. The eigenvalues below the lower
0030 %                      bound is set to the lower bound value. r value here
0031 %                      is the ratio of the lower bound to the maximum
0032 %                      eigenvalue. default r = 1e-6.
0033 %          'gapprox' & Computing the reciprocals of the eigenvalues in the
0034 %                      way of optimal non-singular approximation of
0035 %                      Gaussian distribution. r values here is the ratio
0036 %                      of the minimum effective eigenvalues to the
0037 %                      maximum eigenvalue. The eigenvalues below are
0038 %                      considered to be corresponding to isometric noises.
0039 %                      default r = 1e-6.
0040 %     \*
0041 %
0042 % $ Remarks $
0043 %   - The eigenvalues should be a column vector with values arranged in
0044 %     a descending order.
0045 %
0046 % $ History $
0047 %   - Created by Dahua Lin on Apr 30th, 2006
0048 %
0049 
0050 %% parse and verify input arguments
0051 
0052 n = length(evals);
0053 if n ~= numel(evals)
0054     error('sltoolbox:invalidarg', 'evals should be a vector');
0055 end
0056 
0057 if nargin < 2 || isempty(method)
0058     method = 'std';
0059 end
0060 
0061 %% compute
0062 
0063 % make strictly non-negative
0064 evals = max(evals, 0);
0065 
0066 switch method    
0067     case 'std'
0068         if nargin < 3 || isempty(r)
0069             r = 1e-7;
0070         end
0071         lb = r * evals(1);
0072         k = sum(evals >= lb);
0073         if k == n
0074             revs = 1 ./ evals;
0075         else
0076             revs = [1 ./ evals(1:k); zeros(n-k, 1)];
0077         end
0078         
0079     case 'reg'
0080         if nargin < 3 || isempty(r)
0081             r = 1e-6;
0082         end
0083         a = r * evals(1);
0084         revs = 1 ./ (evals + a);
0085         
0086     case 'bound'
0087         if nargin < 3 || isempty(r)
0088             r = 1e-6;
0089         end
0090         lb = r * evals(1);
0091         evals = max(evals, lb);
0092         revs = 1 ./ evals;
0093         
0094     case 'gapprox'
0095         if nargin < 3 || isempty(r)
0096             r = 1e-6;
0097         end
0098         lb = r * evals(1);
0099         k = sum(evals >= lb);
0100         if k == n
0101             revs = 1 ./ evals;
0102         else
0103             nv = sum(evals(k+1:n)) / (n-k);
0104             rnv = 1 / nv;
0105             rnvs = rnv(ones(n-k, 1));
0106             revs = [1 ./ evals(1:k); rnvs];
0107         end
0108         
0109 end
0110

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

Contact us at files@mathworks.com