X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=octave_packages%2Fnan-2.5.5%2Fdecovm.m;fp=octave_packages%2Fnan-2.5.5%2Fdecovm.m;h=401a5fecb51b5b8c5d2f37bce268ba6403b1c6ff;hb=c880e8788dfc484bf23ce13fa2787f2c6bca4863;hp=0000000000000000000000000000000000000000;hpb=1705066eceaaea976f010f669ce8e972f3734b05;p=CreaPhase.git diff --git a/octave_packages/nan-2.5.5/decovm.m b/octave_packages/nan-2.5.5/decovm.m new file mode 100644 index 0000000..401a5fe --- /dev/null +++ b/octave_packages/nan-2.5.5/decovm.m @@ -0,0 +1,78 @@ +function [mu,sd,COV,xc,M,R2]=decovm(XCN,NN) +% decompose extended covariance matrix into mean (mu), +% standard deviation, the (pure) Covariance (COV), +% correlation (xc) matrix and the correlation coefficients R2. +% NaN's are condsidered as missing values. +% [mu,sd,COV,xc,N,R2]=decovm(ECM[,NN]) +% +% ECM is the extended covariance matrix +% NN is the number of elements, each estimate (in ECM) is based on +% +% see also: MDBC, COVM, R2 + +% $Id: decovm.m 2140 2009-07-02 12:03:55Z schloegl $ +% Copyright (c) 1999-2002,2009 by Alois Schloegl +% This function is part of the NaN-toolbox +% http://pub.ist.ac.at/~schloegl/matlab/NaN/ + +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License +% as published by the Free Software Foundation; either version 3 +% of the License, or (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + +[r,c]=size(XCN); +if r~=c, + fprintf(2,'Warning DECOVM: input argument is not a square matrix\n'); + XCN = ecovm(XCN); + c = c + 1; +else + M = XCN(1,1); + if nargin<2, + XCN = XCN/(XCN(1,1)); + else %if nargin==2 + XCN = XCN./(NN); + end; + + if any(isnan(XCN(:))), + warning('DECOVM: Extended Covariance Matrix should not contain NaN''s'); + end; + if 0, %det(XCN)<0; % check removed for performance reasons + warning('DECOVM: Extended Covariance Matrix must be non-negative definite'); + end; +end; + +mu = XCN(1,2:c); +COV = XCN(2:c,2:c) - mu'*mu; +sd = sqrt(diag(COV))'; +if nargout<4, return; end; +xc = COV./(sd'*sd); +M = XCN(1,1); +if nargout<6, return; end; +R2 = xc.*xc; + +return; + +mu=XCN(2:N,1)/XCN(1,1); +COV=(XCN(2:N,2:N)/XCN(1,1)-XCN(2:N,1)*XCN(1,2:N)/XCN(1,1)^2); +sd=sqrt(diag(COV)); +xc=COV./(sd*sd'); + +% function [ECM] = ecovm(signal); +% Generates extended Covariance matrix, +% ECM= [l signal]'*[l signal]; % l is a matching column of 1's +% ECM is additive, i.e. it can be applied to subsequent blocks and summed up afterwards +% [ECM1] = ecovm(s1); +% [ECM2] = ecovm(s1); +% [ECM] = ecovm([s1;s2]); +% ECM1+ECM2==ECM; +% +% SS=sum(signal); ECM=[[size(signal,1),SS];[SS',signal'*signal]];