Commit 91430f2c authored by Emmanuel Bourg's avatar Emmanuel Bourg

Imported Upstream version 3.6.1

parent ce59910f
The Apache Commons Math team is pleased to announce the commons-math3-3.6 release!
The Apache Commons Math project is a library of lightweight, self-contained mathematics
and statistics components addressing the most common practical problems not immediately
available in the Java programming language or commons-lang.
Apache Commons Math 3.6.1 RELEASE NOTES
Changes in this version include:
The Apache Commons Math team is pleased to announce the release of
commons-math3-3.6.1
The Apache Commons Math project is a library of lightweight, self-contained
mathematics and statistics components addressing the most common practical
problems not immediately available in the Java programming language or
commons-lang.
This is a minor bug fix release. It incorporates three bug fixes since version
3.6. The minimum version of the Java platform required to compile and use
Commons Math 3.6.1 is Java 5.
New features:
o Added a RotationConvention enumerate to allow specifying the semantics
or axis/angle for rotations. This enumerate has two values:
VECTOR_OPERATOR and FRAME_TRANSFORM. Issue: MATH-1302,MATH-1303.
o Added a field-based version of Ordinary Differential Equations framework.
This allows integrating ode that refer to RealField elements instead of
primitive double, hence opening the way to use DerivativeStructure to
compute partial differential without using variational equations, or to solve
ode with extended precision using Dfp. Issue: MATH-1288.
o Added a nth order Brent solver for general real fields, replacing the former
solver that was restricted to Dfp fields only.
o New "Range" inner class of "o.a.c.m.util.IntegerSequence". Issue: MATH-1286.
o "AggregateSummaryStatistics" can now aggregate any kind of
"StatisticalSummary". Issue: MATH-837.
o Deep copy of "Network" (package "o.a.c.m.ml.neuralnet") to allow evaluation of
of intermediate states during training. Issue: MATH-1278.
o Added negative zero support in FastMath.pow. Issue: MATH-1273. Thanks to Qualtagh.
o Various SOFM visualizations (in package "o.a.c.m.ml.neuralnet.twod.util"):
Unified distance matrix, hit histogram, smoothed data histograms,
topographic error, quantization error. Issue: MATH-1270.
o New interfaces to be implemented by algorithms that visualizes properties
of a "NeuronSquareMesh2D" (package "o.a.c.m.ml.neuralnet.twod.util"). Issue: MATH-1268.
o Reimplemented pow(double, double) in FastMath, for better accuracy in
integral power cases and trying to fix erroneous JIT optimization again.
o Added a pow(double, long) method in FastMath.
o "NeuronSquareMesh2D" (package "o.a.c.m.ml.neuralnet.twod") implements "Iterable". Issue: MATH-1265.
o "MapUtils" (package "o.a.c.m.ml.neuralnet"): Method to sort units according to distance
from a given vector. Issue: MATH-1264.
o Accessor (class "o.a.c.m.ml.neuralnet.twod.NeuronSquareMesh2D"). Issue: MATH-1263.
o New "IntegerSequence" class (in package "o.a.c.m.util") with "Incrementor" inner class. Issue: MATH-1259.
o "Neuron" class (package "o.a.c.m.ml.neuralnet"): added methods that can be used
to assess concurrency performance. Issue: MATH-1250.
o Method "cosAngle" in "o.a.c.m.util.MathArrays". Issue: MATH-1244.
Changes in this version include:
Fixed Bugs:
o Improved performance and accuracy of 2-sample KolmogorovSmirnov tests. Issue: MATH-1310.
o Detect start failures with multi-step ODE integrators. Issue: MATH-1297.
o Fixed stability issues with Adams-Bashforth and Adams-Moulton ODE integrators.
The integrators did not estimate the local error properly and were sometimes
stuck attempting to reduce indefinitely the step size as they thought the
error was too high. Thanks to Julien Queyrel.
o Increased default value for number of allowed evaluations in
"o.a.c.m.optim.univariate.BracketFinder". Issue: MATH-1295. Thanks to Luke Lindsay.
o Fixed potential race condition in PolynomialUtils#buildPolynomial in
case polynomials are generated from multiple threads. Furthermore, the
synchronization is now performed on the coefficient list instead of the class. Issue: MATH-1294. Thanks to Kamil Włodarczyk.
o Fixed FastMath.exp that potentially returned NaN for non-NaN argument. Issue: MATH-1269.
o Updated reference in ZipfDistribution's javadoc. Issue: MATH-1285. Thanks to Pim van der Hoorn.
o Fixed "Gamma#gamma(double)" for negative values smaller than -20. Issue: MATH-1283. Thanks to Jean Noel Delavalade.
o Fixed javadoc of methods {floorDiv,floorMod} in class "FastMath". Issue: MATH-1237. Thanks to Ken Williams.
o Check precondition (class "o.a.c.m.random.EmpiricalDistribution"). Issue: MATH-1279.
o Fixed incorrect Kendall's tau coefficient calculation due to internal integer overflow. Issue: MATH-1277. Thanks to Marc Rosen.
o Fixed split/side inconsistencies in BSP trees. Issue: MATH-1266.
o Avoid overflow in "Fraction" (multiplication or division by an int). Issue: MATH-1261. Thanks to Osamu Ikeuchi.
o Added check for equal array lengths to distance measure functions. Issue: MATH-1258. Thanks to Gunel Jahangirova.
o Better accuracy in computation of cumulative probability of "NormalDistribution"
(package "o.a.c.m.distribution"). Issue: MATH-1257. Thanks to Bill Murphy.
o Boundary check to construct an "Interval" (package "o.a.c.m.geometry.euclidean.oned"). Issue: MATH-1256.
o Wrong neighbourhood size in class "KohonenUpdateAction" (package "o.a.c.m.ml.neuralnet.sofm"). Issue: MATH-1255.
o ResizableDoubleArray constructor does not work with double array of size 1. Issue: MATH-1252. Thanks to John Bay.
o Fixed initial value of "number of calls" counter in class "KohonenUpdateAction"
(package "o.a.c.m.ml.neuralnet.sofm"). Issue: MATH-1251.
o Removed unnecessary allocations in "BigFraction" (package "o.a.c.m.fraction"). Issue: MATH-1248. Thanks to Chris Popp.
o Fixed error in computing discrete distribution of D statistics for small-sample
2-sample Kolmogorov-Smirnov tests. Error was causing incorrect p-values returned
by exactP and monteCarloP methods (used by default for small, mid-size samples). Issue: MATH-1245.
o "KolmogorovSmirnovTest#ksSum(...)" returned wrong result in case the provided
t-parameters was zero. This affected the calculation of "approximateP(...)" for
identical samples. Issue: MATH-1240.
o Improved performance to calculate the two-sample Kolmogorov-Smirnov test
via monte carlo simulation ("KolmogorovSmirnovTets#monteCarloP(...)"). Issue: MATH-1242. Thanks to Otmar Ertl.
o A "StackOverflowException" was thrown when passing Double.NaN or infinity
to "Gamma#digamma(double)" or "Gamma#trigamma(double)". Now the input value
is propagated to the output if it is not a real number. Issue: MATH-1241. Thanks to Aleksei Dievskii.
o Improved performance of calculating the two-sample Kolmogorov-Smirnov
test statistic. Issue: MATH-1232. Thanks to Otmar Ertl.
o Fixed error message for unknown parameter name in ODE. Issue: MATH-1232.
o Fixed wrong event detection in case of close events pairs. Issue: MATH-1226.
o Fix potential branching errors in "FastMath#pow(double, double)" when
passing special values, i.e. infinity, due to erroneous JIT optimization.
o Fixed equals/hashcode contract failure for Dfp. Issue: MATH-1118.
o Fixed wrong splitting of huge number in extended accuracy algorithms. Issue: MATH-1223.
o Improve performance of "BetaDistribution#sample()" by using Cheng's algorithm. Issue: MATH-1153. Thanks to Sergei Lebedev.
o Computation of 2-sample Kolmogorov-Smirnov statistic in case of ties
was not correct. Issue: MATH-1197.
o MATH-1316: Fix code example in User Guide > Statistics > Multiple linear regression.
o MATH-1342: Fix ODE integrators when multiple events are nearly simultaneous.
Changes:
o Modified 2-sample KolmogorovSmirnovTest to handle ties in sample data. By default,
ties are broken by adding random jitter to input data. Also added bootstrap method
analogous to ks.boot in R Matching package. Issue: MATH-1246.
o Added bootstrap method to KolmogorovSmirnov test. Issue: MATH-1246.
o Added constructors taking sample data as arguments to enumerated real and integer distributions. Issue: MATH-1287.
o Improved performance of sampling and inverse cumulative probability calculation
for geometric distributions. Issue: MATH-1276.
o Representation of Kolmogorov-Smirnov statistic as integral value. Issue: MATH-1274.
o Faster generation of Zipf distributed random numbers by using rejection-inversion sampling. Issue: MATH-1220.
o Improved performance of sort-in-place methods by avoiding boxing. Issue: MATH-990.
o Refactored implementation of the "miscrosphere projection"
interpolation algorithm.
New classes: "MicrosphereProjectionInterpolator",
"InterpolatingMicrosphere" and "InterpolatingMicrosphere2D"
replace "MicrosphereInterpolator" and "MicrosphereInterpolatingFunction".
(package "o.a.c.m.analysis.interpolation"). Issue: MATH-1243.
o MATH-1317: Add uniformity unit tests to "RandomGeneratorAbstractTest".
For complete information on Apache Commons Math, including instructions on how
to submit bug reports, patches, or suggestions for improvement, see the Apache
Commons Math website:
http://commons.apache.org/proper/commons-math/
Have fun!
-Apache Commons Math team
......@@ -24,7 +24,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6</version>
<version>3.6.1</version>
<name>Apache Commons Math</name>
<inceptionYear>2003</inceptionYear>
......@@ -112,11 +112,6 @@
<id>erans</id>
<email>erans at apache dot org</email>
</developer>
<developer>
<name>Phil Steitz</name>
<id>psteitz</id>
<email>psteitz at apache dot org</email>
</developer>
<developer>
<name>Greg Sterijevski</name>
<id>gregs</id>
......@@ -374,9 +369,9 @@
<!-- This value must reflect the current name of the base package. -->
<commons.osgi.symbolicName>org.apache.commons.math3</commons.osgi.symbolicName>
<!-- do not use snapshot suffix here -->
<commons.release.version>3.6</commons.release.version>
<commons.release.version>3.6.1</commons.release.version>
<commons.release.desc>(requires Java 1.5+)</commons.release.desc>
<commons.rc.version>RC2</commons.rc.version>
<commons.rc.version>RC1</commons.rc.version>
<commons.binary.suffix>-bin</commons.binary.suffix>
<commons.release.2.version>2.2</commons.release.2.version>
......
......@@ -50,6 +50,22 @@ If the output is not quite correct, check for invisible trailing spaces!
<title>Commons Math Release Notes</title>
</properties>
<body>
<release version="3.6.1" date="2016-03-21" description="
This is a minor bug fix release. It incorporates three bug fixes since version 3.6.
The minimum version of the Java platform required to compile and use
Commons Math 3.6.1 is Java 5.
">
<action dev="psteitz" type="update" issue="MATH-1317">
Add uniformity unit tests to "RandomGeneratorAbstractTest".
</action>
<action dev="psteitz" type="fix" issue="MATH-1316">
Fix code example in User Guide > Statistics > Multiple linear regression.
</action>
<action dev="evan" type="fix" issue="MATH-1342">
Fix ODE integrators when multiple events are nearly simultaneous.
</action>
</release>
<release version="3.6" date="2016-01-05" description="
This is a minor release: It combines bug fixes and new features.
Changes to existing features were made in a backwards-compatible
......
......@@ -395,9 +395,7 @@ public abstract class AbstractIntegrator implements FirstOrderIntegrator {
boolean needReset = false;
resetOccurred = false;
for (final EventState state : eventsStates) {
needReset = needReset || state.reset(eventT, eventYComplete);
}
needReset = currentEvent.reset(eventT, eventYComplete);
if (needReset) {
// some event handler has triggered changes that
// invalidate the derivatives, we need to recompute them
......
......@@ -27,6 +27,8 @@
<item name="Overview" href="/index.html"/>
<item name="Downloads" href="http://commons.apache.org/math/download_math.cgi"/>
<item name="Latest API docs (development)" href="apidocs/index.html"/>
<item name="Javadoc (3.6.1 release)"
href="http://commons.apache.org/math/javadocs/api-3.6.1/index.html"/>
<item name="Javadoc (3.6 release)"
href="http://commons.apache.org/math/javadocs/api-3.6/index.html"/>
<item name="Javadoc (3.5 release)"
......
This diff is collapsed.
......@@ -562,14 +562,14 @@ System.out.println(regression.getInterceptStdErr() );
<source>
OLSMultipleLinearRegression regression = new OLSMultipleLinearRegression();
double[] y = new double[]{11.0, 12.0, 13.0, 14.0, 15.0, 16.0};
double[] x = new double[6][];
double[][] x = new double[6][];
x[0] = new double[]{0, 0, 0, 0, 0};
x[1] = new double[]{2.0, 0, 0, 0, 0};
x[2] = new double[]{0, 3.0, 0, 0, 0};
x[3] = new double[]{0, 0, 4.0, 0, 0};
x[4] = new double[]{0, 0, 0, 5.0, 0};
x[5] = new double[]{0, 0, 0, 0, 6.0};
regression.newSample(y, x);
regression.newSampleData(y, x);
</source>
</dd>
<dd>Get regression parameters and diagnostics:
......@@ -593,7 +593,7 @@ double sigma = regression.estimateRegressionStandardError();
<source>
GLSMultipleLinearRegression regression = new GLSMultipleLinearRegression();
double[] y = new double[]{11.0, 12.0, 13.0, 14.0, 15.0, 16.0};
double[] x = new double[6][];
double[][] x = new double[6][];
x[0] = new double[]{0, 0, 0, 0, 0};
x[1] = new double[]{2.0, 0, 0, 0, 0};
x[2] = new double[]{0, 3.0, 0, 0, 0};
......
......@@ -17,18 +17,19 @@
package org.apache.commons.math3.ml.neuralnet.sofm;
import org.apache.commons.math3.ml.neuralnet.Neuron;
import org.apache.commons.math3.ml.neuralnet.Network;
import org.apache.commons.math3.ml.neuralnet.MapUtils;
import org.apache.commons.math3.ml.neuralnet.UpdateAction;
import org.apache.commons.math3.ml.neuralnet.OffsetFeatureInitializer;
import org.apache.commons.math3.ml.neuralnet.FeatureInitializer;
import org.apache.commons.math3.ml.neuralnet.FeatureInitializerFactory;
import org.apache.commons.math3.ml.distance.DistanceMeasure;
import org.apache.commons.math3.ml.distance.EuclideanDistance;
import org.apache.commons.math3.ml.neuralnet.FeatureInitializer;
import org.apache.commons.math3.ml.neuralnet.FeatureInitializerFactory;
import org.apache.commons.math3.ml.neuralnet.MapUtils;
import org.apache.commons.math3.ml.neuralnet.Network;
import org.apache.commons.math3.ml.neuralnet.Neuron;
import org.apache.commons.math3.ml.neuralnet.OffsetFeatureInitializer;
import org.apache.commons.math3.ml.neuralnet.UpdateAction;
import org.apache.commons.math3.ml.neuralnet.oned.NeuronString;
import org.junit.Test;
import org.apache.commons.math3.util.Precision;
import org.junit.Assert;
import org.junit.Test;
/**
* Tests for {@link KohonenUpdateAction} class.
......@@ -82,7 +83,7 @@ public class KohonenUpdateActionTest {
Assert.assertEquals(bestBefore, bestAfter);
// Distance is now zero.
Assert.assertEquals(0, dist.compute(bestAfter.getFeatures(), features), 0d);
Assert.assertEquals(0, dist.compute(bestAfter.getFeatures(), features), Precision.EPSILON);
for (int i = 0; i < netSize; i++) {
// All distances have decreased.
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.commons.math3.ode.events;
import org.apache.commons.math3.ode.FirstOrderDifferentialEquations;
import org.apache.commons.math3.ode.FirstOrderIntegrator;
import org.apache.commons.math3.ode.nonstiff.DormandPrince853Integrator;
import org.junit.Assert;
import org.junit.Test;
/**
* Check events are detected correctly when the event times are close.
*
* @author Evan Ward
*/
public class CloseEventsTest {
@Test
public void testCloseEvents() {
// setup
double e = 1e-15;
FirstOrderIntegrator integrator =
new DormandPrince853Integrator(e, 100.0, 1e-7, 1e-7);
TimeDetector detector1 = new TimeDetector(5);
integrator.addEventHandler(detector1, 10, 1, 100);
TimeDetector detector2 = new TimeDetector(5.5);
integrator.addEventHandler(detector2, 10, 1, 100);
// action
integrator.integrate(new Equation(), 0, new double[2], 20, new double[2]);
// verify
Assert.assertEquals(5, detector1.getActualT(), 0.0);
Assert.assertEquals(5.5, detector2.getActualT(), 0.0);
}
@Test
public void testSimultaneousEvents() {
// setup
double e = 1e-15;
FirstOrderIntegrator integrator =
new DormandPrince853Integrator(e, 100.0, 1e-7, 1e-7);
TimeDetector detector1 = new TimeDetector(5);
integrator.addEventHandler(detector1, 10, 1, 100);
TimeDetector detector2 = new TimeDetector(5);
integrator.addEventHandler(detector2, 10, 1, 100);
// action
integrator.integrate(new Equation(), 0, new double[2], 20, new double[2]);
// verify
Assert.assertEquals(5, detector1.getActualT(), 0.0);
Assert.assertEquals(5, detector2.getActualT(), 0.0);
}
/** Trigger an event at a particular time. */
private static class TimeDetector implements EventHandler {
/** time of the event to trigger. */
private final double eventT;
/** time the event was actually triggered. */
private double actualT;
/**
* Create a new detector.
*
* @param eventT the time to trigger an event.
*/
public TimeDetector(double eventT) {
this.eventT = eventT;
}
/** Get the actual time the event occurred. */
public double getActualT() {
return actualT;
}
public void init(double t0, double[] y0, double t) {
}
public double g(double t, double[] y) {
return t - eventT;
}
public Action eventOccurred(double t, double[] y, boolean increasing) {
this.actualT = t;
return Action.CONTINUE;
}
public void resetState(double t, double[] y) {
}
}
/** Some basic equations to integrate. */
public static class Equation implements FirstOrderDifferentialEquations {
public int getDimension() {
return 2;
}
public void computeDerivatives(double t, double[] y, double[] yDot) {
yDot[0] = 1.0;
yDot[1] = 2.0;
}
}
}
......@@ -19,11 +19,12 @@ package org.apache.commons.math3.random;
import java.util.Arrays;
import org.apache.commons.math3.TestUtils;
import org.apache.commons.math3.distribution.RealDistribution;
import org.apache.commons.math3.distribution.UniformRealDistribution;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.apache.commons.math3.stat.Frequency;
import org.apache.commons.math3.stat.descriptive.SummaryStatistics;
import org.apache.commons.math3.stat.inference.KolmogorovSmirnovTest;
import org.apache.commons.math3.util.FastMath;
import org.apache.commons.math3.exception.MathIllegalArgumentException;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
......@@ -260,29 +261,14 @@ public abstract class RandomGeneratorAbstractTest extends RandomDataGeneratorTes
}
@Test
public void testDoubleDirect() {
SummaryStatistics sample = new SummaryStatistics();
final int N = 10000;
for (int i = 0; i < N; ++i) {
sample.addValue(generator.nextDouble());
}
Assert.assertEquals("Note: This test will fail randomly about 1 in 100 times.",
0.5, sample.getMean(), FastMath.sqrt(N/12.0) * 2.576);
Assert.assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
sample.getStandardDeviation(), 0.01);
}
@Test
public void testFloatDirect() {
SummaryStatistics sample = new SummaryStatistics();
final int N = 1000;
for (int i = 0; i < N; ++i) {
sample.addValue(generator.nextFloat());
public void testNextDouble() {
final double[] sample = new double[10000];
for (int i = 0; i < sample.length; i++) {
sample[i] = generator.nextDouble();
}
Assert.assertEquals("Note: This test will fail randomly about 1 in 100 times.",
0.5, sample.getMean(), FastMath.sqrt(N/12.0) * 2.576);
Assert.assertEquals(1.0 / (2.0 * FastMath.sqrt(3.0)),
sample.getStandardDeviation(), 0.01);
final RealDistribution uniformDistribution = new UniformRealDistribution(0,1);
final KolmogorovSmirnovTest ks = new KolmogorovSmirnovTest();
Assert.assertFalse(ks.kolmogorovSmirnovTest(uniformDistribution, sample, .01));
}
@Test(expected=MathIllegalArgumentException.class)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment