You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2009/09/05 19:37:05 UTC
svn commit: r811685 [16/24] - in /commons/proper/math/trunk: ./
src/main/java/org/apache/commons/math/
src/main/java/org/apache/commons/math/analysis/
src/main/java/org/apache/commons/math/analysis/integration/
src/main/java/org/apache/commons/math/ana...
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/BinomialDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/BinomialDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/BinomialDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/BinomialDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,11 +20,11 @@
* Test cases for BinomialDistribution.
* Extends IntegerDistributionAbstractTest. See class javadoc for
* IntegerDistributionAbstractTest for details.
- *
+ *
* @version $Revision$ $Date$
*/
public class BinomialDistributionTest extends IntegerDistributionAbstractTest {
-
+
/**
* Constructor for BinomialDistributionTest.
* @param name
@@ -32,48 +32,48 @@
public BinomialDistributionTest(String name) {
super(name);
}
-
+
//-------------- Implementations for abstract methods -----------------------
-
+
/** Creates the default discrete distribution instance to use in tests. */
@Override
public IntegerDistribution makeDistribution() {
return new BinomialDistributionImpl(10,0.70);
}
-
+
/** Creates the default probability density test input values */
@Override
public int[] makeDensityTestPoints() {
return new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
}
-
+
/** Creates the default probability density test expected values */
@Override
public double[] makeDensityTestValues() {
- return new double[] {0d, 0.0000d, 0.0001d, 0.0014d, 0.0090d, 0.0368d, 0.1029d,
+ return new double[] {0d, 0.0000d, 0.0001d, 0.0014d, 0.0090d, 0.0368d, 0.1029d,
0.2001d, 0.2668d, 0.2335d, 0.1211d, 0.0282d, 0d};
}
-
+
/** Creates the default cumulative probability density test input values */
@Override
public int[] makeCumulativeTestPoints() {
return makeDensityTestPoints();
}
-
+
/** Creates the default cumulative probability density test expected values */
@Override
public double[] makeCumulativeTestValues() {
return new double[] {0d, 0.0000d, 0.0001d, 0.0016d, 0.0106d, 0.0473d,
0.1503d, 0.3504d, 0.6172d, 0.8507d, 0.9718d, 1d, 1d};
}
-
+
/** Creates the default inverse cumulative probability test input values */
@Override
public double[] makeInverseCumulativeTestPoints() {
return new double[] {0, 0.001d, 0.010d, 0.025d, 0.050d, 0.100d, 0.999d,
- 0.990d, 0.975d, 0.950d, 0.900d,1};
+ 0.990d, 0.975d, 0.950d, 0.900d,1};
}
-
+
/** Creates the default inverse cumulative probability density test expected values */
@Override
public int[] makeInverseCumulativeTestValues() {
@@ -81,7 +81,7 @@
}
//----------------- Additional test cases ---------------------------------
-
+
/** Test degenerate case p = 0 */
public void testDegenerate0() throws Exception {
setDistribution(new BinomialDistributionImpl(5,0.0d));
@@ -93,9 +93,9 @@
setInverseCumulativeTestValues(new int[] {-1, -1});
verifyDensities();
verifyCumulativeProbabilities();
- verifyInverseCumulativeProbabilities();
+ verifyInverseCumulativeProbabilities();
}
-
+
/** Test degenerate case p = 1 */
public void testDegenerate1() throws Exception {
setDistribution(new BinomialDistributionImpl(5,1.0d));
@@ -107,7 +107,7 @@
setInverseCumulativeTestValues(new int[] {4, 4});
verifyDensities();
verifyCumulativeProbabilities();
- verifyInverseCumulativeProbabilities();
+ verifyInverseCumulativeProbabilities();
}
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -21,11 +21,11 @@
* Test cases for CauchyDistribution.
* Extends ContinuousDistributionAbstractTest. See class javadoc for
* ContinuousDistributionAbstractTest for details.
- *
+ *
* @version $Revision$ $Date$
*/
public class CauchyDistributionTest extends ContinuousDistributionAbstractTest {
-
+
/**
* Constructor for CauchyDistributionTest.
* @param arg0
@@ -33,54 +33,54 @@
public CauchyDistributionTest(String arg0) {
super(arg0);
}
-
+
//-------------- Implementations for abstract methods -----------------------
-
+
/** Creates the default continuous distribution instance to use in tests. */
@Override
public ContinuousDistribution makeDistribution() {
return new CauchyDistributionImpl(1.2, 2.1);
- }
-
+ }
+
/** Creates the default cumulative probability distribution test input values */
@Override
public double[] makeCumulativeTestPoints() {
- // quantiles computed using Mathematica
+ // quantiles computed using Mathematica
return new double[] {-667.2485619d, -65.6230835d, -25.48302995d,
-12.05887818d, -5.263135428d, 7.663135428d, 14.45887818d,
27.88302995d, 68.0230835d, 669.6485619d};
}
-
+
/** Creates the default cumulative probability density test expected values */
@Override
public double[] makeCumulativeTestValues() {
return new double[] {0.001d, 0.01d, 0.025d, 0.05d, 0.1d, 0.900d, 0.950d,
0.975d, 0.990d, 0.999d};
}
-
+
//---------------------------- Additional test cases -------------------------
-
+
public void testInverseCumulativeProbabilityExtremes() throws Exception {
setInverseCumulativeTestPoints(new double[] {0.0, 1.0});
setInverseCumulativeTestValues(
new double[] {Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY});
verifyInverseCumulativeProbabilities();
}
-
+
public void testMedian() {
CauchyDistribution distribution = (CauchyDistribution) getDistribution();
double expected = Math.random();
distribution.setMedian(expected);
assertEquals(expected, distribution.getMedian(), 0.0);
}
-
+
public void testScale() {
CauchyDistribution distribution = (CauchyDistribution) getDistribution();
double expected = Math.random();
distribution.setScale(expected);
assertEquals(expected, distribution.getScale(), 0.0);
}
-
+
public void testSetScale() {
CauchyDistribution distribution = (CauchyDistribution) getDistribution();
try {
@@ -89,7 +89,7 @@
} catch (IllegalArgumentException ex) {
// success
}
-
+
try {
distribution.setScale(-1.0);
fail("Can not have negative scale.");
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ChiSquareDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ChiSquareDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ChiSquareDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ChiSquareDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,11 +21,11 @@
* Test cases for ChiSquareDistribution.
* Extends ContinuousDistributionAbstractTest. See class javadoc for
* ContinuousDistributionAbstractTest for details.
- *
+ *
* @version $Revision$ $Date$
*/
public class ChiSquareDistributionTest extends ContinuousDistributionAbstractTest {
-
+
/**
* Constructor for ChiSquareDistributionTest.
* @param name
@@ -33,45 +33,45 @@
public ChiSquareDistributionTest(String name) {
super(name);
}
-
+
//-------------- Implementations for abstract methods -----------------------
-
+
/** Creates the default continuous distribution instance to use in tests. */
@Override
public ContinuousDistribution makeDistribution() {
return new ChiSquaredDistributionImpl(5.0);
- }
-
+ }
+
/** Creates the default cumulative probability distribution test input values */
@Override
public double[] makeCumulativeTestPoints() {
// quantiles computed using R version 1.8.1 (linux version)
- return new double[] {0.210216d, 0.5542981d, 0.8312116d, 1.145476d, 1.610308d,
+ return new double[] {0.210216d, 0.5542981d, 0.8312116d, 1.145476d, 1.610308d,
20.51501d, 15.08627d, 12.83250d, 11.07050d, 9.236357d};
}
-
+
/** Creates the default cumulative probability density test expected values */
@Override
public double[] makeCumulativeTestValues() {
return new double[] {0.001d, 0.01d, 0.025d, 0.05d, 0.1d, 0.999d,
- 0.990d, 0.975d, 0.950d, 0.900d};
+ 0.990d, 0.975d, 0.950d, 0.900d};
}
-
+
/** Creates the default inverse cumulative probability test input values */
@Override
public double[] makeInverseCumulativeTestPoints() {
return new double[] {0, 0.001d, 0.01d, 0.025d, 0.05d, 0.1d, 0.999d,
- 0.990d, 0.975d, 0.950d, 0.900d, 1};
+ 0.990d, 0.975d, 0.950d, 0.900d, 1};
}
-
+
/** Creates the default inverse cumulative probability density test expected values */
@Override
public double[] makeInverseCumulativeTestValues() {
- return new double[] {0, 0.210216d, 0.5542981d, 0.8312116d, 1.145476d, 1.610308d,
- 20.51501d, 15.08627d, 12.83250d, 11.07050d, 9.236357d,
+ return new double[] {0, 0.210216d, 0.5542981d, 0.8312116d, 1.145476d, 1.610308d,
+ 20.51501d, 15.08627d, 12.83250d, 11.07050d, 9.236357d,
Double.POSITIVE_INFINITY};
}
-
+
// --------------------- Override tolerance --------------
@Override
protected void setUp() throws Exception {
@@ -80,20 +80,20 @@
}
//---------------------------- Additional test cases -------------------------
-
+
public void testSmallDf() throws Exception {
setDistribution(new ChiSquaredDistributionImpl(0.1d));
setTolerance(1E-4);
// quantiles computed using R version 1.8.1 (linux version)
- setCumulativeTestPoints(new double[] {1.168926E-60, 1.168926E-40, 1.063132E-32,
- 1.144775E-26, 1.168926E-20, 5.472917, 2.175255, 1.13438,
+ setCumulativeTestPoints(new double[] {1.168926E-60, 1.168926E-40, 1.063132E-32,
+ 1.144775E-26, 1.168926E-20, 5.472917, 2.175255, 1.13438,
0.5318646, 0.1526342});
setInverseCumulativeTestValues(getCumulativeTestPoints());
setInverseCumulativeTestPoints(getCumulativeTestValues());
verifyCumulativeProbabilities();
verifyInverseCumulativeProbabilities();
}
-
+
public void testDfAccessors() {
ChiSquaredDistribution distribution = (ChiSquaredDistribution) getDistribution();
assertEquals(5d, distribution.getDegreesOfFreedom(), Double.MIN_VALUE);
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ContinuousDistributionAbstractTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,7 +39,7 @@
* <p>
* To implement additional test cases with different distribution instances and
* test data, use the setXxx methods for the instance data in test cases and
- * call the verifyXxx methods to verify results.
+ * call the verifyXxx methods to verify results.
* <p>
* Error tolerance can be overriden by implementing getTolerance().
* <p>
@@ -50,32 +50,32 @@
* <p>
* See {@link NormalDistributionTest} and {@link ChiSquareDistributionTest}
* for examples.
- *
+ *
* @version $Revision$ $Date$
*/
public abstract class ContinuousDistributionAbstractTest extends TestCase {
-
+
//-------------------- Private test instance data -------------------------
/** Distribution instance used to perform tests */
private ContinuousDistribution distribution;
-
+
/** Tolerance used in comparing expected and returned values */
private double tolerance = 1E-4;
-
+
/** Arguments used to test cumulative probability density calculations */
private double[] cumulativeTestPoints;
-
+
/** Values used to test cumulative probability density calculations */
private double[] cumulativeTestValues;
-
+
/** Arguments used to test inverse cumulative probability density calculations */
private double[] inverseCumulativeTestPoints;
-
+
/** Values used to test inverse cumulative probability density calculations */
private double[] inverseCumulativeTestValues;
-
+
//-------------------------------------------------------------------------
-
+
/**
* Constructor for ContinuousDistributionAbstractTest.
* @param name
@@ -83,34 +83,34 @@
public ContinuousDistributionAbstractTest(String name) {
super(name);
}
-
+
//-------------------- Abstract methods -----------------------------------
-
+
/** Creates the default continuous distribution instance to use in tests. */
public abstract ContinuousDistribution makeDistribution();
-
+
/** Creates the default cumulative probability density test input values */
public abstract double[] makeCumulativeTestPoints();
-
+
/** Creates the default cumulative probability density test expected values */
public abstract double[] makeCumulativeTestValues();
-
+
//---- Default implementations of inverse test data generation methods ----
-
+
/** Creates the default inverse cumulative probability test input values */
public double[] makeInverseCumulativeTestPoints() {
return makeCumulativeTestValues();
}
-
+
/** Creates the default inverse cumulative probability density test expected values */
public double[] makeInverseCumulativeTestValues() {
return makeCumulativeTestPoints();
}
-
+
//-------------------- Setup / tear down ----------------------------------
-
+
/**
- * Setup sets all test instance data to default values
+ * Setup sets all test instance data to default values
*/
@Override
protected void setUp() throws Exception {
@@ -119,90 +119,90 @@
cumulativeTestPoints = makeCumulativeTestPoints();
cumulativeTestValues = makeCumulativeTestValues();
inverseCumulativeTestPoints = makeInverseCumulativeTestPoints();
- inverseCumulativeTestValues = makeInverseCumulativeTestValues();
+ inverseCumulativeTestValues = makeInverseCumulativeTestValues();
}
-
+
/**
* Cleans up test instance data
*/
@Override
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception {
super.tearDown();
distribution = null;
cumulativeTestPoints = null;
cumulativeTestValues = null;
inverseCumulativeTestPoints = null;
- inverseCumulativeTestValues = null;
+ inverseCumulativeTestValues = null;
}
-
+
//-------------------- Verification methods -------------------------------
-
+
/**
* Verifies that cumulative probability density calculations match expected values
* using current test instance data
- */
+ */
protected void verifyCumulativeProbabilities() throws Exception {
for (int i = 0; i < cumulativeTestPoints.length; i++) {
- TestUtils.assertEquals("Incorrect cumulative probability value returned for "
- + cumulativeTestPoints[i], cumulativeTestValues[i],
- distribution.cumulativeProbability(cumulativeTestPoints[i]),
+ TestUtils.assertEquals("Incorrect cumulative probability value returned for "
+ + cumulativeTestPoints[i], cumulativeTestValues[i],
+ distribution.cumulativeProbability(cumulativeTestPoints[i]),
getTolerance());
- }
+ }
}
-
+
/**
* Verifies that inverse cumulative probability density calculations match expected values
* using current test instance data
*/
protected void verifyInverseCumulativeProbabilities() throws Exception {
for (int i = 0; i < inverseCumulativeTestPoints.length; i++) {
- TestUtils.assertEquals("Incorrect inverse cumulative probability value returned for "
- + inverseCumulativeTestPoints[i], inverseCumulativeTestValues[i],
- distribution.inverseCumulativeProbability(inverseCumulativeTestPoints[i]),
+ TestUtils.assertEquals("Incorrect inverse cumulative probability value returned for "
+ + inverseCumulativeTestPoints[i], inverseCumulativeTestValues[i],
+ distribution.inverseCumulativeProbability(inverseCumulativeTestPoints[i]),
getTolerance());
- }
+ }
}
-
+
//------------------------ Default test cases -----------------------------
-
+
/**
* Verifies that cumulative probability density calculations match expected values
* using default test instance data
*/
public void testCumulativeProbabilities() throws Exception {
- verifyCumulativeProbabilities();
+ verifyCumulativeProbabilities();
}
-
+
/**
* Verifies that inverse cumulative probability density calculations match expected values
* using default test instance data
*/
public void testInverseCumulativeProbabilities() throws Exception {
- verifyInverseCumulativeProbabilities();
+ verifyInverseCumulativeProbabilities();
}
-
+
/**
* Verifies that probability computations are consistent
*/
public void testConsistency() throws Exception {
for (int i=1; i < cumulativeTestPoints.length; i++) {
-
+
// check that cdf(x, x) = 0
- TestUtils.assertEquals(0d,
+ TestUtils.assertEquals(0d,
distribution.cumulativeProbability
(cumulativeTestPoints[i], cumulativeTestPoints[i]), tolerance);
-
+
// check that P(a < X < b) = P(X < b) - P(X < a)
double upper = Math.max(cumulativeTestPoints[i], cumulativeTestPoints[i -1]);
double lower = Math.min(cumulativeTestPoints[i], cumulativeTestPoints[i -1]);
- double diff = distribution.cumulativeProbability(upper) -
+ double diff = distribution.cumulativeProbability(upper) -
distribution.cumulativeProbability(lower);
double direct = distribution.cumulativeProbability(lower, upper);
- TestUtils.assertEquals("Inconsistent cumulative probabilities for ("
+ TestUtils.assertEquals("Inconsistent cumulative probabilities for ("
+ lower + "," + upper + ")", diff, direct, tolerance);
}
}
-
+
/**
* Verifies that illegal arguments are correctly handled
*/
@@ -224,9 +224,9 @@
fail("Expecting IllegalArgumentException for p = 2");
} catch (IllegalArgumentException ex) {
// expected
- }
+ }
}
-
+
//------------------ Getters / Setters for test instance data -----------
/**
* @return Returns the cumulativeTestPoints.
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +20,7 @@
* Test cases for ExponentialDistribution.
* Extends ContinuousDistributionAbstractTest. See class javadoc for
* ContinuousDistributionAbstractTest for details.
- *
+ *
* @version $Revision$ $Date$
*/
public class ExponentialDistributionTest extends ContinuousDistributionAbstractTest {
@@ -34,30 +34,30 @@
}
//-------------- Implementations for abstract methods -----------------------
-
+
/** Creates the default continuous distribution instance to use in tests. */
@Override
public ContinuousDistribution makeDistribution() {
return new ExponentialDistributionImpl(5.0);
- }
-
+ }
+
/** Creates the default cumulative probability distribution test input values */
@Override
public double[] makeCumulativeTestPoints() {
// quantiles computed using R version 1.8.1 (linux version)
- return new double[] {0.005002502d, 0.05025168d, 0.1265890d, 0.2564665d, 0.5268026d,
+ return new double[] {0.005002502d, 0.05025168d, 0.1265890d, 0.2564665d, 0.5268026d,
34.53878d, 23.02585d, 18.44440d, 14.97866d, 11.51293d};
}
-
+
/** Creates the default cumulative probability density test expected values */
@Override
public double[] makeCumulativeTestValues() {
return new double[] {0.001d, 0.01d, 0.025d, 0.05d, 0.1d, 0.999d,
- 0.990d, 0.975d, 0.950d, 0.900d};
+ 0.990d, 0.975d, 0.950d, 0.900d};
}
-
+
//------------ Additional tests -------------------------------------------
-
+
public void testCumulativeProbabilityExtremes() throws Exception {
setCumulativeTestPoints(new double[] {-2, 0});
setCumulativeTestValues(new double[] {0, 0});
@@ -91,7 +91,7 @@
// computed using print(dexp(2, rate=1/3), digits=10) in R 2.5
assertEquals(0.1711390397, d2.density(2.0), 1e-8);
}
-
+
public void testMeanAccessors() {
ExponentialDistribution distribution = (ExponentialDistribution) getDistribution();
assertEquals(5d, distribution.getMean(), Double.MIN_VALUE);
@@ -104,5 +104,5 @@
// expected
}
}
-
+
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/FDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/FDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/FDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/FDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,7 +21,7 @@
* Test cases for FDistribution.
* Extends ContinuousDistributionAbstractTest. See class javadoc for
* ContinuousDistributionAbstractTest for details.
- *
+ *
* @version $Revision$ $Date$
*/
public class FDistributionTest extends ContinuousDistributionAbstractTest {
@@ -35,29 +35,29 @@
}
//-------------- Implementations for abstract methods -----------------------
-
+
/** Creates the default continuous distribution instance to use in tests. */
@Override
public ContinuousDistribution makeDistribution() {
return new FDistributionImpl(5.0, 6.0);
- }
-
+ }
+
/** Creates the default cumulative probability distribution test input values */
@Override
public double[] makeCumulativeTestPoints() {
// quantiles computed using R version 1.8.1 (linux version)
return new double[] {0.03468084d ,0.09370091d, 0.1433137d,
- 0.2020084d, 0.2937283d, 20.80266d, 8.745895d, 5.987565d,
+ 0.2020084d, 0.2937283d, 20.80266d, 8.745895d, 5.987565d,
4.387374d, 3.107512d};
}
-
+
/** Creates the default cumulative probability density test expected values */
@Override
public double[] makeCumulativeTestValues() {
return new double[] {0.001d, 0.01d, 0.025d, 0.05d, 0.1d, 0.999d,
- 0.990d, 0.975d, 0.950d, 0.900d};
+ 0.990d, 0.975d, 0.950d, 0.900d};
}
-
+
// --------------------- Override tolerance --------------
@Override
protected void setUp() throws Exception {
@@ -78,7 +78,7 @@
setInverseCumulativeTestValues(new double[] {0, Double.POSITIVE_INFINITY});
verifyInverseCumulativeProbabilities();
}
-
+
public void testDfAccessors() {
FDistribution distribution = (FDistribution) getDistribution();
assertEquals(5d, distribution.getNumeratorDegreesOfFreedom(), Double.MIN_VALUE);
@@ -99,7 +99,7 @@
} catch (IllegalArgumentException ex) {
// expected
}
- }
+ }
public void testLargeDegreesOfFreedom() throws Exception {
org.apache.commons.math.distribution.FDistributionImpl fd =
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/GammaDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/GammaDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/GammaDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/GammaDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,11 +21,11 @@
* Test cases for GammaDistribution.
* Extends ContinuousDistributionAbstractTest. See class javadoc for
* ContinuousDistributionAbstractTest for details.
- *
+ *
* @version $Revision$ $Date$
*/
public class GammaDistributionTest extends ContinuousDistributionAbstractTest {
-
+
/**
* Constructor for GammaDistributionTest.
* @param name
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/HypergeometricDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/HypergeometricDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/HypergeometricDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/HypergeometricDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,7 +23,7 @@
* Test cases for HyperGeometriclDistribution.
* Extends IntegerDistributionAbstractTest. See class javadoc for
* IntegerDistributionAbstractTest for details.
- *
+ *
* @version $Revision$ $Date$
*/
public class HypergeometricDistributionTest extends IntegerDistributionAbstractTest {
@@ -37,54 +37,54 @@
}
//-------------- Implementations for abstract methods -----------------------
-
+
/** Creates the default discrete distribution instance to use in tests. */
@Override
public IntegerDistribution makeDistribution() {
return new HypergeometricDistributionImpl(10,5, 5);
}
-
+
/** Creates the default probability density test input values */
@Override
public int[] makeDensityTestPoints() {
return new int[] {-1, 0, 1, 2, 3, 4, 5, 10};
}
-
+
/** Creates the default probability density test expected values */
@Override
public double[] makeDensityTestValues() {
- return new double[] {0d, 0.003968d, 0.099206d, 0.396825d, 0.396825d,
+ return new double[] {0d, 0.003968d, 0.099206d, 0.396825d, 0.396825d,
0.099206d, 0.003968d, 0d};
}
-
+
/** Creates the default cumulative probability density test input values */
@Override
public int[] makeCumulativeTestPoints() {
return makeDensityTestPoints();
}
-
+
/** Creates the default cumulative probability density test expected values */
@Override
public double[] makeCumulativeTestValues() {
return new double[] {0d, .003968d, .103175d, .50000d, .896825d, .996032d,
1.00000d, 1d};
}
-
+
/** Creates the default inverse cumulative probability test input values */
@Override
public double[] makeInverseCumulativeTestPoints() {
return new double[] {0d, 0.001d, 0.010d, 0.025d, 0.050d, 0.100d, 0.999d,
- 0.990d, 0.975d, 0.950d, 0.900d, 1d};
+ 0.990d, 0.975d, 0.950d, 0.900d, 1d};
}
-
+
/** Creates the default inverse cumulative probability density test expected values */
@Override
public int[] makeInverseCumulativeTestValues() {
return new int[] {-1, -1, 0, 0, 0, 0, 4, 3, 3, 3, 3, 5};
}
-
+
//-------------------- Additional test cases ------------------------------
-
+
/** Verify that if there are no failures, mass is concentrated on sampleSize */
public void testDegenerateNoFailures() throws Exception {
setDistribution(new HypergeometricDistributionImpl(5,5,3));
@@ -96,9 +96,9 @@
setInverseCumulativeTestValues(new int[] {2, 2});
verifyDensities();
verifyCumulativeProbabilities();
- verifyInverseCumulativeProbabilities();
+ verifyInverseCumulativeProbabilities();
}
-
+
/** Verify that if there are no successes, mass is concentrated on 0 */
public void testDegenerateNoSuccesses() throws Exception {
setDistribution(new HypergeometricDistributionImpl(5,0,3));
@@ -110,9 +110,9 @@
setInverseCumulativeTestValues(new int[] {-1, -1});
verifyDensities();
verifyCumulativeProbabilities();
- verifyInverseCumulativeProbabilities();
+ verifyInverseCumulativeProbabilities();
}
-
+
/** Verify that if sampleSize = populationSize, mass is concentrated on numberOfSuccesses */
public void testDegenerateFullSample() throws Exception {
setDistribution(new HypergeometricDistributionImpl(5,3,5));
@@ -124,7 +124,7 @@
setInverseCumulativeTestValues(new int[] {2, 2});
verifyDensities();
verifyCumulativeProbabilities();
- verifyInverseCumulativeProbabilities();
+ verifyInverseCumulativeProbabilities();
}
public void testPopulationSize() {
@@ -134,11 +134,11 @@
fail("negative population size. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
-
+
dist.setPopulationSize(10);
assertEquals(10, dist.getPopulationSize());
}
-
+
public void testLargeValues() {
int populationSize = 3456;
int sampleSize = 789;
@@ -150,20 +150,20 @@
{3.0, 1.32724172984193e-8, 1.46736255879763e-8, 0.999999998598792},
{4.0, 9.94501711734089e-8, 1.14123796761385e-7, 0.999999985326375},
{5.0, 5.89080768883643e-7, 7.03204565645028e-7, 0.999999885876203},
- {20.0, 0.0760051397707708, 0.27349758476299, 0.802507555007781},
- {21.0, 0.087144222047629, 0.360641806810619, 0.72650241523701},
- {22.0, 0.0940378846881819, 0.454679691498801, 0.639358193189381},
- {23.0, 0.0956897500614809, 0.550369441560282, 0.545320308501199},
- {24.0, 0.0919766921922999, 0.642346133752582, 0.449630558439718},
- {25.0, 0.083641637261095, 0.725987771013677, 0.357653866247418},
+ {20.0, 0.0760051397707708, 0.27349758476299, 0.802507555007781},
+ {21.0, 0.087144222047629, 0.360641806810619, 0.72650241523701},
+ {22.0, 0.0940378846881819, 0.454679691498801, 0.639358193189381},
+ {23.0, 0.0956897500614809, 0.550369441560282, 0.545320308501199},
+ {24.0, 0.0919766921922999, 0.642346133752582, 0.449630558439718},
+ {25.0, 0.083641637261095, 0.725987771013677, 0.357653866247418},
{96.0, 5.93849188852098e-57, 1.0, 6.01900244560712e-57},
- {97.0, 7.96593036832547e-59, 1.0, 8.05105570861321e-59},
+ {97.0, 7.96593036832547e-59, 1.0, 8.05105570861321e-59},
{98.0, 8.44582921934367e-61, 1.0, 8.5125340287733e-61},
- {99.0, 6.63604297068222e-63, 1.0, 6.670480942963e-63},
+ {99.0, 6.63604297068222e-63, 1.0, 6.670480942963e-63},
{100.0, 3.43501099007557e-65, 1.0, 3.4437972280786e-65},
{101.0, 8.78623800302957e-68, 1.0, 8.78623800302957e-68},
};
-
+
testHypergeometricDistributionProbabilities(populationSize, sampleSize, numberOfSucceses, data);
}
@@ -184,30 +184,30 @@
TestUtils.assertRelativelyEquals(cdf1, actualCdf1, 1.0e-9);
}
}
-
+
public void testMoreLargeValues() {
int populationSize = 26896;
int sampleSize = 895;
int numberOfSucceses = 55;
double[][] data = {
- {0.0, 0.155168304750504, 0.155168304750504, 1.0},
- {1.0, 0.29437545000746, 0.449543754757964, 0.844831695249496},
- {2.0, 0.273841321577003, 0.723385076334967, 0.550456245242036},
- {3.0, 0.166488572570786, 0.889873648905753, 0.276614923665033},
- {4.0, 0.0743969744713231, 0.964270623377076, 0.110126351094247},
- {5.0, 0.0260542785784855, 0.990324901955562, 0.0357293766229237},
- {20.0, 3.57101101678792e-16, 1.0, 3.78252101622096e-16},
- {21.0, 2.00551638598312e-17, 1.0, 2.11509999433041e-17},
- {22.0, 1.04317070180562e-18, 1.0, 1.09583608347287e-18},
- {23.0, 5.03153504903308e-20, 1.0, 5.266538166725e-20},
- {24.0, 2.2525984149695e-21, 1.0, 2.35003117691919e-21},
- {25.0, 9.3677424515947e-23, 1.0, 9.74327619496943e-23},
- {50.0, 9.83633962945521e-69, 1.0, 9.8677629437617e-69},
- {51.0, 3.13448949497553e-71, 1.0, 3.14233143064882e-71},
- {52.0, 7.82755221928122e-74, 1.0, 7.84193567329055e-74},
- {53.0, 1.43662126065532e-76, 1.0, 1.43834540093295e-76},
- {54.0, 1.72312692517348e-79, 1.0, 1.7241402776278e-79},
- {55.0, 1.01335245432581e-82, 1.0, 1.01335245432581e-82},
+ {0.0, 0.155168304750504, 0.155168304750504, 1.0},
+ {1.0, 0.29437545000746, 0.449543754757964, 0.844831695249496},
+ {2.0, 0.273841321577003, 0.723385076334967, 0.550456245242036},
+ {3.0, 0.166488572570786, 0.889873648905753, 0.276614923665033},
+ {4.0, 0.0743969744713231, 0.964270623377076, 0.110126351094247},
+ {5.0, 0.0260542785784855, 0.990324901955562, 0.0357293766229237},
+ {20.0, 3.57101101678792e-16, 1.0, 3.78252101622096e-16},
+ {21.0, 2.00551638598312e-17, 1.0, 2.11509999433041e-17},
+ {22.0, 1.04317070180562e-18, 1.0, 1.09583608347287e-18},
+ {23.0, 5.03153504903308e-20, 1.0, 5.266538166725e-20},
+ {24.0, 2.2525984149695e-21, 1.0, 2.35003117691919e-21},
+ {25.0, 9.3677424515947e-23, 1.0, 9.74327619496943e-23},
+ {50.0, 9.83633962945521e-69, 1.0, 9.8677629437617e-69},
+ {51.0, 3.13448949497553e-71, 1.0, 3.14233143064882e-71},
+ {52.0, 7.82755221928122e-74, 1.0, 7.84193567329055e-74},
+ {53.0, 1.43662126065532e-76, 1.0, 1.43834540093295e-76},
+ {54.0, 1.72312692517348e-79, 1.0, 1.7241402776278e-79},
+ {55.0, 1.01335245432581e-82, 1.0, 1.01335245432581e-82},
};
testHypergeometricDistributionProbabilities(populationSize, sampleSize, numberOfSucceses, data);
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/IntegerDistributionAbstractTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -22,9 +22,9 @@
* Abstract base class for {@link IntegerDistribution} tests.
* <p>
* To create a concrete test class for an integer distribution implementation,
- * implement makeDistribution() to return a distribution instance to use in
+ * implement makeDistribution() to return a distribution instance to use in
* tests and each of the test data generation methods below. In each case, the
- * test points and test values arrays returned represent parallel arrays of
+ * test points and test values arrays returned represent parallel arrays of
* inputs and expected values for the distribution returned by makeDistribution().
* <p>
* makeDensityTestPoints() -- arguments used to test probability density calculation
@@ -36,39 +36,39 @@
* <p>
* To implement additional test cases with different distribution instances and test data,
* use the setXxx methods for the instance data in test cases and call the verifyXxx methods
- * to verify results.
- *
+ * to verify results.
+ *
* @version $Revision$ $Date$
*/
public abstract class IntegerDistributionAbstractTest extends TestCase {
-
+
//-------------------- Private test instance data -------------------------
/** Discrete distribution instance used to perform tests */
private IntegerDistribution distribution;
-
+
/** Tolerance used in comparing expected and returned values */
private double tolerance = 1E-4;
-
+
/** Arguments used to test probability density calculations */
private int[] densityTestPoints;
-
+
/** Values used to test probability density calculations */
private double[] densityTestValues;
-
+
/** Arguments used to test cumulative probability density calculations */
private int[] cumulativeTestPoints;
-
+
/** Values used to test cumulative probability density calculations */
private double[] cumulativeTestValues;
-
+
/** Arguments used to test inverse cumulative probability density calculations */
private double[] inverseCumulativeTestPoints;
-
+
/** Values used to test inverse cumulative probability density calculations */
private int[] inverseCumulativeTestValues;
-
+
//-------------------------------------------------------------------------
-
+
/**
* Constructor for IntegerDistributionAbstractTest.
* @param name
@@ -76,34 +76,34 @@
public IntegerDistributionAbstractTest(String name) {
super(name);
}
-
+
//-------------------- Abstract methods -----------------------------------
-
+
/** Creates the default discrete distribution instance to use in tests. */
public abstract IntegerDistribution makeDistribution();
-
+
/** Creates the default probability density test input values */
public abstract int[] makeDensityTestPoints();
-
+
/** Creates the default probability density test expected values */
public abstract double[] makeDensityTestValues();
-
+
/** Creates the default cumulative probability density test input values */
public abstract int[] makeCumulativeTestPoints();
-
+
/** Creates the default cumulative probability density test expected values */
public abstract double[] makeCumulativeTestValues();
-
+
/** Creates the default inverse cumulative probability test input values */
public abstract double[] makeInverseCumulativeTestPoints();
-
+
/** Creates the default inverse cumulative probability density test expected values */
public abstract int[] makeInverseCumulativeTestValues();
-
+
//-------------------- Setup / tear down ----------------------------------
-
+
/**
- * Setup sets all test instance data to default values
+ * Setup sets all test instance data to default values
*/
@Override
protected void setUp() throws Exception {
@@ -114,14 +114,14 @@
cumulativeTestPoints = makeCumulativeTestPoints();
cumulativeTestValues = makeCumulativeTestValues();
inverseCumulativeTestPoints = makeInverseCumulativeTestPoints();
- inverseCumulativeTestValues = makeInverseCumulativeTestValues();
+ inverseCumulativeTestValues = makeInverseCumulativeTestValues();
}
-
+
/**
* Cleans up test instance data
*/
@Override
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception {
super.tearDown();
distribution = null;
densityTestPoints = null;
@@ -129,11 +129,11 @@
cumulativeTestPoints = null;
cumulativeTestValues = null;
inverseCumulativeTestPoints = null;
- inverseCumulativeTestValues = null;
+ inverseCumulativeTestValues = null;
}
-
+
//-------------------- Verification methods -------------------------------
-
+
/**
* Verifies that probability density calculations match expected values
* using current test instance data
@@ -141,36 +141,36 @@
protected void verifyDensities() throws Exception {
for (int i = 0; i < densityTestPoints.length; i++) {
assertEquals("Incorrect density value returned for " + densityTestPoints[i],
- densityTestValues[i],
+ densityTestValues[i],
distribution.probability(densityTestPoints[i]), tolerance);
- }
+ }
}
-
+
/**
* Verifies that cumulative probability density calculations match expected values
* using current test instance data
- */
+ */
protected void verifyCumulativeProbabilities() throws Exception {
for (int i = 0; i < cumulativeTestPoints.length; i++) {
assertEquals("Incorrect cumulative probability value returned for " + cumulativeTestPoints[i],
- cumulativeTestValues[i],
+ cumulativeTestValues[i],
distribution.cumulativeProbability(cumulativeTestPoints[i]), tolerance);
- }
+ }
}
-
-
+
+
/**
* Verifies that inverse cumulative probability density calculations match expected values
* using current test instance data
*/
protected void verifyInverseCumulativeProbabilities() throws Exception {
for (int i = 0; i < inverseCumulativeTestPoints.length; i++) {
- assertEquals("Incorrect inverse cumulative probability value returned for "
- + inverseCumulativeTestPoints[i], inverseCumulativeTestValues[i],
+ assertEquals("Incorrect inverse cumulative probability value returned for "
+ + inverseCumulativeTestPoints[i], inverseCumulativeTestValues[i],
distribution.inverseCumulativeProbability(inverseCumulativeTestPoints[i]));
- }
+ }
}
-
+
//------------------------ Default test cases -----------------------------
/**
@@ -178,17 +178,17 @@
* using default test instance data
*/
public void testDensities() throws Exception {
- verifyDensities();
+ verifyDensities();
}
-
+
/**
* Verifies that cumulative probability density calculations match expected values
* using default test instance data
*/
public void testCumulativeProbabilities() throws Exception {
- verifyCumulativeProbabilities();
+ verifyCumulativeProbabilities();
}
-
+
/**
* Verifies that floating point arguments are correctly handled by
* cumulativeProbablility(-,-)
@@ -200,7 +200,7 @@
assertEquals(
"Incorrect cumulative probability value returned for " +
cumulativeTestPoints[i],
- cumulativeTestValues[i],
+ cumulativeTestValues[i],
distribution.cumulativeProbability(arg), tolerance);
if (i < cumulativeTestPoints.length - 1) {
double arg2 = cumulativeTestPoints[i + 1];
@@ -219,33 +219,33 @@
cumulativeTestPoints[i + 1]),
distribution.cumulativeProbability(arg, arg2), tolerance);
}
- }
+ }
int one = 1;
int ten = 10;
int two = 2;
double oned = one;
double twod = two;
double tend = ten;
- assertEquals(distribution.cumulativeProbability(one, two),
+ assertEquals(distribution.cumulativeProbability(one, two),
distribution.cumulativeProbability(oned, twod), tolerance);
- assertEquals(distribution.cumulativeProbability(one, two),
+ assertEquals(distribution.cumulativeProbability(one, two),
distribution.cumulativeProbability(oned - tolerance,
twod + 0.9), tolerance);
- assertEquals(distribution.cumulativeProbability(two, ten),
+ assertEquals(distribution.cumulativeProbability(two, ten),
distribution.cumulativeProbability(twod, tend), tolerance);
- assertEquals(distribution.cumulativeProbability(two, ten),
+ assertEquals(distribution.cumulativeProbability(two, ten),
distribution.cumulativeProbability(twod - tolerance,
tend + 0.9), tolerance);
}
-
+
/**
* Verifies that inverse cumulative probability density calculations match expected values
* using default test instance data
*/
public void testInverseCumulativeProbabilities() throws Exception {
- verifyInverseCumulativeProbabilities();
+ verifyInverseCumulativeProbabilities();
}
-
+
/**
* Verifies that illegal arguments are correctly handled
*/
@@ -267,9 +267,9 @@
fail("Expecting IllegalArgumentException for p = 2");
} catch (IllegalArgumentException ex) {
// expected
- }
+ }
}
-
+
//------------------ Getters / Setters for test instance data -----------
/**
* @return Returns the cumulativeTestPoints.
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,11 +23,11 @@
* Test cases for NormalDistribution.
* Extends ContinuousDistributionAbstractTest. See class javadoc for
* ContinuousDistributionAbstractTest for details.
- *
+ *
* @version $Revision$ $Date$
*/
public class NormalDistributionTest extends ContinuousDistributionAbstractTest {
-
+
/**
* Constructor for NormalDistributionTest.
* @param arg0
@@ -35,52 +35,52 @@
public NormalDistributionTest(String arg0) {
super(arg0);
}
-
+
//-------------- Implementations for abstract methods -----------------------
-
+
/** Creates the default continuous distribution instance to use in tests. */
@Override
public ContinuousDistribution makeDistribution() {
return new NormalDistributionImpl(2.1, 1.4);
- }
-
+ }
+
/** Creates the default cumulative probability distribution test input values */
@Override
public double[] makeCumulativeTestPoints() {
- // quantiles computed using R
- return new double[] {-2.226325d, -1.156887d, -0.6439496d, -0.2027951d, 0.3058278d,
+ // quantiles computed using R
+ return new double[] {-2.226325d, -1.156887d, -0.6439496d, -0.2027951d, 0.3058278d,
6.426325d, 5.356887d, 4.84395d, 4.402795d, 3.894172d};
}
-
+
/** Creates the default cumulative probability density test expected values */
@Override
public double[] makeCumulativeTestValues() {
return new double[] {0.001d, 0.01d, 0.025d, 0.05d, 0.1d, 0.999d,
- 0.990d, 0.975d, 0.950d, 0.900d};
+ 0.990d, 0.975d, 0.950d, 0.900d};
}
-
+
// --------------------- Override tolerance --------------
@Override
protected void setUp() throws Exception {
super.setUp();
setTolerance(1E-6);
}
-
+
//---------------------------- Additional test cases -------------------------
-
+
private void verifyQuantiles() throws Exception {
NormalDistribution distribution = (NormalDistribution) getDistribution();
double mu = distribution.getMean();
double sigma = distribution.getStandardDeviation();
- setCumulativeTestPoints( new double[] {mu - 2 *sigma, mu - sigma,
+ setCumulativeTestPoints( new double[] {mu - 2 *sigma, mu - sigma,
mu, mu + sigma, mu +2 * sigma, mu +3 * sigma, mu + 4 * sigma,
mu + 5 * sigma});
// Quantiles computed using R (same as Mathematica)
- setCumulativeTestValues(new double[] {0.02275013, 0.1586553, 0.5, 0.8413447,
+ setCumulativeTestValues(new double[] {0.02275013, 0.1586553, 0.5, 0.8413447,
0.9772499, 0.9986501, 0.9999683, 0.9999997});
- verifyCumulativeProbabilities();
+ verifyCumulativeProbabilities();
}
-
+
public void testQuantiles() throws Exception {
verifyQuantiles();
setDistribution(new NormalDistributionImpl(0, 1));
@@ -88,31 +88,31 @@
setDistribution(new NormalDistributionImpl(0, 0.1));
verifyQuantiles();
}
-
+
public void testInverseCumulativeProbabilityExtremes() throws Exception {
setInverseCumulativeTestPoints(new double[] {0, 1});
setInverseCumulativeTestValues(
new double[] {Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY});
verifyInverseCumulativeProbabilities();
}
-
+
public void testGetMean() {
NormalDistribution distribution = (NormalDistribution) getDistribution();
assertEquals(2.1, distribution.getMean(), 0);
}
-
+
public void testSetMean() throws Exception {
double mu = Math.random();
NormalDistribution distribution = (NormalDistribution) getDistribution();
distribution.setMean(mu);
verifyQuantiles();
}
-
+
public void testGetStandardDeviation() {
NormalDistribution distribution = (NormalDistribution) getDistribution();
- assertEquals(1.4, distribution.getStandardDeviation(), 0);
+ assertEquals(1.4, distribution.getStandardDeviation(), 0);
}
-
+
public void testSetStandardDeviation() throws Exception {
double sigma = 0.1d + Math.random();
NormalDistribution distribution = (NormalDistribution) getDistribution();
@@ -131,7 +131,7 @@
double [] x = new double[]{-2, -1, 0, 1, 2};
// R 2.5: print(dnorm(c(-2,-1,0,1,2)), digits=10)
checkDensity(0, 1, x, new double[]{0.05399096651, 0.24197072452, 0.39894228040, 0.24197072452, 0.05399096651});
- // R 2.5: print(dnorm(c(-2,-1,0,1,2), mean=1.1), digits=10)
+ // R 2.5: print(dnorm(c(-2,-1,0,1,2), mean=1.1), digits=10)
checkDensity(1.1, 1, x, new double[]{0.003266819056,0.043983595980,0.217852177033,0.396952547477,0.266085249899});
}
@@ -161,7 +161,7 @@
assertTrue(lowerTail < 0.00001);
assertTrue(upperTail > 0.99999);
}
- }
+ }
}
public void testMath280() throws MathException {
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,11 +20,11 @@
* Test cases for PascalDistribution.
* Extends IntegerDistributionAbstractTest. See class javadoc for
* IntegerDistributionAbstractTest for details.
- *
+ *
* @version $Revision$ $Date$
*/
public class PascalDistributionTest extends IntegerDistributionAbstractTest {
-
+
/**
* Constructor for PascalDistributionTest.
* @param name
@@ -32,48 +32,48 @@
public PascalDistributionTest(String name) {
super(name);
}
-
+
//-------------- Implementations for abstract methods -----------------------
-
+
/** Creates the default discrete distribution instance to use in tests. */
@Override
public IntegerDistribution makeDistribution() {
return new PascalDistributionImpl(10,0.70);
}
-
+
/** Creates the default probability density test input values */
@Override
public int[] makeDensityTestPoints() {
return new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
}
-
+
/** Creates the default probability density test expected values */
@Override
public double[] makeDensityTestValues() {
- return new double[] {0d, 0.02824d, 0.08474d, 0.13982d,
+ return new double[] {0d, 0.02824d, 0.08474d, 0.13982d,
0.16779d, 0.16359d, 0.1374d, 0.10306d, 0.070673d, 0.04505d, 0.02703d, 0.01540d, 0.0084};
}
-
+
/** Creates the default cumulative probability density test input values */
@Override
public int[] makeCumulativeTestPoints() {
return makeDensityTestPoints();
}
-
+
/** Creates the default cumulative probability density test expected values */
@Override
public double[] makeCumulativeTestValues() {
return new double[] {0d, 0.02824d, 0.11299d, 0.25281d, 0.42060d, 0.58420d,
0.72162d, 0.82468d, 0.89535d, 0.94041d, 0.967446d, 0.98285, 0.99125d};
}
-
+
/** Creates the default inverse cumulative probability test input values */
@Override
public double[] makeInverseCumulativeTestPoints() {
return new double[] {0, 0.001d, 0.010d, 0.025d, 0.050d, 0.100d, 0.999d,
- 0.990d, 0.975d, 0.950d, 0.900d, 1};
+ 0.990d, 0.975d, 0.950d, 0.900d, 1};
}
-
+
/** Creates the default inverse cumulative probability density test expected values */
@Override
public int[] makeInverseCumulativeTestValues() {
@@ -81,7 +81,7 @@
}
//----------------- Additional test cases ---------------------------------
-
+
/** Test degenerate case p = 0 */
public void testDegenerate0() throws Exception {
setDistribution(new PascalDistributionImpl(5,0.0d));
@@ -93,9 +93,9 @@
setInverseCumulativeTestValues(new int[] {Integer.MAX_VALUE - 1, Integer.MAX_VALUE - 1});
verifyDensities();
verifyCumulativeProbabilities();
- verifyInverseCumulativeProbabilities();
+ verifyInverseCumulativeProbabilities();
}
-
+
/** Test degenerate case p = 1 */
public void testDegenerate1() throws Exception {
setDistribution(new PascalDistributionImpl(5,1.0d));
@@ -107,6 +107,6 @@
setInverseCumulativeTestValues(new int[] {-1, -1});
verifyDensities();
verifyCumulativeProbabilities();
- verifyInverseCumulativeProbabilities();
+ verifyInverseCumulativeProbabilities();
}
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +20,7 @@
/**
* <code>PoissonDistributionTest</code>
- *
+ *
* @version $Revision$ $Date$
*/
public class PoissonDistributionTest extends IntegerDistributionAbstractTest {
@@ -39,15 +39,15 @@
setTolerance(1e-12);
}
- /**
- * Creates the default discrete distribution instance to use in tests.
+ /**
+ * Creates the default discrete distribution instance to use in tests.
*/
@Override
public IntegerDistribution makeDistribution() {
- return new PoissonDistributionImpl(DEFAULT_TEST_POISSON_PARAMETER);
+ return new PoissonDistributionImpl(DEFAULT_TEST_POISSON_PARAMETER);
}
- /**
+ /**
* Creates the default probability density test input values.
*/
@Override
@@ -62,7 +62,7 @@
@Override
public double[] makeDensityTestValues() {
return new double[] { 0d, 0.0183156388887d, 0.073262555555d,
- 0.14652511111d, 0.195366814813d, 0.195366814813,
+ 0.14652511111d, 0.195366814813d, 0.195366814813,
0.156293451851d, 0.00529247667642d, 8.27746364655e-09};
}
@@ -79,20 +79,20 @@
*/
@Override
public double[] makeCumulativeTestValues() {
- return new double[] { 0d, 0.0183156388887d, 0.0915781944437d,
+ return new double[] { 0d, 0.0183156388887d, 0.0915781944437d,
0.238103305554d, 0.433470120367d, 0.62883693518,
0.78513038703d, 0.99716023388d, 0.999999998077 };
}
- /**
+ /**
* Creates the default inverse cumulative probability test input values.
* Increased 3rd and 7th values slightly as computed cumulative
- * probabilities for corresponding values exceeds the target value (still
+ * probabilities for corresponding values exceeds the target value (still
* within tolerance).
*/
@Override
public double[] makeInverseCumulativeTestPoints() {
- return new double[] { 0d, 0.018315638889d, 0.0915781944437d,
+ return new double[] { 0d, 0.018315638889d, 0.0915781944437d,
0.238103305554d, 0.433470120367d, 0.62883693518,
0.78513038704d, 0.99716023388d, 0.999999998077 };
}
@@ -130,7 +130,7 @@
assertEquals(Integer.MAX_VALUE, dist.inverseCumulativeProbability(1.0d));
assertEquals(-1, dist.inverseCumulativeProbability(0d));
}
-
+
public void testMean() {
PoissonDistribution dist = new PoissonDistributionImpl(DEFAULT_TEST_POISSON_PARAMETER);
try {
@@ -138,17 +138,17 @@
fail("negative mean. IllegalArgumentException expected");
} catch(IllegalArgumentException ex) {
}
-
+
dist.setMean(10.0);
assertEquals(10.0, dist.getMean(), 0.0);
}
-
+
public void testLargeMeanCumulativeProbability() {
PoissonDistribution dist = new PoissonDistributionImpl(1.0);
double mean = 1.0;
while (mean <= 10000000.0) {
dist.setMean(mean);
-
+
double x = mean * 2.0;
double dx = x / 10.0;
while (x >= 0) {
@@ -159,17 +159,17 @@
}
x -= dx;
}
-
+
mean *= 10.0;
}
}
-
+
public void testLargeMeanInverseCumulativeProbability() {
PoissonDistribution dist = new PoissonDistributionImpl(1.0);
double mean = 1.0;
while (mean <= 10000000.0) {
dist.setMean(mean);
-
+
double p = 0.1;
double dp = p;
while (p < 1.0) {
@@ -180,8 +180,8 @@
}
p += dp;
}
-
+
mean *= 10.0;
}
}
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -21,11 +21,11 @@
* Test cases for WeibullDistribution.
* Extends ContinuousDistributionAbstractTest. See class javadoc for
* ContinuousDistributionAbstractTest for details.
- *
+ *
* @version $Revision$ $Date$
*/
public class WeibullDistributionTest extends ContinuousDistributionAbstractTest {
-
+
/**
* Constructor for CauchyDistributionTest.
* @param arg0
@@ -33,54 +33,54 @@
public WeibullDistributionTest(String arg0) {
super(arg0);
}
-
+
//-------------- Implementations for abstract methods -----------------------
-
+
/** Creates the default continuous distribution instance to use in tests. */
@Override
public ContinuousDistribution makeDistribution() {
return new WeibullDistributionImpl(1.2, 2.1);
- }
-
+ }
+
/** Creates the default cumulative probability distribution test input values */
@Override
public double[] makeCumulativeTestPoints() {
- // quantiles computed using Mathematica
+ // quantiles computed using Mathematica
return new double[] {0.00664355181d, 0.04543282833d, 0.09811627374d,
0.1767135246d, 0.3219468654d, 4.207902826d, 5.23968437d,
6.232056007d, 7.497630467d, 10.51154969d};
}
-
+
/** Creates the default cumulative probability density test expected values */
@Override
public double[] makeCumulativeTestValues() {
return new double[] {0.001d, 0.01d, 0.025d, 0.05d, 0.1d, 0.900d, 0.950d,
0.975d, 0.990d, 0.999d};
}
-
+
//---------------------------- Additional test cases -------------------------
-
+
public void testInverseCumulativeProbabilityExtremes() throws Exception {
setInverseCumulativeTestPoints(new double[] {0.0, 1.0});
setInverseCumulativeTestValues(
new double[] {0.0, Double.POSITIVE_INFINITY});
verifyInverseCumulativeProbabilities();
}
-
+
public void testAlpha() {
WeibullDistribution distribution = (WeibullDistribution) getDistribution();
double expected = Math.random();
distribution.setShape(expected);
assertEquals(expected, distribution.getShape(), 0.0);
}
-
+
public void testBeta() {
WeibullDistribution distribution = (WeibullDistribution) getDistribution();
double expected = Math.random();
distribution.setScale(expected);
assertEquals(expected, distribution.getScale(), 0.0);
}
-
+
public void testSetAlpha() {
WeibullDistribution distribution = (WeibullDistribution) getDistribution();
try {
@@ -89,7 +89,7 @@
} catch (IllegalArgumentException ex) {
// success
}
-
+
try {
distribution.setShape(-1.0);
fail("Can not have negative alpha.");
@@ -97,7 +97,7 @@
// success
}
}
-
+
public void testSetBeta() {
WeibullDistribution distribution = (WeibullDistribution) getDistribution();
try {
@@ -106,7 +106,7 @@
} catch (IllegalArgumentException ex) {
// success
}
-
+
try {
distribution.setScale(-1.0);
fail("Can not have negative beta.");
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ZipfDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ZipfDistributionTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ZipfDistributionTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/distribution/ZipfDistributionTest.java Sat Sep 5 17:36:48 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,58 +21,58 @@
* Test cases for {@link ZipfDistribution}.
* Extends IntegerDistributionAbstractTest. See class javadoc for
* IntegerDistributionAbstractTest for details.
- *
+ *
* @version $Revision$ $Date$
*/
public class ZipfDistributionTest extends IntegerDistributionAbstractTest {
public ZipfDistributionTest(String name) {
super(name);
}
-
+
//-------------- Implementations for abstract methods -----------------------
-
+
/** Creates the default discrete distribution instance to use in tests. */
@Override
public IntegerDistribution makeDistribution() {
return new ZipfDistributionImpl(10, 1);
}
-
+
/** Creates the default probability density test input values */
@Override
public int[] makeDensityTestPoints() {
return new int[] {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
}
-
+
/** Creates the default probability density test expected values */
@Override
public double[] makeDensityTestValues() {
- return new double[] {0d, 0d, 0.3414d, 0.1707d, 0.1138d, 0.0854d, 0.0683d,
+ return new double[] {0d, 0d, 0.3414d, 0.1707d, 0.1138d, 0.0854d, 0.0683d,
0.0569d, 0.0488d, 0.0427d, 0.0379d, 0.0341d, 0d};
}
-
+
/** Creates the default cumulative probability density test input values */
@Override
public int[] makeCumulativeTestPoints() {
return makeDensityTestPoints();
}
-
+
/** Creates the default cumulative probability density test expected values */
@Override
public double[] makeCumulativeTestValues() {
return new double[] {0d, 0.0000d, 0.3414d, 0.5121d, 0.6259d, 0.7113d,
0.7796d, 0.8365d, 0.8852d, 0.9279d, 0.9659d, 1d, 1d};
}
-
+
/** Creates the default inverse cumulative probability test input values */
@Override
public double[] makeInverseCumulativeTestPoints() {
return new double[] {0, 0.001d, 0.010d, 0.025d, 0.050d, 0.3414d, 0.3415d, 0.999d,
- 0.990d, 0.975d, 0.950d, 0.900d, 1};
+ 0.990d, 0.975d, 0.950d, 0.900d, 1};
}
-
+
/** Creates the default inverse cumulative probability density test expected values */
@Override
public int[] makeInverseCumulativeTestValues() {
return new int[] {0, 0, 0, 0, 0, 0, 1, 9, 9, 9, 8, 7, 10};
}
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/GaussNewtonEstimatorTest.java Sat Sep 5 17:36:48 2009
@@ -27,7 +27,7 @@
/**
* <p>Some of the unit tests are re-implementations of the MINPACK <a
* href="http://www.netlib.org/minpack/ex/file17">file17</a> and <a
- * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
+ * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
* The redistribution policy for MINPACK is available <a
* href="http://www.netlib.org/minpack/disclaimer">here</a>, for
* convenience, it is reproduced below.</p>
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/LevenbergMarquardtEstimatorTest.java Sat Sep 5 17:36:48 2009
@@ -27,7 +27,7 @@
/**
* <p>Some of the unit tests are re-implementations of the MINPACK <a
* href="http://www.netlib.org/minpack/ex/file17">file17</a> and <a
- * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
+ * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
* The redistribution policy for MINPACK is available <a
* href="http://www.netlib.org/minpack/disclaimer">here</a>, for
* convenience, it is reproduced below.</p>
@@ -515,7 +515,7 @@
double[] errors = estimator.guessParametersErrors(circle);
assertEquals(1.384, errors[0], 0.001);
assertEquals(0.905, errors[1], 0.001);
-
+
// add perfect measurements and check errors are reduced
double cx = circle.getX();
double cy = circle.getY();
@@ -622,7 +622,7 @@
}
return set.toArray(new EstimatedParameter[set.size()]);
}
-
+
private LinearMeasurement[] measurements;
}
Modified: commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/MinpackTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/MinpackTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/MinpackTest.java (original)
+++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/estimation/MinpackTest.java Sat Sep 5 17:36:48 2009
@@ -30,7 +30,7 @@
/**
* <p>Some of the unit tests are re-implementations of the MINPACK <a
* href="http://www.netlib.org/minpack/ex/file17">file17</a> and <a
- * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
+ * href="http://www.netlib.org/minpack/ex/file22">file22</a> test files.
* The redistribution policy for MINPACK is available <a
* href="http://www.netlib.org/minpack/disclaimer">here</a>, for
* convenience, it is reproduced below.</p>
@@ -133,7 +133,7 @@
minpackTest(new HelicalValleyFunction(new double[] { -100.0, 0.0, 0.0},
991.261822123701), false);
}
-
+
public void testMinpackPowellSingular() {
minpackTest(new PowellSingularFunction(new double[] { 3.0, -1.0, 0.0, 1.0 },
14.6628782986152), false);
@@ -142,7 +142,7 @@
minpackTest(new PowellSingularFunction(new double[] { 300.0, -100.0, 0.0, 100.0 },
126887.903284750), false);
}
-
+
public void testMinpackFreudensteinRoth() {
minpackTest(new FreudensteinRothFunction(new double[] { 0.5, -2.0 },
20.0124960961895, 6.99887517584575,
@@ -163,7 +163,7 @@
-0.89680510749204
}), false);
}
-
+
public void testMinpackBard() {
minpackTest(new BardFunction(1.0, 6.45613629515967, 0.0906359603390466,
new double[] {
@@ -184,7 +184,7 @@
-164464906.857771
}), false);
}
-
+
public void testMinpackKowalikOsborne() {
minpackTest(new KowalikOsborneFunction(new double[] { 0.25, 0.39, 0.415, 0.39 },
0.0728915102882945,
@@ -214,7 +214,7 @@
0.134575665392506
}), true);
}
-
+
public void testMinpackMeyer() {
minpackTest(new MeyerFunction(new double[] { 0.02, 4000.0, 250.0 },
41153.4665543031, 9.37794514651874,
@@ -231,9 +231,9 @@
901.268527953801
}), true);
}
-
+
public void testMinpackWatson() {
-
+
minpackTest(new WatsonFunction(6, 0.0,
5.47722557505166, 0.0478295939097601,
new double[] {
@@ -316,12 +316,12 @@
}), false);
}
-
+
public void testMinpackBox3Dimensional() {
minpackTest(new Box3DimensionalFunction(10, new double[] { 0.0, 10.0, 20.0 },
32.1115837449572), false);
}
-
+
public void testMinpackJennrichSampson() {
minpackTest(new JennrichSampsonFunction(10, new double[] { 0.3, 0.4 },
64.5856498144943, 11.1517793413499,
@@ -353,7 +353,7 @@
-0.403688070279258, 0.236665033746463
}), false);
}
-
+
public void testMinpackChebyquad() {
minpackTest(new ChebyquadFunction(1, 8, 1.0,
1.88623796907732, 1.88623796907732,
@@ -391,7 +391,7 @@
0.833291216194063, 0.940379732824644
}), false);
}
-
+
public void testMinpackBrownAlmostLinear() {
minpackTest(new BrownAlmostLinearFunction(10, 0.5,
16.5302162063499, 0.0,
@@ -410,7 +410,7 @@
0.979430303349865, 0.979430303349865,
0.979430303349865, 0.979430303349865,
0.979430303349865, 1.20569696650135
- }), false);
+ }), false);
minpackTest(new BrownAlmostLinearFunction(10, 50.0,
0.9765625e17, 0.0,
new double[] {
@@ -459,7 +459,7 @@
0.999999999999121
}), false);
}
-
+
public void testMinpackOsborne1() {
minpackTest(new Osborne1Function(new double[] { 0.5, 1.5, -1.0, 0.01, 0.02, },
0.937564021037838, 0.00739249260904843,
@@ -469,9 +469,9 @@
0.0221227011813076
}), false);
}
-
+
public void testMinpackOsborne2() {
-
+
minpackTest(new Osborne2Function(new double[] {
1.3, 0.65, 0.65, 0.7, 0.6,
3.0, 5.0, 7.0, 2.0, 4.5, 5.5
@@ -505,7 +505,7 @@
}
private static abstract class MinpackFunction implements EstimationProblem {
-
+
protected MinpackFunction(int m,
double[] startParams,
double theoreticalStartCost,
@@ -564,7 +564,7 @@
}
return true;
}
-
+
public WeightedMeasurement[] getMeasurements() {
WeightedMeasurement[] measurements = new WeightedMeasurement[m];
for (int i = 0; i < m; ++i) {
@@ -1043,7 +1043,7 @@
34780.0, 28610.0, 23650.0, 19630.0,
16370.0, 13720.0, 11540.0, 9744.0,
8261.0, 7030.0, 6005.0, 5147.0,
- 4427.0, 3820.0, 3307.0, 2872.0
+ 4427.0, 3820.0, 3307.0, 2872.0
};
}