changeset 1253:634e73d5db36 octave-forge

improve documentation - only (CORRCOEF)<=1, abs(COR) can be larger than 1, too
author schloegl
date Fri, 30 Jan 2004 11:03:19 +0000
parents db52758cd21d
children cc81e087aa50
files extra/NaN/cor.m extra/NaN/corrcoef.m
diffstat 2 files changed, 22 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/extra/NaN/cor.m	Fri Jan 30 00:28:02 2004 +0000
+++ b/extra/NaN/cor.m	Fri Jan 30 11:03:19 2004 +0000
@@ -13,13 +13,21 @@
 % c = COR(...);
 % 	c is the correlation matrix
 %
+% NOTE: Under certain circumstances (Missing values and small number of samples) 
+%   abs(COR) can be larger than 1.  
+%   If you need abs(COR)<=1, use CORRCOEF. CORRCOEF garantees abs(COR)<=1. 
+%
 % see also: SUMSKIPNAN, COVM, COV, CORRCOEF
 %
 % REFERENCES:
 % http://mathworld.wolfram.com/CorrelationCoefficient.html
 
 
-%	Copyright (C) 2000-2002 by  Alois Schloegl <a.schloegl@ieee.org>	
+%       $Revision$
+%       $Id$
+%	Copyright (C) 2000-2004 by  Alois Schloegl <a.schloegl@ieee.org>	
+%       This function is part of the NaN-toolbox
+%       http://www.dpmi.tu-graz.ac.at/~schloegl/matlab/NaN/
 
 
 %    This program is free software; you can redistribute it and/or modify
--- a/extra/NaN/corrcoef.m	Fri Jan 30 00:28:02 2004 +0000
+++ b/extra/NaN/corrcoef.m	Fri Jan 30 11:03:19 2004 +0000
@@ -1,12 +1,13 @@
 function [R,sig,ci1,ci2,nan_sig] = corrcoef(X,Y,Mode);
 % CORRCOEF calculates the correlation coefficient.
-% X and Y can contain missing values encoded with NaN.
-% NaN's are skipped, NaN do not result in a NaN output. 
-% A significance test to check the independence of NaN's
-% is included. 
-%   CORRCOEF(X [,Mode]);
+%   X and Y can contain missing values encoded with NaN.
+%   NaN's are skipped, NaN do not result in a NaN output. 
+%   It is garanteed that abs(R) is not larger than 1. 
+%   A significance test to check the independence of NaN's
+%   is included. 
+%   R = CORRCOEF(X [,Mode]);
 %      calculates the (auto-)correlation matrix of X
-%   CORRCOEF(X,Y [,Mode]);
+%   R = CORRCOEF(X,Y [,Mode]);
 %      calculates the crosscorrelation between X and Y
 %
 % Mode='Pearson' or 'parametric' [default]
@@ -60,9 +61,11 @@
 % others
 % [20] http://www.tufts.edu/~gdallal/corr.htm
 
-%    $Revision$
-%    $Id$
-%    Copyright (C) 2000-2003 by  Alois Schloegl <a.schloegl@ieee.org>	
+%       $Revision$
+%       $Id$
+%       Copyright (C) 2000-2003 by  Alois Schloegl <a.schloegl@ieee.org>	
+%       This function is part of the NaN-toolbox
+%       http://www.dpmi.tu-graz.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
@@ -218,7 +221,7 @@
                 end;
 		X = ranks(X);
         end;
-        R = 1 - 6 * R ./ (n.*(n.*n-1));
+        R = 1 - 6 * R ./ (n.*(n.*n-1));
         
 elseif strcmp(lower(Mode(1:7)),'partial');
         fprintf(2,'Error CORRCOEF: use PARTCORRCOEF \n',Mode);