[Quantproject-developers] QuantProject/b1_ADT/Statistics BasicFunctions.cs,1.3,1.4
Brought to you by:
glauco_1
|
From: Marco M. <mi...@us...> - 2004-08-22 16:52:49
|
Update of /cvsroot/quantproject/QuantProject/b1_ADT/Statistics In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19434/b1_ADT/Statistics Modified Files: BasicFunctions.cs Log Message: Updated BasicFunctions class with the computation of CoVariance Index: BasicFunctions.cs =================================================================== RCS file: /cvsroot/quantproject/QuantProject/b1_ADT/Statistics/BasicFunctions.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BasicFunctions.cs 4 Aug 2004 22:49:27 -0000 1.3 --- BasicFunctions.cs 22 Aug 2004 16:52:40 -0000 1.4 *************** *** 90,93 **** --- 90,116 ---- return (sumOfSquares - sum*sum/data.Length)/data.Length; } + + static public double CoVariance( double[] firstDataVariable, + double[] secondDataVariable ) + { + BasicFunctions.checkLengthOfDataVariables(firstDataVariable, secondDataVariable); + double simpleAvgOfProduct = BasicFunctions.SimpleAverageOfProduct(firstDataVariable, secondDataVariable); + double productOfSimpleAvgs = BasicFunctions.SimpleAverage(firstDataVariable) * + BasicFunctions.SimpleAverage(secondDataVariable); + + return (simpleAvgOfProduct - productOfSimpleAvgs); + } + + static public double CoVariance( float[] firstDataVariable, + float[] secondDataVariable ) + { + BasicFunctions.checkLengthOfDataVariables(firstDataVariable, secondDataVariable); + double simpleAvgOfProduct = BasicFunctions.SimpleAverageOfProduct(firstDataVariable, secondDataVariable); + double productOfSimpleAvgs = BasicFunctions.SimpleAverage(firstDataVariable) * + BasicFunctions.SimpleAverage(secondDataVariable); + + return (simpleAvgOfProduct - productOfSimpleAvgs); + } + static public double StdDev( double[] data ) { *************** *** 103,113 **** { BasicFunctions.checkLengthOfDataVariables(firstDataVariable, secondDataVariable); ! double simpleAvgOfProduct = BasicFunctions.SimpleAverageOfProduct(firstDataVariable, secondDataVariable); ! double productOfSimpleAvgs = BasicFunctions.SimpleAverage(firstDataVariable) * ! BasicFunctions.SimpleAverage(secondDataVariable); double stdDevOfFirst = BasicFunctions.StdDev(firstDataVariable); double stdDevOfSecond = BasicFunctions.StdDev(secondDataVariable); ! return (simpleAvgOfProduct - productOfSimpleAvgs)/(stdDevOfFirst*stdDevOfSecond); } static public double PearsonCorrelationCoefficient( float[] firstDataVariable, --- 126,136 ---- { BasicFunctions.checkLengthOfDataVariables(firstDataVariable, secondDataVariable); ! double stdDevOfFirst = BasicFunctions.StdDev(firstDataVariable); double stdDevOfSecond = BasicFunctions.StdDev(secondDataVariable); + double coVariance = BasicFunctions.CoVariance(firstDataVariable, + secondDataVariable); ! return (coVariance)/(stdDevOfFirst*stdDevOfSecond); } static public double PearsonCorrelationCoefficient( float[] firstDataVariable, *************** *** 115,125 **** { BasicFunctions.checkLengthOfDataVariables(firstDataVariable, secondDataVariable); ! double simpleAvgOfProduct = BasicFunctions.SimpleAverageOfProduct(firstDataVariable, secondDataVariable); ! double productOfSimpleAvgs = BasicFunctions.SimpleAverage(firstDataVariable) * ! BasicFunctions.SimpleAverage(secondDataVariable); double stdDevOfFirst = BasicFunctions.StdDev(firstDataVariable); double stdDevOfSecond = BasicFunctions.StdDev(secondDataVariable); ! return (simpleAvgOfProduct - productOfSimpleAvgs)/(stdDevOfFirst*stdDevOfSecond); } --- 138,148 ---- { BasicFunctions.checkLengthOfDataVariables(firstDataVariable, secondDataVariable); ! double stdDevOfFirst = BasicFunctions.StdDev(firstDataVariable); double stdDevOfSecond = BasicFunctions.StdDev(secondDataVariable); + double coVariance = BasicFunctions.CoVariance(firstDataVariable, + secondDataVariable); ! return (coVariance)/(stdDevOfFirst*stdDevOfSecond); } |