commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dim...@apache.org
Subject svn commit: r982507 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/linear/ main/java/org/apache/commons/math/optimization/general/ site/xdoc/ test/java/org/apache/commons/math/optimization/general/
Date Thu, 05 Aug 2010 08:48:00 GMT
Author: dimpbx
Date: Thu Aug  5 08:48:00 2010
New Revision: 982507

URL: http://svn.apache.org/viewvc?rev=982507&view=rev
Log:
MATH-377 fixed

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
    commons/proper/math/trunk/src/site/xdoc/changes.xml
    commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java?rev=982507&r1=982506&r2=982507&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/EigenDecompositionImpl.java
Thu Aug  5 08:48:00 2010
@@ -561,7 +561,7 @@ public class EigenDecompositionImpl impl
                             z[ia][i] = c * z[ia][i] - s * p;
                         }
                     }
-                    if (e[i + 1] == 0.0 && i >= j)
+                    if (t == 0.0 && i >= j)
                         continue;
                     realEigenvalues[j] -= u;
                     e[j] = q;

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java?rev=982507&r1=982506&r2=982507&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/linear/SingularValueDecompositionImpl.java
Thu Aug  5 08:48:00 2010
@@ -108,7 +108,7 @@ public class SingularValueDecompositionI
                 for (int k = 0; k < n; k++) {
                     matAAT[i][j] += localcopy[i][k] * localcopy[j][k];
                 }
-                matAAT[j][i]=matAAT[i][j];
+                 matAAT[j][i]=matAAT[i][j];
             }
         }
         int p;
@@ -119,7 +119,6 @@ public class SingularValueDecompositionI
                     new Array2DRowRealMatrix(matATA),1.0);
             singularValues = eigenDecomposition.getRealEigenvalues();
             cachedV = eigenDecomposition.getV();
-
             // compute eigen decomposition of A*A^T
             eigenDecomposition = new EigenDecompositionImpl(
                     new Array2DRowRealMatrix(matAAT),1.0);
@@ -141,7 +140,7 @@ public class SingularValueDecompositionI
             singularValues[i] = Math.sqrt(Math.abs(singularValues[i]));
         }
         // Up to this point, U and V are computed independently of each other.
-        // There still an sign indetermination of each column of, say, U.
+        // There still a sign indetermination of each column of, say, U.
         // The sign is set such that A.V_i=sigma_i.U_i (i<=p)
         // The right sign corresponds to a positive dot product of A.V_i and U_i
         for (int i = 0; i < p; i++) {

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java?rev=982507&r1=982506&r2=982507&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/optimization/general/AbstractLeastSquaresOptimizer.java
Thu Aug  5 08:48:00 2010
@@ -237,23 +237,20 @@ public abstract class AbstractLeastSquar
      * @return RMS value
      */
     public double getRMS() {
-        double criterion = 0;
-        for (int i = 0; i < rows; ++i) {
-            final double residual = residuals[i];
-            criterion += residualsWeights[i] * residual * residual;
-        }
-        return Math.sqrt(criterion / rows);
+        return Math.sqrt(getChiSquare() / rows);
     }
 
     /**
-     * Get the Chi-Square value.
+     * Get a Chi-Square-like value assuming the N residuals follow N
+     * distinct normal distributions centered on 0 and whose variances are
+     * the reciprocal of the weights.
      * @return chi-square value
      */
     public double getChiSquare() {
         double chiSquare = 0;
         for (int i = 0; i < rows; ++i) {
             final double residual = residuals[i];
-            chiSquare += residual * residual / residualsWeights[i];
+            chiSquare += residual * residual * residualsWeights[i];
         }
         return chiSquare;
     }

Modified: commons/proper/math/trunk/src/site/xdoc/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/site/xdoc/changes.xml?rev=982507&r1=982506&r2=982507&view=diff
==============================================================================
--- commons/proper/math/trunk/src/site/xdoc/changes.xml (original)
+++ commons/proper/math/trunk/src/site/xdoc/changes.xml Thu Aug  5 08:48:00 2010
@@ -52,6 +52,9 @@ The <action> type attribute can be add,u
     If the output is not quite correct, check for invisible trailing spaces!
      -->
     <release version="2.2" date="TBD" description="TBD">
+      <action dev="dimpbx" type="fix" issue="MATH-377">
+        Fixed bug in chi-square computation in AbstractLeastSquaresOptimizer.
+      </action>
       <action dev="luc" type="add" issue="MATH-400" due-to="J. Lewis Muir">
         Added support for Gaussian curve fitting.
       </action>

Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java?rev=982507&r1=982506&r2=982507&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
(original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/optimization/general/LevenbergMarquardtOptimizerTest.java
Thu Aug  5 08:48:00 2010
@@ -439,8 +439,8 @@ public class LevenbergMarquardtOptimizer
         assertEquals(cov[0][1], cov[1][0], 1.0e-14);
         assertEquals(0.0016, cov[1][1], 0.001);
         errors = optimizer.guessParametersErrors();
-        assertEquals(0.002, errors[0], 0.001);
-        assertEquals(0.002, errors[1], 0.001);
+        assertEquals(0.004, errors[0], 0.001);
+        assertEquals(0.004, errors[1], 0.001);
 
     }
 



Mime
View raw message