[13] | 1 | %CUTEIGS Select significant eigenvalues from a list
|
---|
| 2 | %
|
---|
| 3 | % J = CUTEIGS(L,PREC)
|
---|
| 4 | %
|
---|
| 5 | % INPUT
|
---|
| 6 | % L List of eigenvalues
|
---|
| 7 | % PREC Precision parameter (optional; default: 0.0001)
|
---|
| 8 | %
|
---|
| 9 | % OUTPUT
|
---|
| 10 | % J Index of selected eigenvalues
|
---|
| 11 | %
|
---|
| 12 | % DESCRIPTION
|
---|
| 13 | % This is a low-level routine for SELEIGS, which serves PSEM, KPSEM, KPCA and
|
---|
| 14 | % PEPCA. It makes use of PCHIP determing piecewise cubic Hermite interpolating
|
---|
| 15 | % polynomial P, built on [1:length(LL) LL], where LL = -sort(-abs(L).^3) folloowed
|
---|
| 16 | % by a normalization to [0,1]. A third power is used to emphasize the differences
|
---|
| 17 | % better, as sometimes there is a very long tail of slowly dropping eigenvalues.
|
---|
| 18 | % The number M of significant eigenvalues is determined such that the ratio
|
---|
| 19 | % of the estimated derivative of P versus the largest derivative value is smaller
|
---|
| 20 | % then the given precision, PREC * cumsum(LL).
|
---|
| 21 | %
|
---|
| 22 | % Note that M will differ between different samples and for different sizes of L.
|
---|
| 23 | %
|
---|
| 24 | % SEE ALSO
|
---|
| 25 | % MAPPINGS, DATASETS, PSEM, KPSEM, KPCA, PEPCA
|
---|
| 26 | %
|
---|
| 27 |
|
---|
| 28 | % Elzbieta Pekalska, e.pekalska@ewi.tudelft.nl
|
---|
| 29 | % Faculty of Electrical Engineering, Mathematics and Computer Science,
|
---|
| 30 | % Delft University of Technology, The Netherlands
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | function [J,prec] = cuteigs(L,prec)
|
---|
| 34 |
|
---|
| 35 | if nargin < 2 | isempty(prec),
|
---|
| 36 | prec = 0.0001;
|
---|
| 37 | end
|
---|
| 38 |
|
---|
| 39 | tol = 1e-14;
|
---|
| 40 |
|
---|
| 41 | n = length(L);
|
---|
| 42 | LL = L.^3;
|
---|
| 43 | [lambda,J] = sort(-abs(LL)/sum(abs(LL)));
|
---|
| 44 | lambda = -lambda;
|
---|
| 45 |
|
---|
| 46 | if n > 1,
|
---|
| 47 | M = findJ(lambda,prec);
|
---|
| 48 | else
|
---|
| 49 | M = n;
|
---|
| 50 | end
|
---|
| 51 | JJ = J(1:M);
|
---|
| 52 |
|
---|
| 53 | I1 = find (L(JJ) >= 0);
|
---|
| 54 | I2 = find (L(JJ) < 0);
|
---|
| 55 |
|
---|
| 56 | J = [JJ(I1); JJ(I2)];
|
---|
| 57 |
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 |
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 |
|
---|
| 64 | function M = findJ (lambda,prec)
|
---|
| 65 |
|
---|
| 66 | n = length(lambda);
|
---|
| 67 | if n >= 400,
|
---|
| 68 | Z = [1:80 81:4:n];
|
---|
| 69 | elseif n >= 200,
|
---|
| 70 | Z = [1:50 51:2:n];
|
---|
| 71 | else
|
---|
| 72 | Z =1:n;
|
---|
| 73 | end
|
---|
| 74 |
|
---|
| 75 | if n > 3
|
---|
| 76 | % Hermite piecewise cubic interpolating polynomial
|
---|
| 77 | H = pchip(Z,lambda(Z));
|
---|
| 78 |
|
---|
| 79 | % Derivative of the Hermite piecewise cubic polynomial
|
---|
| 80 | Hder = H;
|
---|
| 81 | Hder.order = 3;
|
---|
| 82 | Hder.coefs = zeros(H.pieces,3);
|
---|
| 83 | for i=1:Hder.pieces
|
---|
| 84 | pp = polyder(H.coefs(i,:));
|
---|
| 85 | Hder.coefs(i,4-length(pp):3) = pp;
|
---|
| 86 | end
|
---|
| 87 | pder= -ppval(1:n,Hder); % Evaluated derivative
|
---|
| 88 | else
|
---|
| 89 | pder= [lambda(1) -diff(lambda')]; % Approximated derivative
|
---|
| 90 | end
|
---|
| 91 |
|
---|
| 92 | % pder(1) is an extrapolated value; pder(2) is used
|
---|
| 93 | I = find(pder/pder(2) < prec*cumsum(lambda'));
|
---|
| 94 | II = diff(I);
|
---|
| 95 | Q = find(II > 1);
|
---|
| 96 | if ~isempty(Q),
|
---|
| 97 | I = I(Q(1));
|
---|
| 98 | end
|
---|
| 99 | if ~isempty(I),
|
---|
| 100 | M = I(1)-1;
|
---|
| 101 | else
|
---|
| 102 | if n <= 25,
|
---|
| 103 | M = n;
|
---|
| 104 | else
|
---|
| 105 | M = n-1;
|
---|
| 106 | end
|
---|
| 107 | end
|
---|
| 108 | if M < 1, M = 1; end
|
---|