## [marf-cvs] marf/src/marf/Classification/Distance MahalanobisDistance.java,1.8,1.9

 [marf-cvs] marf/src/marf/Classification/Distance MahalanobisDistance.java,1.8,1.9 From: - 2003-05-04 20:35:55 ```Update of /cvsroot/marf/marf/src/marf/Classification/Distance In directory sc8-pr-cvs1:/tmp/cvs-serv19873/Classification/Distance Modified Files: MahalanobisDistance.java Log Message: Make MahalanobisDistance to fully use Matrix as 'prescribed'. For large sets of features run-time maybe large and increases exponetially. Next step: to implement leardning of the covariance matrix. Index: MahalanobisDistance.java =================================================================== RCS file: /cvsroot/marf/marf/src/marf/Classification/Distance/MahalanobisDistance.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MahalanobisDistance.java 2 May 2003 21:23:33 -0000 1.8 --- MahalanobisDistance.java 4 May 2003 20:35:53 -0000 1.9 *************** *** 52,55 **** --- 52,70 ---- double dDistance = 0; + Matrix oVector1 = new Matrix(paVector1); + Matrix oVector2 = new Matrix(paVector2); + + // dDistance = Math.sqrt(oVector1.minus(oVector2).multiply(this.oC.inverse()).multiply(oVector1.minus(oVector2).transpose())); + + Matrix oDifferenceVector = oVector1.minus(oVector2); + + Matrix oTransposedVector = (Matrix)oDifferenceVector.clone(); + oTransposedVector.transpose(); + + this.oC.inverse(); + + dDistance = Math.sqrt(oDifferenceVector.multiply(this.oC).multiply(oTransposedVector).getElement(0,0)); + + /* double[] adCovariedVector = new double[paVector1.length]; *************** *** 62,66 **** for(int f = 0; f < paVector1.length; f++) dDistance += (adCovariedVector[f] - paVector2[f]) * (adCovariedVector[f] - paVector2[f]); ! return dDistance; } --- 77,81 ---- for(int f = 0; f < paVector1.length; f++) dDistance += (adCovariedVector[f] - paVector2[f]) * (adCovariedVector[f] - paVector2[f]); ! */ return dDistance; } ```

 [marf-cvs] marf/src/marf/Classification/Distance MahalanobisDistance.java,1.8,1.9 From: - 2003-05-04 20:35:55 ```Update of /cvsroot/marf/marf/src/marf/Classification/Distance In directory sc8-pr-cvs1:/tmp/cvs-serv19873/Classification/Distance Modified Files: MahalanobisDistance.java Log Message: Make MahalanobisDistance to fully use Matrix as 'prescribed'. For large sets of features run-time maybe large and increases exponetially. Next step: to implement leardning of the covariance matrix. Index: MahalanobisDistance.java =================================================================== RCS file: /cvsroot/marf/marf/src/marf/Classification/Distance/MahalanobisDistance.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** MahalanobisDistance.java 2 May 2003 21:23:33 -0000 1.8 --- MahalanobisDistance.java 4 May 2003 20:35:53 -0000 1.9 *************** *** 52,55 **** --- 52,70 ---- double dDistance = 0; + Matrix oVector1 = new Matrix(paVector1); + Matrix oVector2 = new Matrix(paVector2); + + // dDistance = Math.sqrt(oVector1.minus(oVector2).multiply(this.oC.inverse()).multiply(oVector1.minus(oVector2).transpose())); + + Matrix oDifferenceVector = oVector1.minus(oVector2); + + Matrix oTransposedVector = (Matrix)oDifferenceVector.clone(); + oTransposedVector.transpose(); + + this.oC.inverse(); + + dDistance = Math.sqrt(oDifferenceVector.multiply(this.oC).multiply(oTransposedVector).getElement(0,0)); + + /* double[] adCovariedVector = new double[paVector1.length]; *************** *** 62,66 **** for(int f = 0; f < paVector1.length; f++) dDistance += (adCovariedVector[f] - paVector2[f]) * (adCovariedVector[f] - paVector2[f]); ! return dDistance; } --- 77,81 ---- for(int f = 0; f < paVector1.length; f++) dDistance += (adCovariedVector[f] - paVector2[f]) * (adCovariedVector[f] - paVector2[f]); ! */ return dDistance; } ```