Author: luc
Date: Thu Feb 20 14:35:14 2014
New Revision: 1570206
URL: http://svn.apache.org/r1570206
Log:
computeXxx renamed getXxx in the Evaluation interface (leastsquares).
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/AbstractEvaluation.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/DenseWeightedEvaluation.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresFactory.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblem.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblemImpl.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizer.java
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/OptimumImpl.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/EvaluationTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/EvaluationTestValidation.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/MinpackTest.java
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/AbstractEvaluation.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/AbstractEvaluation.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/AbstractEvaluation.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/AbstractEvaluation.java
Thu Feb 20 14:35:14 2014
@@ -42,16 +42,16 @@ abstract class AbstractEvaluation implem
* Constructor.
*
* @param observationSize the number of observation. Needed for {@link
- * #computeRMS()}.
+ * #getRMS()}.
*/
AbstractEvaluation(final int observationSize) {
this.observationSize = observationSize;
}
/** {@inheritDoc} */
- public RealMatrix computeCovariances(double threshold) {
+ public RealMatrix getCovariances(double threshold) {
// Set up the Jacobian.
- final RealMatrix j = this.computeJacobian();
+ final RealMatrix j = this.getJacobian();
// Compute transpose(J)J.
final RealMatrix jTj = j.transpose().multiply(j);
@@ -63,8 +63,8 @@ abstract class AbstractEvaluation implem
}
/** {@inheritDoc} */
- public RealVector computeSigma(double covarianceSingularityThreshold) {
- final RealMatrix cov =
this.computeCovariances(covarianceSingularityThreshold);
+ public RealVector getSigma(double covarianceSingularityThreshold) {
+ final RealMatrix cov =
this.getCovariances(covarianceSingularityThreshold);
final int nC = cov.getColumnDimension();
final RealVector sig = new ArrayRealVector(nC);
for (int i = 0; i < nC; ++i) {
@@ -74,14 +74,14 @@ abstract class AbstractEvaluation implem
}
/** {@inheritDoc} */
- public double computeRMS() {
- final double cost = this.computeCost();
+ public double getRMS() {
+ final double cost = this.getCost();
return FastMath.sqrt(cost * cost / this.observationSize);
}
/** {@inheritDoc} */
- public double computeCost() {
- final ArrayRealVector r = new ArrayRealVector(this.computeResiduals());
+ public double getCost() {
+ final ArrayRealVector r = new ArrayRealVector(this.getResiduals());
return FastMath.sqrt(r.dotProduct(r));
}
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/DenseWeightedEvaluation.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/DenseWeightedEvaluation.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/DenseWeightedEvaluation.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/DenseWeightedEvaluation.java
Thu Feb 20 14:35:14 2014
@@ -50,18 +50,18 @@ class DenseWeightedEvaluation extends Ab
/* apply weights */
/** {@inheritDoc} */
- public RealMatrix computeJacobian() {
- return weightSqrt.multiply(this.unweighted.computeJacobian());
+ public RealMatrix getJacobian() {
+ return weightSqrt.multiply(this.unweighted.getJacobian());
}
/** {@inheritDoc} */
- public RealVector computeResiduals() {
- return this.weightSqrt.operate(this.unweighted.computeResiduals());
+ public RealVector getResiduals() {
+ return this.weightSqrt.operate(this.unweighted.getResiduals());
}
/** {@inheritDoc} */
- public RealVector computeValue() {
- return this.weightSqrt.operate(unweighted.computeValue());
+ public RealVector getValue() {
+ return this.weightSqrt.operate(unweighted.getValue());
}
/* delegate */
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/GaussNewtonOptimizer.java
Thu Feb 20 14:35:14 2014
@@ -211,8 +211,8 @@ public class GaussNewtonOptimizer implem
// Value of the objective function at "currentPoint".
evaluationCounter.incrementCount();
current = lsp.evaluate(currentPoint);
- final RealVector currentResiduals = current.computeResiduals();
- final RealMatrix weightedJacobian = current.computeJacobian();
+ final RealVector currentResiduals = current.getResiduals();
+ final RealMatrix weightedJacobian = current.getJacobian();
// Check convergence.
if (previous != null) {
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresFactory.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresFactory.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresFactory.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresFactory.java
Thu Feb 20 14:35:14 2014
@@ -215,11 +215,11 @@ public class LeastSquaresFactory {
iteration,
new PointVectorValuePair(
previous.getPoint().toArray(),
- previous.computeValue().toArray(),
+ previous.getValue().toArray(),
false),
new PointVectorValuePair(
current.getPoint().toArray(),
- current.computeValue().toArray(),
+ current.getValue().toArray(),
false)
);
}
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblem.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblem.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblem.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblem.java
Thu Feb 20 14:35:14 2014
@@ -24,7 +24,7 @@ import org.apache.commons.math3.linear.R
* <p>
* Includes the observed values, computed model function, and
* convergence/divergence criteria. Weights are implicit in {@link
- * Evaluation#computeResiduals()} and {@link Evaluation#computeJacobian()}.
+ * Evaluation#getResiduals()} and {@link Evaluation#getJacobian()}.
* </p>
* <p>
* Instances are typically either created progressively using a {@link
@@ -92,57 +92,57 @@ public interface LeastSquaresProblem ext
* @throws org.apache.commons.math3.linear.SingularMatrixException
* if the covariance matrix cannot be computed (singular
problem).
*/
- RealMatrix computeCovariances(double threshold);
+ RealMatrix getCovariances(double threshold);
/**
- * Computes an estimate of the standard deviation of the parameters.
The returned
+ * Get an estimate of the standard deviation of the parameters. The
returned
* values are the square root of the diagonal coefficients of the
covariance
* matrix, {@code sd(a[i]) ~= sqrt(C[i][i])}, where {@code a[i]} is
the optimized
* value of the {@code i}-th parameter, and {@code C} is the
covariance matrix.
*
*
* @param covarianceSingularityThreshold Singularity threshold (see
{@link
- * #computeCovariances(double)
computeCovariances}).
+ * #getCovariances(double)
computeCovariances}).
* @return an estimate of the standard deviation of the optimized
parameters
* @throws org.apache.commons.math3.linear.SingularMatrixException
* if the covariance matrix cannot be computed.
*/
- RealVector computeSigma(double covarianceSingularityThreshold);
+ RealVector getSigma(double covarianceSingularityThreshold);
/**
- * Computes the normalized cost. It is the square-root of the sum of
squared of
+ * Get the normalized cost. It is the square-root of the sum of
squared of
* the residuals, divided by the number of measurements.
*
* @return the cost.
*/
- double computeRMS();
+ double getRMS();
/**
- * Computes the weighted objective (model) function value.
+ * Get the weighted objective (model) function value.
*
* @return the weighted objective function value at the specified
point.
*/
- RealVector computeValue();
+ RealVector getValue();
/**
- * Computes the weighted Jacobian matrix.
+ * Get the weighted Jacobian matrix.
*
* @return the weighted Jacobian: W<sup>1/2</sup> J.
* @throws
org.apache.commons.math3.exception.DimensionMismatchException
* if the Jacobian dimension does not match problem dimension.
*/
- RealMatrix computeJacobian();
+ RealMatrix getJacobian();
/**
- * Computes the cost.
+ * Get the cost.
*
* @return the cost.
- * @see #computeResiduals()
+ * @see #getResiduals()
*/
- double computeCost();
+ double getCost();
/**
- * Computes the weighted residuals. The residual is the difference
between the
+ * Get the weighted residuals. The residual is the difference between
the
* observed (target) values and the model (objective function) value.
There is one
* residual for each element of the vector-valued function. The raw
residuals are
* then multiplied by the square root of the weight matrix.
@@ -151,7 +151,7 @@ public interface LeastSquaresProblem ext
* @throws
org.apache.commons.math3.exception.DimensionMismatchException
* if the residuals have the wrong length.
*/
- RealVector computeResiduals();
+ RealVector getResiduals();
/**
* Get the abscissa (independent variables) of this evaluation.
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblemImpl.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblemImpl.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblemImpl.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LeastSquaresProblemImpl.java
Thu Feb 20 14:35:14 2014
@@ -125,12 +125,12 @@ class LeastSquaresProblemImpl
}
/** {@inheritDoc} */
- public RealVector computeValue() {
+ public RealVector getValue() {
return this.values;
}
/** {@inheritDoc} */
- public RealMatrix computeJacobian() {
+ public RealMatrix getJacobian() {
return this.jacobian;
}
@@ -140,8 +140,8 @@ class LeastSquaresProblemImpl
}
/** {@inheritDoc} */
- public RealVector computeResiduals() {
- return target.subtract(this.computeValue());
+ public RealVector getResiduals() {
+ return target.subtract(this.getValue());
}
}
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizer.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizer.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizer.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizer.java
Thu Feb 20 14:35:14 2014
@@ -329,8 +329,8 @@ public class LevenbergMarquardtOptimizer
evaluationCounter.incrementCount();
//value will be reassigned in the loop
Evaluation current = problem.evaluate(new
ArrayRealVector(currentPoint, false));
- double[] currentResiduals = current.computeResiduals().toArray();
- double currentCost = current.computeCost();
+ double[] currentResiduals = current.getResiduals().toArray();
+ double currentCost = current.getCost();
// Outer loop.
boolean firstIteration = true;
@@ -341,7 +341,7 @@ public class LevenbergMarquardtOptimizer
// QR decomposition of the jacobian matrix
final InternalData internalData
- = qrDecomposition(current.computeJacobian(), solvedCols);
+ = qrDecomposition(current.getJacobian(), solvedCols);
final double[][] weightedJacobian = internalData.weightedJacobian;
final int[] permutation = internalData.permutation;
final double[] diagR = internalData.diagR;
@@ -446,8 +446,8 @@ public class LevenbergMarquardtOptimizer
// Evaluate the function at x + p and calculate its norm.
evaluationCounter.incrementCount();
current = problem.evaluate(new
ArrayRealVector(currentPoint,false));
- currentResiduals = current.computeResiduals().toArray();
- currentCost = current.computeCost();
+ currentResiduals = current.getResiduals().toArray();
+ currentCost = current.getCost();
// compute the scaled actual reduction
double actRed = -1.0;
Modified:
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/OptimumImpl.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/OptimumImpl.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/OptimumImpl.java
(original)
+++
commons/proper/math/trunk/src/main/java/org/apache/commons/math3/fitting/leastsquares/OptimumImpl.java
Thu Feb 20 14:35:14 2014
@@ -62,38 +62,38 @@ class OptimumImpl implements Optimum {
}
/** {@inheritDoc} */
- public RealMatrix computeCovariances(double threshold) {
- return value.computeCovariances(threshold);
+ public RealMatrix getCovariances(double threshold) {
+ return value.getCovariances(threshold);
}
/** {@inheritDoc} */
- public RealVector computeSigma(double covarianceSingularityThreshold) {
- return value.computeSigma(covarianceSingularityThreshold);
+ public RealVector getSigma(double covarianceSingularityThreshold) {
+ return value.getSigma(covarianceSingularityThreshold);
}
/** {@inheritDoc} */
- public double computeRMS() {
- return value.computeRMS();
+ public double getRMS() {
+ return value.getRMS();
}
/** {@inheritDoc} */
- public RealVector computeValue() {
- return value.computeValue();
+ public RealVector getValue() {
+ return value.getValue();
}
/** {@inheritDoc} */
- public RealMatrix computeJacobian() {
- return value.computeJacobian();
+ public RealMatrix getJacobian() {
+ return value.getJacobian();
}
/** {@inheritDoc} */
- public double computeCost() {
- return value.computeCost();
+ public double getCost() {
+ return value.getCost();
}
/** {@inheritDoc} */
- public RealVector computeResiduals() {
- return value.computeResiduals();
+ public RealVector getResiduals() {
+ return value.getResiduals();
}
/** {@inheritDoc} */
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/AbstractLeastSquaresOptimizerAbstractTest.java
Thu Feb 20 14:35:14 2014
@@ -154,9 +154,9 @@ public abstract class AbstractLeastSquar
Optimum optimum = optimizer.optimize(ls);
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
assertEquals(TOl, optimum.getPoint(), 1.5);
- Assert.assertEquals(3.0, optimum.computeValue().getEntry(0), TOl);
+ Assert.assertEquals(3.0, optimum.getValue().getEntry(0), TOl);
}
@Test
@@ -167,9 +167,9 @@ public abstract class AbstractLeastSquar
Optimum optimum = optimizer.optimize(problem.getBuilder().build());
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
assertEquals(TOl, optimum.getPoint(), 7, 3);
- assertEquals(TOl, optimum.computeValue(), 4, 6, 1);
+ assertEquals(TOl, optimum.getValue(), 4, 6, 1);
}
@Test
@@ -185,7 +185,7 @@ public abstract class AbstractLeastSquar
Optimum optimum = optimizer.optimize(problem.getBuilder().build());
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
for (int i = 0; i < problem.target.length; ++i) {
Assert.assertEquals(0.55 * i, optimum.getPoint().getEntry(i), TOl);
}
@@ -201,7 +201,7 @@ public abstract class AbstractLeastSquar
Optimum optimum = optimizer.optimize(problem.getBuilder().build());
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
assertEquals(TOl, optimum.getPoint(), 1, 2, 3);
}
@@ -219,7 +219,7 @@ public abstract class AbstractLeastSquar
Optimum optimum = optimizer.optimize(problem.getBuilder().build());
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
assertEquals(TOl, optimum.getPoint(), 3, 4, -1, -2, 1 + epsilon, 1 -
epsilon);
}
@@ -253,7 +253,7 @@ public abstract class AbstractLeastSquar
Optimum optimum = optimizer
.optimize(problem1.getBuilder().start(start).build());
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
assertEquals(TOl, optimum.getPoint(), 1, 1, 1, 1);
LinearProblem problem2 = new LinearProblem(new double[][]{
@@ -265,7 +265,7 @@ public abstract class AbstractLeastSquar
optimum =
optimizer.optimize(problem2.getBuilder().start(start).build());
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
assertEquals(1e-8, optimum.getPoint(), -81, 137, -34, 22);
}
@@ -280,7 +280,7 @@ public abstract class AbstractLeastSquar
Optimum optimum = optimizer
.optimize(problem.getBuilder().start(new double[]{7, 6, 5,
4}).build());
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
}
@Test
@@ -296,7 +296,7 @@ public abstract class AbstractLeastSquar
Optimum optimum = optimizer.optimize(
problem.getBuilder().start(new double[]{2, 2, 2, 2, 2,
2}).build());
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
//TODO the first two elements of point were not previously checked
assertEquals(TOl, optimum.getPoint(), 2, 1, 3, 4, 5, 6);
}
@@ -312,7 +312,7 @@ public abstract class AbstractLeastSquar
Optimum optimum = optimizer
.optimize(problem.getBuilder().start(new double[]{1,
1}).build());
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
assertEquals(TOl, optimum.getPoint(), 2, 1);
}
@@ -328,7 +328,7 @@ public abstract class AbstractLeastSquar
.optimize(problem.getBuilder().start(new double[]{1,
1}).build());
//TODO what is this actually testing?
- Assert.assertTrue(optimum.computeRMS() > 0.1);
+ Assert.assertTrue(optimum.getRMS() > 0.1);
}
@Test
@@ -342,7 +342,7 @@ public abstract class AbstractLeastSquar
//TODO why is this part here? hasn't it been tested already?
Optimum optimum = optimizer.optimize(problem.getBuilder().build());
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
assertEquals(TOl, optimum.getPoint(), -1, 1);
//TODO move to builder test
@@ -364,7 +364,7 @@ public abstract class AbstractLeastSquar
Optimum optimum = optimizer.optimize(problem.getBuilder().build());
- Assert.assertEquals(0, optimum.computeRMS(), TOl);
+ Assert.assertEquals(0, optimum.getRMS(), TOl);
assertEquals(TOl, optimum.getPoint(), -1, 1);
//TODO move to builder test
@@ -395,7 +395,7 @@ public abstract class AbstractLeastSquar
Assert.assertTrue(optimum.getEvaluations() < 10);
- double rms = optimum.computeRMS();
+ double rms = optimum.getRMS();
Assert.assertEquals(1.768262623567235, FastMath.sqrt(circle.getN()) *
rms, TOl);
Vector2D center = new Vector2D(optimum.getPoint().getEntry(0),
optimum.getPoint().getEntry(1));
@@ -403,7 +403,7 @@ public abstract class AbstractLeastSquar
Assert.assertEquals(96.07590211815305, center.getX(), 1e-6);
Assert.assertEquals(48.13516790438953, center.getY(), 1e-6);
- double[][] cov = optimum.computeCovariances(1e-14).getData();
+ double[][] cov = optimum.getCovariances(1e-14).getData();
Assert.assertEquals(1.839, cov[0][0], 0.001);
Assert.assertEquals(0.731, cov[0][1], 0.001);
Assert.assertEquals(cov[0][1], cov[1][0], 1e-14);
@@ -421,7 +421,7 @@ public abstract class AbstractLeastSquar
optimum = optimizer.optimize(
builder(circle).weight(new
DiagonalMatrix(weights)).start(start).build());
- cov = optimum.computeCovariances(1e-14).getData();
+ cov = optimum.getCovariances(1e-14).getData();
Assert.assertEquals(0.0016, cov[0][0], 0.001);
Assert.assertEquals(3.2e-7, cov[0][1], 1e-9);
Assert.assertEquals(cov[0][1], cov[1][0], 1e-14);
@@ -443,7 +443,7 @@ public abstract class AbstractLeastSquar
Vector2D center = new Vector2D(optimum.getPoint().getEntry(0),
optimum.getPoint().getEntry(1));
Assert.assertTrue(optimum.getEvaluations() < 25);
- Assert.assertEquals(0.043, optimum.computeRMS(), 1e-3);
+ Assert.assertEquals(0.043, optimum.getRMS(), 1e-3);
Assert.assertEquals(0.292235, circle.getRadius(center), 1e-6);
Assert.assertEquals(-0.151738, center.getX(), 1e-6);
Assert.assertEquals(0.2075001, center.getY(), 1e-6);
@@ -464,7 +464,7 @@ public abstract class AbstractLeastSquar
builder(circle).weight(new
DiagonalMatrix(weights)).start(start).build());
assertEquals(1e-6, optimum.getPoint(), -0.1517383071957963,
0.2074999736353867);
- Assert.assertEquals(0.04268731682389561, optimum.computeRMS(), 1e-8);
+ Assert.assertEquals(0.04268731682389561, optimum.getRMS(), 1e-8);
}
private final double[][] circlePoints = new double[][]{
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/EvaluationTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/EvaluationTest.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/EvaluationTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/EvaluationTest.java
Thu Feb 20 14:35:14 2014
@@ -78,7 +78,7 @@ public class EvaluationTest {
//action + verify
Assert.assertArrayEquals(
- evaluation.computeResiduals().toArray(),
+ evaluation.getResiduals().toArray(),
new double[]{2, -3},
Precision.EPSILON);
}
@@ -104,14 +104,14 @@ public class EvaluationTest {
//action
TestUtils.assertEquals(
"covariance",
- evaluation.computeCovariances(FastMath.nextAfter(1e-4, 0.0)),
+ evaluation.getCovariances(FastMath.nextAfter(1e-4, 0.0)),
MatrixUtils.createRealMatrix(new double[][]{{1, 0}, {0, 1e4}}),
Precision.EPSILON
);
//singularity fail
try {
- evaluation.computeCovariances(FastMath.nextAfter(1e-4, 1.0));
+ evaluation.getCovariances(FastMath.nextAfter(1e-4, 1.0));
Assert.fail("Expected Exception");
} catch (SingularMatrixException e) {
//expected
@@ -141,8 +141,8 @@ public class EvaluationTest {
.evaluate(point);
//action
- RealVector value = evaluation.computeValue();
- RealMatrix jacobian = evaluation.computeJacobian();
+ RealVector value = evaluation.getValue();
+ RealMatrix jacobian = evaluation.getJacobian();
//verify
Assert.assertArrayEquals(evaluation.getPoint().toArray(),
point.toArray(), 0);
@@ -162,7 +162,7 @@ public class EvaluationTest {
final LeastSquaresProblem lsp = builder(dataset).build();
final double expected = dataset.getResidualSumOfSquares();
- final double cost = lsp.evaluate(lsp.getStart()).computeCost();
+ final double cost = lsp.evaluate(lsp.getStart()).getCost();
final double actual = cost * cost;
Assert.assertEquals(dataset.getName(), expected, actual, 1e-11 *
expected);
}
@@ -176,7 +176,7 @@ public class EvaluationTest {
final double expected =
FastMath.sqrt(dataset.getResidualSumOfSquares() /
dataset.getNumObservations());
- final double actual = lsp.evaluate(lsp.getStart()).computeRMS();
+ final double actual = lsp.evaluate(lsp.getStart()).getRMS();
Assert.assertEquals(dataset.getName(), expected, actual, 1e-11 *
expected);
}
@@ -190,8 +190,8 @@ public class EvaluationTest {
final double[] expected = dataset.getParametersStandardDeviations();
final Evaluation evaluation = lsp.evaluate(lsp.getStart());
- final double cost = evaluation.computeCost();
- final RealVector sig = evaluation.computeSigma(1e-14);
+ final double cost = evaluation.getCost();
+ final RealVector sig = evaluation.getSigma(1e-14);
final int dof = lsp.getObservationSize() - lsp.getParameterSize();
for (int i = 0; i < sig.getDimension(); i++) {
final double actual = FastMath.sqrt(cost * cost / dof) *
sig.getEntry(i);
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/EvaluationTestValidation.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/EvaluationTestValidation.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/EvaluationTestValidation.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/EvaluationTestValidation.java
Thu Feb 20 14:35:14 2014
@@ -118,7 +118,7 @@ public class EvaluationTestValidation {
// covariance matrix).
final LeastSquaresProblem lsp = builder(problem).build();
- final RealVector sigma = lsp.evaluate(init).computeSigma(1e-14);
+ final RealVector sigma = lsp.evaluate(init).getSigma(1e-14);
// Accumulate statistics.
for (int i = 0; i < numParams; i++) {
@@ -222,7 +222,7 @@ public class EvaluationTestValidation {
// Get chi-square of the best parameters set for the given set of
// observations.
final double bestChi2N = getChi2N(lsp, regress);
- final RealVector sigma = lsp.evaluate(regress).computeSigma(1e-14);
+ final RealVector sigma = lsp.evaluate(regress).getSigma(1e-14);
// Monte-Carlo (generates a grid of parameters).
final int mcRepeat = MONTE_CARLO_RUNS;
@@ -299,7 +299,7 @@ public class EvaluationTestValidation {
*/
private double getChi2N(LeastSquaresProblem lsp,
RealVector params) {
- final double cost = lsp.evaluate(params).computeCost();
+ final double cost = lsp.evaluate(params).getCost();
return cost * cost / (lsp.getObservationSize() -
params.getDimension());
}
}
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/LevenbergMarquardtOptimizerTest.java
Thu Feb 20 14:35:14 2014
@@ -87,9 +87,9 @@ public class LevenbergMarquardtOptimizer
problem.getBuilder().maxIterations(20).build());
//TODO check that it is a bad fit? Why the extra conditions?
- Assert.assertTrue(FastMath.sqrt(problem.getTarget().length) *
optimum.computeRMS() > 0.6);
+ Assert.assertTrue(FastMath.sqrt(problem.getTarget().length) *
optimum.getRMS() > 0.6);
- optimum.computeCovariances(1.5e-14);
+ optimum.getCovariances(1.5e-14);
fail(optimizer);
}catch (SingularMatrixException e){
@@ -198,7 +198,7 @@ public class LevenbergMarquardtOptimizer
final RealVector solution = optimum.getPoint();
final double[] expectedSolution = { 10.4, 958.3, 131.4, 33.9, 205.0 };
- final RealMatrix covarMatrix = optimum.computeCovariances(1e-14);
+ final RealMatrix covarMatrix = optimum.getCovariances(1e-14);
final double[][] expectedCovarMatrix = {
{ 3.38, -3.69, 27.98, -2.34, -49.24 },
{ -3.69, 2492.26, 81.89, -69.21, -8.9 },
@@ -256,7 +256,7 @@ public class LevenbergMarquardtOptimizer
final double[] paramFound = optimum.getPoint().toArray();
// Retrieve errors estimation.
- final double[] asymptoticStandardErrorFound =
optimum.computeSigma(1e-14).toArray();
+ final double[] asymptoticStandardErrorFound =
optimum.getSigma(1e-14).toArray();
// Check that the parameters are found within the assumed error bars.
Assert.assertEquals(xCenter, paramFound[0],
asymptoticStandardErrorFound[0]);
Modified:
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/MinpackTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/MinpackTest.java?rev=1570206&r1=1570205&r2=1570206&view=diff
==============================================================================
---
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/MinpackTest.java
(original)
+++
commons/proper/math/trunk/src/test/java/org/apache/commons/math3/fitting/leastsquares/MinpackTest.java
Thu Feb 20 14:35:14 2014
@@ -516,7 +516,7 @@ public class MinpackTest {
try {
final Optimum optimum = optimizer.optimize(problem);
Assert.assertFalse(exceptionExpected);
- function.checkTheoreticalMinCost(optimum.computeRMS());
+ function.checkTheoreticalMinCost(optimum.getRMS());
function.checkTheoreticalMinParams(optimum.getPoint().toArray());
} catch (TooManyEvaluationsException e) {
Assert.assertTrue(exceptionExpected);