1 function [mu,sd,COV,xc,M,R2]=decovm(XCN,NN)
2 % decompose extended covariance matrix into mean (mu),
3 % standard deviation, the (pure) Covariance (COV),
4 % correlation (xc) matrix and the correlation coefficients R2.
5 % NaN's are condsidered as missing values.
6 % [mu,sd,COV,xc,N,R2]=decovm(ECM[,NN])
8 % ECM is the extended covariance matrix
9 % NN is the number of elements, each estimate (in ECM) is based on
11 % see also: MDBC, COVM, R2
13 % $Id: decovm.m 2140 2009-07-02 12:03:55Z schloegl $
14 % Copyright (c) 1999-2002,2009 by Alois Schloegl
15 % This function is part of the NaN-toolbox
16 % http://pub.ist.ac.at/~schloegl/matlab/NaN/
18 % This program is free software; you can redistribute it and/or
19 % modify it under the terms of the GNU General Public License
20 % as published by the Free Software Foundation; either version 3
21 % of the License, or (at your option) any later version.
23 % This program is distributed in the hope that it will be useful,
24 % but WITHOUT ANY WARRANTY; without even the implied warranty of
25 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 % GNU General Public License for more details.
28 % You should have received a copy of the GNU General Public License
29 % along with this program; if not, write to the Free Software
30 % Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
34 fprintf(2,'Warning DECOVM: input argument is not a square matrix\n');
45 if any(isnan(XCN(:))),
46 warning('DECOVM: Extended Covariance Matrix should not contain NaN''s');
48 if 0, %det(XCN)<0; % check removed for performance reasons
49 warning('DECOVM: Extended Covariance Matrix must be non-negative definite');
54 COV = XCN(2:c,2:c) - mu'*mu;
55 sd = sqrt(diag(COV))';
56 if nargout<4, return; end;
59 if nargout<6, return; end;
64 mu=XCN(2:N,1)/XCN(1,1);
65 COV=(XCN(2:N,2:N)/XCN(1,1)-XCN(2:N,1)*XCN(1,2:N)/XCN(1,1)^2);
69 % function [ECM] = ecovm(signal);
70 % Generates extended Covariance matrix,
71 % ECM= [l signal]'*[l signal]; % l is a matching column of 1's
72 % ECM is additive, i.e. it can be applied to subsequent blocks and summed up afterwards
75 % [ECM] = ecovm([s1;s2]);
78 % SS=sum(signal); ECM=[[size(signal,1),SS];[SS',signal'*signal]];