Remove trailing whitespace
This commit is contained in:
parent
a8d392580d
commit
5a8234a2fe
|
@ -322,7 +322,7 @@ public class LoessInterpolatorTest {
|
||||||
Assert.assertEquals(yref[i], res[i], delta);
|
Assert.assertEquals(yref[i], res[i], delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateSineData(double[] xval, double[] yval, double xnoise, double ynoise) {
|
private void generateSineData(double[] xval, double[] yval, double xnoise, double ynoise) {
|
||||||
double dx = 2 * JdkMath.PI / xval.length;
|
double dx = 2 * JdkMath.PI / xval.length;
|
||||||
double x = 0;
|
double x = 0;
|
||||||
|
|
|
@ -109,7 +109,7 @@ public final class MullerSolverTest {
|
||||||
UnivariateFunction f = new Expm1();
|
UnivariateFunction f = new Expm1();
|
||||||
UnivariateSolver solver = new MullerSolver();
|
UnivariateSolver solver = new MullerSolver();
|
||||||
double min;
|
double min;
|
||||||
double max;
|
double max;
|
||||||
double expected;
|
double expected;
|
||||||
double result;
|
double result;
|
||||||
double tolerance;
|
double tolerance;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.junit.Assert;
|
||||||
public class SimplePointCheckerTest {
|
public class SimplePointCheckerTest {
|
||||||
@Test(expected=NotStrictlyPositiveException.class)
|
@Test(expected=NotStrictlyPositiveException.class)
|
||||||
public void testIterationCheckPrecondition() {
|
public void testIterationCheckPrecondition() {
|
||||||
new SimplePointChecker<PointValuePair>(1e-1, 1e-2, 0);
|
new SimplePointChecker<>(1e-1, 1e-2, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class MultivariateFunctionPenaltyAdapterTest {
|
||||||
biQuadratic.getUpper(),
|
biQuadratic.getUpper(),
|
||||||
1000.0, new double[] { 100.0, 100.0 });
|
1000.0, new double[] { 100.0, 100.0 });
|
||||||
|
|
||||||
SimplexOptimizer optimizer = new SimplexOptimizer(new SimplePointChecker<PointValuePair>(1.0e-11, 1.0e-20));
|
SimplexOptimizer optimizer = new SimplexOptimizer(new SimplePointChecker<>(1.0e-11, 1.0e-20));
|
||||||
|
|
||||||
final PointValuePair optimum
|
final PointValuePair optimum
|
||||||
= optimizer.optimize(new MaxEval(600),
|
= optimizer.optimize(new MaxEval(600),
|
||||||
|
@ -133,7 +133,7 @@ public class MultivariateFunctionPenaltyAdapterTest {
|
||||||
biQuadratic.getUpper(),
|
biQuadratic.getUpper(),
|
||||||
1000.0, new double[] { 100.0, 100.0 });
|
1000.0, new double[] { 100.0, 100.0 });
|
||||||
|
|
||||||
SimplexOptimizer optimizer = new SimplexOptimizer(new SimplePointChecker<>(1.0e-10, 1.0e-20));
|
SimplexOptimizer optimizer = new SimplexOptimizer(new SimplePointChecker<PointValuePair>(1.0e-10, 1.0e-20));
|
||||||
|
|
||||||
final PointValuePair optimum
|
final PointValuePair optimum
|
||||||
= optimizer.optimize(new MaxEval(400),
|
= optimizer.optimize(new MaxEval(400),
|
||||||
|
|
|
@ -86,7 +86,7 @@ public final class FrequencyTest {
|
||||||
Assert.assertEquals("-2 cum pct", 0, fInteger.getCumPct(-2), TOLERANCE);
|
Assert.assertEquals("-2 cum pct", 0, fInteger.getCumPct(-2), TOLERANCE);
|
||||||
Assert.assertEquals("10 cum pct", 1, fInteger.getCumPct(10), TOLERANCE);
|
Assert.assertEquals("10 cum pct", 1, fInteger.getCumPct(10), TOLERANCE);
|
||||||
|
|
||||||
fString = new Frequency<String>(String.CASE_INSENSITIVE_ORDER);
|
fString = new Frequency<>(String.CASE_INSENSITIVE_ORDER);
|
||||||
fString.addValue("one");
|
fString.addValue("one");
|
||||||
fString.addValue("One");
|
fString.addValue("One");
|
||||||
fString.addValue("oNe");
|
fString.addValue("oNe");
|
||||||
|
@ -260,10 +260,10 @@ public final class FrequencyTest {
|
||||||
Assert.assertEquals(1, f.getCount(ONE_LONG));
|
Assert.assertEquals(1, f.getCount(ONE_LONG));
|
||||||
Assert.assertEquals(0, f.getCount(TWO_LONG));
|
Assert.assertEquals(0, f.getCount(TWO_LONG));
|
||||||
|
|
||||||
Frequency<Long> g = new Frequency<>();
|
Frequency<Long> g = new Frequency<Long>();
|
||||||
g.addValue(TWO_LONG);
|
g.addValue(TWO_LONG);
|
||||||
|
|
||||||
Frequency<Long> h = new Frequency<>();
|
Frequency<Long> h = new Frequency<Long>();
|
||||||
h.addValue(THREE_LONG);
|
h.addValue(THREE_LONG);
|
||||||
|
|
||||||
List<Frequency<Long>> coll = new ArrayList<>();
|
List<Frequency<Long>> coll = new ArrayList<>();
|
||||||
|
|
|
@ -387,7 +387,7 @@ public class PSquarePercentileTest extends
|
||||||
|
|
||||||
@Test(expected = MathIllegalArgumentException.class)
|
@Test(expected = MathIllegalArgumentException.class)
|
||||||
public void testInitial() {
|
public void testInitial() {
|
||||||
PSquarePercentile.newMarkers(new ArrayList<Double>(), 0.5);
|
PSquarePercentile.newMarkers(new ArrayList<>(), 0.5);
|
||||||
Assert.fail();
|
Assert.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -183,7 +183,7 @@ public class Network
|
||||||
}
|
}
|
||||||
|
|
||||||
neuronMap.put(id, new Neuron(id, features.clone()));
|
neuronMap.put(id, new Neuron(id, features.clone()));
|
||||||
linkMap.put(id, new HashSet<Long>());
|
linkMap.put(id, new HashSet<>());
|
||||||
|
|
||||||
if (id > nextId.get()) {
|
if (id > nextId.get()) {
|
||||||
nextId.set(id);
|
nextId.set(id);
|
||||||
|
|
|
@ -36,7 +36,7 @@ The <action> type attribute can be add,update,fix,remove.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- NOTE:
|
<!-- NOTE:
|
||||||
The description attribute entries below are specially formatted
|
The description attribute entries below are specially formatted
|
||||||
so as to improve the layout of the generated text release notes.
|
so as to improve the layout of the generated text release notes.
|
||||||
|
|
||||||
The parsing process removes all line feeds, replacing them with a single space.
|
The parsing process removes all line feeds, replacing them with a single space.
|
||||||
|
@ -477,7 +477,7 @@ Caveat:
|
||||||
<action dev="tn" type="add" issue="MATH-1039" due-to="Aleksei Dievskii">
|
<action dev="tn" type="add" issue="MATH-1039" due-to="Aleksei Dievskii">
|
||||||
Added logDensity(double) to RealDistribution and logProbability(int)
|
Added logDensity(double) to RealDistribution and logProbability(int)
|
||||||
to IntegerDistribution interface. The implementations have already been
|
to IntegerDistribution interface. The implementations have already been
|
||||||
updated in release 3.3.
|
updated in release 3.3.
|
||||||
</action>
|
</action>
|
||||||
<action dev="tn" type="update" issue="MATH-1155">
|
<action dev="tn" type="update" issue="MATH-1155">
|
||||||
WELL type pseudo-random number generators have been refactored:
|
WELL type pseudo-random number generators have been refactored:
|
||||||
|
@ -577,7 +577,7 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
Fixed potential race condition in PolynomialUtils#buildPolynomial in
|
Fixed potential race condition in PolynomialUtils#buildPolynomial in
|
||||||
case polynomials are generated from multiple threads. Furthermore, the
|
case polynomials are generated from multiple threads. Furthermore, the
|
||||||
synchronization is now performed on the coefficient list instead of the class.
|
synchronization is now performed on the coefficient list instead of the class.
|
||||||
</action>
|
</action>
|
||||||
<action dev="psteitz" type="update" issue="MATH-1246">
|
<action dev="psteitz" type="update" issue="MATH-1246">
|
||||||
Added bootstrap method to KolmogorovSmirnov test.
|
Added bootstrap method to KolmogorovSmirnov test.
|
||||||
</action>
|
</action>
|
||||||
|
@ -599,7 +599,7 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
</action>
|
</action>
|
||||||
<action dev="tn" type="fix" issue="MATH-1283" due-to="Jean Noel Delavalade">
|
<action dev="tn" type="fix" issue="MATH-1283" due-to="Jean Noel Delavalade">
|
||||||
Fixed "Gamma#gamma(double)" for negative values smaller than -20.
|
Fixed "Gamma#gamma(double)" for negative values smaller than -20.
|
||||||
</action>
|
</action>
|
||||||
<action dev="tn" type="fix" issue="MATH-1237" due-to="Ken Williams">
|
<action dev="tn" type="fix" issue="MATH-1237" due-to="Ken Williams">
|
||||||
Fixed javadoc of methods {floorDiv,floorMod} in class "FastMath".
|
Fixed javadoc of methods {floorDiv,floorMod} in class "FastMath".
|
||||||
</action>
|
</action>
|
||||||
|
@ -697,7 +697,7 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
</action>
|
</action>
|
||||||
<action dev="psteitz" type="fix" issue="MATH-1245">
|
<action dev="psteitz" type="fix" issue="MATH-1245">
|
||||||
Fixed error in computing discrete distribution of D statistics for small-sample
|
Fixed error in computing discrete distribution of D statistics for small-sample
|
||||||
2-sample Kolmogorov-Smirnov tests. Error was causing incorrect p-values returned
|
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).
|
by exactP and monteCarloP methods (used by default for small, mid-size samples).
|
||||||
</action>
|
</action>
|
||||||
<action dev="erans" type="update" issue="MATH-1243">
|
<action dev="erans" type="update" issue="MATH-1243">
|
||||||
|
@ -719,16 +719,16 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
<action dev="tn" type="fix" issue="MATH-1242" due-to="Otmar Ertl">
|
<action dev="tn" type="fix" issue="MATH-1242" due-to="Otmar Ertl">
|
||||||
Improved performance to calculate the two-sample Kolmogorov-Smirnov test
|
Improved performance to calculate the two-sample Kolmogorov-Smirnov test
|
||||||
via monte carlo simulation ("KolmogorovSmirnovTets#monteCarloP(...)").
|
via monte carlo simulation ("KolmogorovSmirnovTets#monteCarloP(...)").
|
||||||
</action>
|
</action>
|
||||||
<action dev="tn" type="fix" issue="MATH-1241" due-to="Aleksei Dievskii">
|
<action dev="tn" type="fix" issue="MATH-1241" due-to="Aleksei Dievskii">
|
||||||
A "StackOverflowException" was thrown when passing Double.NaN or infinity
|
A "StackOverflowException" was thrown when passing Double.NaN or infinity
|
||||||
to "Gamma#digamma(double)" or "Gamma#trigamma(double)". Now the input value
|
to "Gamma#digamma(double)" or "Gamma#trigamma(double)". Now the input value
|
||||||
is propagated to the output if it is not a real number.
|
is propagated to the output if it is not a real number.
|
||||||
</action>
|
</action>
|
||||||
<action dev="tn" type="fix" issue="MATH-1232" due-to="Otmar Ertl">
|
<action dev="tn" type="fix" issue="MATH-1232" due-to="Otmar Ertl">
|
||||||
Improved performance of calculating the two-sample Kolmogorov-Smirnov
|
Improved performance of calculating the two-sample Kolmogorov-Smirnov
|
||||||
test statistic.
|
test statistic.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="fix" issue="MATH-1232">
|
<action dev="luc" type="fix" issue="MATH-1232">
|
||||||
Fixed error message for unknown parameter name in ODE.
|
Fixed error message for unknown parameter name in ODE.
|
||||||
</action>
|
</action>
|
||||||
|
@ -738,7 +738,7 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
<action dev="tn" type="fix">
|
<action dev="tn" type="fix">
|
||||||
Fix potential branching errors in "FastMath#pow(double, double)" when
|
Fix potential branching errors in "FastMath#pow(double, double)" when
|
||||||
passing special values, i.e. infinity, due to erroneous JIT optimization.
|
passing special values, i.e. infinity, due to erroneous JIT optimization.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="fix" issue="MATH-1118" >
|
<action dev="luc" type="fix" issue="MATH-1118" >
|
||||||
Fixed equals/hashcode contract failure for Dfp.
|
Fixed equals/hashcode contract failure for Dfp.
|
||||||
</action>
|
</action>
|
||||||
|
@ -751,27 +751,27 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
<action dev="tn" type="fix" issue="MATH-1197">
|
<action dev="tn" type="fix" issue="MATH-1197">
|
||||||
Computation of 2-sample Kolmogorov-Smirnov statistic in case of ties
|
Computation of 2-sample Kolmogorov-Smirnov statistic in case of ties
|
||||||
was not correct.
|
was not correct.
|
||||||
</action>
|
</action>
|
||||||
</release>
|
</release>
|
||||||
|
|
||||||
<release version="3.5" date="2015-04-17" description="
|
<release version="3.5" date="2015-04-17" description="
|
||||||
This is a minor release: It combines bug fixes and new features.
|
This is a minor release: It combines bug fixes and new features.
|
||||||
Changes to existing features were made in a backwards-compatible
|
Changes to existing features were made in a backwards-compatible
|
||||||
way such as to allow drop-in replacement of the v3.4.1 JAR file.
|
way such as to allow drop-in replacement of the v3.4.1 JAR file.
|
||||||
|
|
||||||
Most notable among the new features are:
|
Most notable among the new features are:
|
||||||
getQuadraticMean method added to DescriptiveStatistics SummaryStatistics
|
getQuadraticMean method added to DescriptiveStatistics SummaryStatistics
|
||||||
which calculates the root mean square, and a way to build polyhedrons sets
|
which calculates the root mean square, and a way to build polyhedrons sets
|
||||||
from list of vertices and the facets they belong too. There have been
|
from list of vertices and the facets they belong too. There have been
|
||||||
numerous bug fixes. See below for a full list.
|
numerous bug fixes. See below for a full list.
|
||||||
|
|
||||||
The minimum version of the Java platform required to compile and use
|
The minimum version of the Java platform required to compile and use
|
||||||
Apache Commons Math is Java 5.
|
Apache Commons Math is Java 5.
|
||||||
|
|
||||||
Users are encouraged to upgrade to this version as this release not
|
Users are encouraged to upgrade to this version as this release not
|
||||||
only includes bug fixes but also deprecates numerous classes and
|
only includes bug fixes but also deprecates numerous classes and
|
||||||
methods that will be deleted from the next major release (4.0).
|
methods that will be deleted from the next major release (4.0).
|
||||||
|
|
||||||
Caveat:
|
Caveat:
|
||||||
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
||||||
state (cf. MATH-621): Many code paths are untested, and we are looking
|
state (cf. MATH-621): Many code paths are untested, and we are looking
|
||||||
|
@ -783,26 +783,26 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
<action dev="luc" type="fix" issue="MATH-1195">
|
<action dev="luc" type="fix" issue="MATH-1195">
|
||||||
Moved FastMathTestPerformance out of the main test tree, as is is
|
Moved FastMathTestPerformance out of the main test tree, as is is
|
||||||
a benchmark rather than a test.
|
a benchmark rather than a test.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="add">
|
<action dev="luc" type="add">
|
||||||
Added a way to build polyhedrons sets from a list of vertices and
|
Added a way to build polyhedrons sets from a list of vertices and
|
||||||
facets specified using vertices indices.
|
facets specified using vertices indices.
|
||||||
</action>
|
</action>
|
||||||
<action dev="psteitz" type="update" issue="MATH-1213">
|
<action dev="psteitz" type="update" issue="MATH-1213">
|
||||||
Added Laguerre complex solve methods taking maxEval parameters.
|
Added Laguerre complex solve methods taking maxEval parameters.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="fix" issue="MATH-1191">
|
<action dev="luc" type="fix" issue="MATH-1191">
|
||||||
Fixed ignored method parameters in QRDecomposition protected methods.
|
Fixed ignored method parameters in QRDecomposition protected methods.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="fix" issue="MATH-1211" due-to="Mike Zimmerman">
|
<action dev="luc" type="fix" issue="MATH-1211" due-to="Mike Zimmerman">
|
||||||
Fixed wrong selection of line/polyhedron intersection point.
|
Fixed wrong selection of line/polyhedron intersection point.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="fix" issue="MATH-1162">
|
<action dev="luc" type="fix" issue="MATH-1162">
|
||||||
Improved fix for corner cases in BSP-tree merging, when cut sub-hyperplanes vanish.
|
Improved fix for corner cases in BSP-tree merging, when cut sub-hyperplanes vanish.
|
||||||
</action>
|
</action>
|
||||||
<action dev="tn" type="fix" issue="MATH-1209" due-to="Jonathan Ogilvie">
|
<action dev="tn" type="fix" issue="MATH-1209" due-to="Jonathan Ogilvie">
|
||||||
Fixed link to algorithm description in "PoissonDistribution#sample()".
|
Fixed link to algorithm description in "PoissonDistribution#sample()".
|
||||||
</action>
|
</action>
|
||||||
<action dev="psteitz" type="fix" issue="MATH-1208">
|
<action dev="psteitz" type="fix" issue="MATH-1208">
|
||||||
EmpiricalDistribution cumulativeProbability can return NaN when evaluated within a constant bin.
|
EmpiricalDistribution cumulativeProbability can return NaN when evaluated within a constant bin.
|
||||||
</action>
|
</action>
|
||||||
|
@ -835,7 +835,7 @@ This is a maintenance release: It fixes issue MATH-1188.
|
||||||
This is a minor release: It combines bug fixes and new features.
|
This is a minor release: It combines bug fixes and new features.
|
||||||
Changes to existing features were made in a backwards-compatible
|
Changes to existing features were made in a backwards-compatible
|
||||||
way such as to allow drop-in replacement of the v3.3 JAR file.
|
way such as to allow drop-in replacement of the v3.3 JAR file.
|
||||||
|
|
||||||
Most notable among the new features are:
|
Most notable among the new features are:
|
||||||
new distributions (Gumbel, Laplace, Logistic, Nakagami), and
|
new distributions (Gumbel, Laplace, Logistic, Nakagami), and
|
||||||
improvements on percentiles algorithms (better handling for NaNs
|
improvements on percentiles algorithms (better handling for NaNs
|
||||||
|
@ -844,14 +844,14 @@ Most notable among the new features are:
|
||||||
implementations added. There have been numerous bug fixes and
|
implementations added. There have been numerous bug fixes and
|
||||||
several improvements on performances or robustness. See below
|
several improvements on performances or robustness. See below
|
||||||
for a full list.
|
for a full list.
|
||||||
|
|
||||||
The minimum version of the Java platform required to compile and use
|
The minimum version of the Java platform required to compile and use
|
||||||
Apache Commons Math is Java 5.
|
Apache Commons Math is Java 5.
|
||||||
|
|
||||||
Users are encouraged to upgrade to this version as this release not
|
Users are encouraged to upgrade to this version as this release not
|
||||||
only includes bug fixes but also deprecates numerous classes and
|
only includes bug fixes but also deprecates numerous classes and
|
||||||
methods that will be deleted from the next major release (4.0).
|
methods that will be deleted from the next major release (4.0).
|
||||||
|
|
||||||
Caveat:
|
Caveat:
|
||||||
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
||||||
state (cf. MATH-621): Many code paths are untested, and we are looking
|
state (cf. MATH-621): Many code paths are untested, and we are looking
|
||||||
|
@ -870,7 +870,7 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
</action>
|
</action>
|
||||||
<action dev="psteitz" type="fix" issue="MATH-1181">
|
<action dev="psteitz" type="fix" issue="MATH-1181">
|
||||||
Fixed integer overflow in KolmogorovSmirnovTest causing 2-sample test
|
Fixed integer overflow in KolmogorovSmirnovTest causing 2-sample test
|
||||||
to use exact method when the product of the sample sizes exceeds
|
to use exact method when the product of the sample sizes exceeds
|
||||||
Integer.MAX_VALUE, resulting in effectively hung execution.
|
Integer.MAX_VALUE, resulting in effectively hung execution.
|
||||||
</action>
|
</action>
|
||||||
<action dev="erans" type="add" issue="MATH-1180">
|
<action dev="erans" type="add" issue="MATH-1180">
|
||||||
|
@ -896,14 +896,14 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="update" >
|
<action dev="luc" type="update" >
|
||||||
Spurious vertices in the middle of otherwise straight edges are now
|
Spurious vertices in the middle of otherwise straight edges are now
|
||||||
filtered out when rebuilding polygons boundaries from BSP trees.
|
filtered out when rebuilding polygons boundaries from BSP trees.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="fix" issue="MATH-1174" >
|
<action dev="luc" type="fix" issue="MATH-1174" >
|
||||||
Fixed a problem with too thin polygons considered to have infinite size.
|
Fixed a problem with too thin polygons considered to have infinite size.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="add" >
|
<action dev="luc" type="add" >
|
||||||
Boundary attributes in regions now provides the BSP tree nodes that
|
Boundary attributes in regions now provides the BSP tree nodes that
|
||||||
were used to split the sub-hyperplane forming the boundary part of the facet.
|
were used to split the sub-hyperplane forming the boundary part of the facet.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="fix" issue="MATH-1162" >
|
<action dev="luc" type="fix" issue="MATH-1162" >
|
||||||
Fixed a problem with vanishing cut sub-hyperplanes during BSP tree merging.
|
Fixed a problem with vanishing cut sub-hyperplanes during BSP tree merging.
|
||||||
|
@ -999,7 +999,7 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
Added lazy evaluation to "LeastSquaresFactory" (in "o.a.c.m.fitting.leastsquares")
|
Added lazy evaluation to "LeastSquaresFactory" (in "o.a.c.m.fitting.leastsquares")
|
||||||
to avoid evaluating the model when the optimization algorithm does not actually
|
to avoid evaluating the model when the optimization algorithm does not actually
|
||||||
require it.
|
require it.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="fix" issue="MATH-1127">
|
<action dev="luc" type="fix" issue="MATH-1127">
|
||||||
Fixed overflow in Precision.equals with ulps (both double and float versions).
|
Fixed overflow in Precision.equals with ulps (both double and float versions).
|
||||||
</action>
|
</action>
|
||||||
|
@ -1019,20 +1019,20 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
This is a minor release: It combines bug fixes and new features.
|
This is a minor release: It combines bug fixes and new features.
|
||||||
Changes to existing features were made in a backwards-compatible
|
Changes to existing features were made in a backwards-compatible
|
||||||
way such as to allow drop-in replacement of the v3.x JAR file.
|
way such as to allow drop-in replacement of the v3.x JAR file.
|
||||||
|
|
||||||
Most notable among the new features are:
|
Most notable among the new features are:
|
||||||
Framework for creating artificial neural nets, self organizing feature maps,
|
Framework for creating artificial neural nets, self organizing feature maps,
|
||||||
computational geometry algorithms (convex hull, enclosing ball), performance
|
computational geometry algorithms (convex hull, enclosing ball), performance
|
||||||
improvements of the linear simplex solver, refactoring of curve fitters,
|
improvements of the linear simplex solver, refactoring of curve fitters,
|
||||||
low-discrepancy random generators (sobol, halton), least-squares fitting.
|
low-discrepancy random generators (sobol, halton), least-squares fitting.
|
||||||
|
|
||||||
The minimum version of the Java platform required to compile and use
|
The minimum version of the Java platform required to compile and use
|
||||||
Commons Math is Java 5.
|
Commons Math is Java 5.
|
||||||
|
|
||||||
Users are encouraged to upgrade to this version as this release not
|
Users are encouraged to upgrade to this version as this release not
|
||||||
only includes bug fixes but also deprecates numerous classes and
|
only includes bug fixes but also deprecates numerous classes and
|
||||||
methods that will be deleted from the next major release (4.0).
|
methods that will be deleted from the next major release (4.0).
|
||||||
|
|
||||||
Caveat:
|
Caveat:
|
||||||
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
||||||
state (cf. MATH-621): Many code paths are untested, and we are looking
|
state (cf. MATH-621): Many code paths are untested, and we are looking
|
||||||
|
@ -1043,7 +1043,7 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
3. A few methods/constructors in the package o.a.c.m.geometry.partitioning
|
3. A few methods/constructors in the package o.a.c.m.geometry.partitioning
|
||||||
have changed their signature in a non backwards-compatible way. The respective
|
have changed their signature in a non backwards-compatible way. The respective
|
||||||
classes are intended to be package private only and are not supposed to be
|
classes are intended to be package private only and are not supposed to be
|
||||||
used for other purposes.
|
used for other purposes.
|
||||||
">
|
">
|
||||||
<action dev="tn" type="add" issue="MATH-1110" due-to="Edward Segall">
|
<action dev="tn" type="add" issue="MATH-1110" due-to="Edward Segall">
|
||||||
Added new constructor to "OLSMultipleLinearRegression" to be able
|
Added new constructor to "OLSMultipleLinearRegression" to be able
|
||||||
|
@ -1397,7 +1397,7 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
"o.a.c.m.analysis.integration.gauss").
|
"o.a.c.m.analysis.integration.gauss").
|
||||||
</action>
|
</action>
|
||||||
<action dev="erans" type="update" issue="MATH-995">
|
<action dev="erans" type="update" issue="MATH-995">
|
||||||
Documented limitation of "IterativeLegendreGaussIntegrator" (added
|
Documented limitation of "IterativeLegendreGaussIntegrator" (added
|
||||||
warning about potential wrong usage).
|
warning about potential wrong usage).
|
||||||
</action>
|
</action>
|
||||||
<action dev="erans" type="fix" issue="MATH-993">
|
<action dev="erans" type="fix" issue="MATH-993">
|
||||||
|
@ -1448,7 +1448,7 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
This is a minor release: It combines bug fixes and new features.
|
This is a minor release: It combines bug fixes and new features.
|
||||||
Changes to existing features were made in a backwards-compatible
|
Changes to existing features were made in a backwards-compatible
|
||||||
way such as to allow drop-in replacement of the v3.1[.1] JAR file.
|
way such as to allow drop-in replacement of the v3.1[.1] JAR file.
|
||||||
|
|
||||||
Most notable among the new features are: Framework for automatic
|
Most notable among the new features are: Framework for automatic
|
||||||
differentiation, Lévy distribution, prime numbers, enumerated
|
differentiation, Lévy distribution, prime numbers, enumerated
|
||||||
distributions, real field allowing to use several algorithms
|
distributions, real field allowing to use several algorithms
|
||||||
|
@ -1456,14 +1456,14 @@ Most notable among the new features are: Framework for automatic
|
||||||
classes (high accuracy or automatic differentiation), spherical
|
classes (high accuracy or automatic differentiation), spherical
|
||||||
coordinates with gradients and Hessians, reorganized clustering
|
coordinates with gradients and Hessians, reorganized clustering
|
||||||
package with different distance implementations.
|
package with different distance implementations.
|
||||||
|
|
||||||
The minimum version of the Java platform required to compile and use
|
The minimum version of the Java platform required to compile and use
|
||||||
Commons Math is Java 5.
|
Commons Math is Java 5.
|
||||||
|
|
||||||
Users are encouraged to upgrade to this version as this release not
|
Users are encouraged to upgrade to this version as this release not
|
||||||
only includes bug fixes but also deprecates numerous classes and
|
only includes bug fixes but also deprecates numerous classes and
|
||||||
methods that will be deleted from the next major release (4.0).
|
methods that will be deleted from the next major release (4.0).
|
||||||
|
|
||||||
Caveat:
|
Caveat:
|
||||||
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
||||||
state (cf. MATH-621): Many code paths are untested, and we are looking
|
state (cf. MATH-621): Many code paths are untested, and we are looking
|
||||||
|
@ -1601,17 +1601,17 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="add" >
|
<action dev="luc" type="add" >
|
||||||
Added RealFieldElement interface to represent anything that is
|
Added RealFieldElement interface to represent anything that is
|
||||||
real number like, implemented by both Decimal64, Dfp and DerivativeStructure.
|
real number like, implemented by both Decimal64, Dfp and DerivativeStructure.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="add" >
|
<action dev="luc" type="add" >
|
||||||
Added partial derivatives computation for 3D vectors and rotations.
|
Added partial derivatives computation for 3D vectors and rotations.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="fix" issue="MATH-935" >
|
<action dev="luc" type="fix" issue="MATH-935" >
|
||||||
Fixed DerivativeStructure.atan2 for special cases when both arguments are +/-0.
|
Fixed DerivativeStructure.atan2 for special cases when both arguments are +/-0.
|
||||||
</action>
|
</action>
|
||||||
<action dev="luc" type="add" >
|
<action dev="luc" type="add" >
|
||||||
Added accurate linear combination of DerivativeStructure instances,
|
Added accurate linear combination of DerivativeStructure instances,
|
||||||
avoiding cancellation.
|
avoiding cancellation.
|
||||||
</action>
|
</action>
|
||||||
<action dev="erans" type="update" issue="MATH-933">
|
<action dev="erans" type="update" issue="MATH-933">
|
||||||
Throw "MathUnsupportedOperationException" from optimizers that do
|
Throw "MathUnsupportedOperationException" from optimizers that do
|
||||||
|
@ -1626,7 +1626,7 @@ Users are encouraged to upgrade to this version as this release not
|
||||||
Greater efficiency in "UnitSphereRandomVectorGenerator".
|
Greater efficiency in "UnitSphereRandomVectorGenerator".
|
||||||
</action>
|
</action>
|
||||||
<action dev="tn" type="fix" issue="MATH-930">
|
<action dev="tn" type="fix" issue="MATH-930">
|
||||||
Improved class javadoc wrt convergence criteria and added
|
Improved class javadoc wrt convergence criteria and added
|
||||||
additional constructors to override the default epsilon and cut-off
|
additional constructors to override the default epsilon and cut-off
|
||||||
values in class "SimplexSolver".
|
values in class "SimplexSolver".
|
||||||
</action>
|
</action>
|
||||||
|
@ -1653,7 +1653,7 @@ This is a point release: It fixes a bug that renders version 3.1 unusable
|
||||||
This is a minor release: It combines bug fixes and new features.
|
This is a minor release: It combines bug fixes and new features.
|
||||||
Changes to existing features were made in a backwards-compatible
|
Changes to existing features were made in a backwards-compatible
|
||||||
way such as to allow drop-in replacement of the v3.0 JAR file.
|
way such as to allow drop-in replacement of the v3.0 JAR file.
|
||||||
|
|
||||||
Most notable among the new features are: Framework for automatic
|
Most notable among the new features are: Framework for automatic
|
||||||
differentiation, multivariate mixture model distribution, quaternions,
|
differentiation, multivariate mixture model distribution, quaternions,
|
||||||
Gauss integration framework, Hermite polynomial interpolation,
|
Gauss integration framework, Hermite polynomial interpolation,
|
||||||
|
@ -1661,13 +1661,13 @@ This is a minor release: It combines bug fixes and new features.
|
||||||
Most notable among the changes are: Greatly improved precision in
|
Most notable among the changes are: Greatly improved precision in
|
||||||
the implementation of the Gamma and Beta special functions, optimizers
|
the implementation of the Gamma and Beta special functions, optimizers
|
||||||
API, deprecation of the sparse vector implementation.
|
API, deprecation of the sparse vector implementation.
|
||||||
|
|
||||||
The minimal version of the Java platform required to compile and use
|
The minimal version of the Java platform required to compile and use
|
||||||
Commons Math is Java 5.
|
Commons Math is Java 5.
|
||||||
Users are encouraged to upgrade to this version as this release not
|
Users are encouraged to upgrade to this version as this release not
|
||||||
only includes bug fixes but also deprecates numerous classes and
|
only includes bug fixes but also deprecates numerous classes and
|
||||||
methods that will be deleted from the next major release (4.0).
|
methods that will be deleted from the next major release (4.0).
|
||||||
|
|
||||||
Caveat:
|
Caveat:
|
||||||
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
||||||
state (cf. MATH-621): Many code paths are untested, and we are looking
|
state (cf. MATH-621): Many code paths are untested, and we are looking
|
||||||
|
@ -2026,7 +2026,7 @@ Caveat:
|
||||||
for volunteers to improve the code readability, robustness and performance
|
for volunteers to improve the code readability, robustness and performance
|
||||||
and to extend the unit tests suite.
|
and to extend the unit tests suite.
|
||||||
2. A few methods in the FastMath class are in fact slower that their
|
2. A few methods in the FastMath class are in fact slower that their
|
||||||
counterpart in either Math or StrictMath (cf. MATH-740).
|
counterpart in either Math or StrictMath (cf. MATH-740).
|
||||||
">
|
">
|
||||||
<action dev="mikl" type="add" issue="MATH-431">
|
<action dev="mikl" type="add" issue="MATH-431">
|
||||||
Added statistical hypothesis tests "MannWhitneyUTest" and
|
Added statistical hypothesis tests "MannWhitneyUTest" and
|
||||||
|
|
|
@ -160,7 +160,7 @@
|
||||||
<module name="EmptyStatement" />
|
<module name="EmptyStatement" />
|
||||||
<module name="EqualsHashCode" />
|
<module name="EqualsHashCode" />
|
||||||
<!-- Method parameters and local variables should not hide fields, except in constructors and setters -->
|
<!-- Method parameters and local variables should not hide fields, except in constructors and setters -->
|
||||||
<!--
|
<!--
|
||||||
<module name="HiddenField">
|
<module name="HiddenField">
|
||||||
<property name="ignoreConstructorParameter" value="true" />
|
<property name="ignoreConstructorParameter" value="true" />
|
||||||
<property name="ignoreSetter" value="true" />
|
<property name="ignoreSetter" value="true" />
|
||||||
|
|
|
@ -50,9 +50,9 @@
|
||||||
<item name="Javadoc (2.2 release)"
|
<item name="Javadoc (2.2 release)"
|
||||||
href="http://commons.apache.org/math/javadocs/api-2.2/index.html"/>
|
href="http://commons.apache.org/math/javadocs/api-2.2/index.html"/>
|
||||||
<item name="Issue Tracking" href="/issue-tracking.html"/>
|
<item name="Issue Tracking" href="/issue-tracking.html"/>
|
||||||
<item name="Source Repository (current)"
|
<item name="Source Repository (current)"
|
||||||
href="http://gitbox.apache.org/repos/asf/commons-math.git"/>
|
href="http://gitbox.apache.org/repos/asf/commons-math.git"/>
|
||||||
<item name="Wiki"
|
<item name="Wiki"
|
||||||
href="http://wiki.apache.org/commons/Math"/>
|
href="http://wiki.apache.org/commons/Math"/>
|
||||||
<item name="Developers Guide" href="/developers.html"/>
|
<item name="Developers Guide" href="/developers.html"/>
|
||||||
<item name="Proposal" href="/proposal.html"/>
|
<item name="Proposal" href="/proposal.html"/>
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<document>
|
<document>
|
||||||
<properties>
|
<properties>
|
||||||
<title>Developers Guide</title>
|
<title>Developers Guide</title>
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
<p>
|
<p>
|
||||||
<ol>
|
<ol>
|
||||||
<li>Start by reviewing the overall objectives stated in the
|
<li>Start by reviewing the overall objectives stated in the
|
||||||
<a href="proposal.html">proposal</a> upon which the project is
|
<a href="proposal.html">proposal</a> upon which the project is
|
||||||
founded.
|
founded.
|
||||||
</li>
|
</li>
|
||||||
<li>Download the Commons Math source code. Follow the instructions
|
<li>Download the Commons Math source code. Follow the instructions
|
||||||
|
@ -57,8 +57,8 @@
|
||||||
read-write access.
|
read-write access.
|
||||||
</li>
|
</li>
|
||||||
<li>Like most commons components, Commons Math uses Apache Maven as our
|
<li>Like most commons components, Commons Math uses Apache Maven as our
|
||||||
build tool. The sources can also be built using Ant (a working
|
build tool. The sources can also be built using Ant (a working
|
||||||
Ant build.xml is included in the top level project directory).
|
Ant build.xml is included in the top level project directory).
|
||||||
To build Commons Math using Maven, you can follow the instructions for
|
To build Commons Math using Maven, you can follow the instructions for
|
||||||
<a href="http://maven.apache.org/run-maven/index.html">Building a
|
<a href="http://maven.apache.org/run-maven/index.html">Building a
|
||||||
project with Maven</a>. Launch Maven from the top-level directory
|
project with Maven</a>. Launch Maven from the top-level directory
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
on the <a href="http://wiki.apache.org/commons/MathWishList">
|
on the <a href="http://wiki.apache.org/commons/MathWishList">
|
||||||
Math Wish List Wiki Page.</a>
|
Math Wish List Wiki Page.</a>
|
||||||
</li>
|
</li>
|
||||||
<li>Be sure to join the commons-dev and commons-user
|
<li>Be sure to join the commons-dev and commons-user
|
||||||
<a href="mail-lists.html">
|
<a href="mail-lists.html">
|
||||||
email lists</a> and use them appropriately (make sure the string
|
email lists</a> and use them appropriately (make sure the string
|
||||||
"[math]" starts the Subject line of all your postings).
|
"[math]" starts the Subject line of all your postings).
|
||||||
|
@ -81,15 +81,15 @@
|
||||||
<li>
|
<li>
|
||||||
<a href="https://issues.apache.org/jira/secure/Signup!default.jspa">
|
<a href="https://issues.apache.org/jira/secure/Signup!default.jspa">
|
||||||
Setup an account on JIRA</a> and use it to submit patches and
|
Setup an account on JIRA</a> and use it to submit patches and
|
||||||
identify bugs. Read the
|
identify bugs. Read the
|
||||||
<a href="https://issues.apache.org/bugwritinghelp.html">
|
<a href="https://issues.apache.org/bugwritinghelp.html">
|
||||||
directions</a> for submitting bugs and search the database to
|
directions</a> for submitting bugs and search the database to
|
||||||
determine if an issue exists or has already been dealt with.
|
determine if an issue exists or has already been dealt with.
|
||||||
<p>
|
<p>
|
||||||
See the <a href="http://commons.apache.org/math/issue-tracking.html">
|
See the <a href="http://commons.apache.org/math/issue-tracking.html">
|
||||||
Commons Math Issue Tracking Page</a> for more information on how to
|
Commons Math Issue Tracking Page</a> for more information on how to
|
||||||
search for or submit bugs or enhancement requests.
|
search for or submit bugs or enhancement requests.
|
||||||
</p>
|
</p>
|
||||||
<li>
|
<li>
|
||||||
Generating patches: The requested format for generating patches is
|
Generating patches: The requested format for generating patches is
|
||||||
the Unified Diff format, which can be easily generated using the git
|
the Unified Diff format, which can be easily generated using the git
|
||||||
|
@ -105,7 +105,7 @@
|
||||||
<p>
|
<p>
|
||||||
Follow the steps below when making suggestions for additions or
|
Follow the steps below when making suggestions for additions or
|
||||||
enhancements to Commons Math. This will make it easier for the community
|
enhancements to Commons Math. This will make it easier for the community
|
||||||
to comment on your ideas and for the committers to keep track of them.
|
to comment on your ideas and for the committers to keep track of them.
|
||||||
Thanks in advance!
|
Thanks in advance!
|
||||||
<ol>
|
<ol>
|
||||||
<li>Start with a post to the commons-dev mailing list, with [math] at
|
<li>Start with a post to the commons-dev mailing list, with [math] at
|
||||||
|
@ -122,7 +122,7 @@
|
||||||
useful</li>
|
useful</li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li>Assuming a generally favorable response to the idea on commons-dev,
|
<li>Assuming a generally favorable response to the idea on commons-dev,
|
||||||
the next step is to add an entry to the
|
the next step is to add an entry to the
|
||||||
<a href="http://wiki.apache.org/commons/MathWishList">Math Wish
|
<a href="http://wiki.apache.org/commons/MathWishList">Math Wish
|
||||||
List</a> corresponding to the idea. Include a reference to the
|
List</a> corresponding to the idea. Include a reference to the
|
||||||
discussion thread. </li>
|
discussion thread. </li>
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
ticket if a patch goes more than a few days with no comment or commit.
|
ticket if a patch goes more than a few days with no comment or commit.
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</ol>
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
<subsection name='Coding Style'>
|
<subsection name='Coding Style'>
|
||||||
<p>
|
<p>
|
||||||
|
@ -191,7 +191,7 @@
|
||||||
formulas and escape special characters.</li>
|
formulas and escape special characters.</li>
|
||||||
<li>
|
<li>
|
||||||
Implementations <i>should</i> use standard algorithms and
|
Implementations <i>should</i> use standard algorithms and
|
||||||
references or full descriptions of all algorithms <i>should</i> be
|
references or full descriptions of all algorithms <i>should</i> be
|
||||||
provided.</li>
|
provided.</li>
|
||||||
<li>
|
<li>
|
||||||
Additions and enhancements <i>should</i> include updates to the User
|
Additions and enhancements <i>should</i> include updates to the User
|
||||||
|
@ -232,11 +232,11 @@
|
||||||
impossible to specify because of numerical properties of the method.
|
impossible to specify because of numerical properties of the method.
|
||||||
If a solver fails to find a root or a quadrature method fails to converge
|
If a solver fails to find a root or a quadrature method fails to converge
|
||||||
for a given set of parameters, <i>unless those parameters violate the
|
for a given set of parameters, <i>unless those parameters violate the
|
||||||
advertised preconditions</i> it is not appropriate to throw
|
advertised preconditions</i> it is not appropriate to throw
|
||||||
MathIllegalArgumentException.</li>
|
MathIllegalArgumentException.</li>
|
||||||
<li>
|
<li>
|
||||||
State information included in exception messages <i>must</i> be available
|
State information included in exception messages <i>must</i> be available
|
||||||
in exception properties - i.e., successful handling or reporting of
|
in exception properties - i.e., successful handling or reporting of
|
||||||
Commons Math exceptions must not require parsing exception messages.</li>
|
Commons Math exceptions must not require parsing exception messages.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</subsection>
|
</subsection>
|
||||||
|
@ -259,7 +259,7 @@
|
||||||
All new source file submissions <i>must</i> include the Apache Software
|
All new source file submissions <i>must</i> include the Apache Software
|
||||||
License in a comment that begins the file </li>
|
License in a comment that begins the file </li>
|
||||||
<li>
|
<li>
|
||||||
All contributions must comply with the terms of the Apache
|
All contributions must comply with the terms of the Apache
|
||||||
<a href="http://www.apache.org/licenses/cla.pdf">Contributor License
|
<a href="http://www.apache.org/licenses/cla.pdf">Contributor License
|
||||||
Agreement (CLA)</a></li>
|
Agreement (CLA)</a></li>
|
||||||
<li>
|
<li>
|
||||||
|
@ -271,7 +271,7 @@
|
||||||
<li>
|
<li>
|
||||||
References to source materials covered by restrictive proprietary
|
References to source materials covered by restrictive proprietary
|
||||||
licenses should be avoided. In particular, contributions should not
|
licenses should be avoided. In particular, contributions should not
|
||||||
implement or include references to algorithms in
|
implement or include references to algorithms in
|
||||||
<a href="http://www.nr.com/">Numerical Recipes (NR)</a>.
|
<a href="http://www.nr.com/">Numerical Recipes (NR)</a>.
|
||||||
Any questions about copyright or patent issues should be raised on
|
Any questions about copyright or patent issues should be raised on
|
||||||
the commons-dev mailing list before contributing or committing code.
|
the commons-dev mailing list before contributing or committing code.
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<document>
|
<document>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
<section name="Download Math">
|
<section name="Download Math">
|
||||||
<subsection name="Releases">
|
<subsection name="Releases">
|
||||||
<p>
|
<p>
|
||||||
Download the
|
Download the
|
||||||
<a href="http://commons.apache.org/math/download_math.cgi">
|
<a href="http://commons.apache.org/math/download_math.cgi">
|
||||||
Latest Release</a> of Commons Math.
|
Latest Release</a> of Commons Math.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -48,7 +48,7 @@ limitations under the License.
|
||||||
|
|
||||||
<section name="Overview">
|
<section name="Overview">
|
||||||
<p>
|
<p>
|
||||||
<a href="index.html">Commons Math</a> shares mailing lists with all the other
|
<a href="index.html">Commons Math</a> shares mailing lists with all the other
|
||||||
<a href="http://commons.apache.org/components.html">Commons Components</a>.
|
<a href="http://commons.apache.org/components.html">Commons Components</a>.
|
||||||
To make it easier for people to only read messages related to components they are interested in,
|
To make it easier for people to only read messages related to components they are interested in,
|
||||||
the convention in Commons is to prefix the subject line of messages with the component's name,
|
the convention in Commons is to prefix the subject line of messages with the component's name,
|
||||||
|
@ -68,8 +68,8 @@ limitations under the License.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<strong>Note:</strong> please don't send patches or attachments to any of the mailing lists.
|
<strong>Note:</strong> please don't send patches or attachments to any of the mailing lists.
|
||||||
Patches are best handled via the <a href="issue-tracking.html">Issue Tracking</a> system.
|
Patches are best handled via the <a href="issue-tracking.html">Issue Tracking</a> system.
|
||||||
Otherwise, please upload the file to a public server and include the URL in the mail.
|
Otherwise, please upload the file to a public server and include the URL in the mail.
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
@ -185,10 +185,10 @@ limitations under the License.
|
||||||
General announcements of Apache project releases.
|
General announcements of Apache project releases.
|
||||||
<br /><br />
|
<br /><br />
|
||||||
</td>
|
</td>
|
||||||
<td><a class="externalLink" href="mailto:announce-subscribe@apache.org">Subscribe</a></td>
|
<td><a class="externalLink" href="mailto:announce-subscribe@apache.org">Subscribe</a></td>
|
||||||
<td><a class="externalLink" href="mailto:announce-unsubscribe@apache.org">Unsubscribe</a></td>
|
<td><a class="externalLink" href="mailto:announce-unsubscribe@apache.org">Unsubscribe</a></td>
|
||||||
<td><i>read only</i></td>
|
<td><i>read only</i></td>
|
||||||
<td><a class="externalLink" href="https://mail-archives.apache.org/mod_mbox/www-announce/">mail-archives.apache.org</a></td>
|
<td><a class="externalLink" href="https://mail-archives.apache.org/mod_mbox/www-announce/">mail-archives.apache.org</a></td>
|
||||||
<td><a class="externalLink" href="http://markmail.org/list/org.apache.announce/">markmail.org</a><br />
|
<td><a class="externalLink" href="http://markmail.org/list/org.apache.announce/">markmail.org</a><br />
|
||||||
<a class="externalLink" href="http://old.nabble.com/Apache-News-and-Announce-f109.html">old.nabble.com</a><br />
|
<a class="externalLink" href="http://old.nabble.com/Apache-News-and-Announce-f109.html">old.nabble.com</a><br />
|
||||||
<a class="externalLink" href="http://www.mail-archive.com/announce@apache.org/">www.mail-archive.com</a><br />
|
<a class="externalLink" href="http://www.mail-archive.com/announce@apache.org/">www.mail-archive.com</a><br />
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<document>
|
<document>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -29,40 +29,40 @@
|
||||||
<section name='Proposal for math Package'>
|
<section name='Proposal for math Package'>
|
||||||
|
|
||||||
<subsection name='(0) Rationale'>
|
<subsection name='(0) Rationale'>
|
||||||
<p>The Java programming language and the math extensions in commons-lang provide implementations
|
<p>The Java programming language and the math extensions in commons-lang provide implementations
|
||||||
for only the most basic mathematical algorithms. Routine development tasks such as computing
|
for only the most basic mathematical algorithms. Routine development tasks such as computing
|
||||||
basic statistics or solving a system of linear equations require components not available in java
|
basic statistics or solving a system of linear equations require components not available in java
|
||||||
or commons-lang.</p>
|
or commons-lang.</p>
|
||||||
|
|
||||||
<p>Most basic mathematical or statistical algorithms are available in open source implementations,
|
<p>Most basic mathematical or statistical algorithms are available in open source implementations,
|
||||||
but to assemble a simple set of capabilities one has to use multiple libraries, many of which have
|
but to assemble a simple set of capabilities one has to use multiple libraries, many of which have
|
||||||
more restrictive licensing terms than the ASF. In addition, many of the best open source
|
more restrictive licensing terms than the ASF. In addition, many of the best open source
|
||||||
implementations (e.g. the R statistical package) are either not available in Java or require large
|
implementations (e.g. the R statistical package) are either not available in Java or require large
|
||||||
support libraries and/or external dependencies to work.</p>
|
support libraries and/or external dependencies to work.</p>
|
||||||
|
|
||||||
<p>A commons-math community will provide a productive environment for aggregation, testing and
|
<p>A commons-math community will provide a productive environment for aggregation, testing and
|
||||||
support of efficient Java implementations of commonly used mathematical and statistical algorithms.</p>
|
support of efficient Java implementations of commonly used mathematical and statistical algorithms.</p>
|
||||||
|
|
||||||
</subsection>
|
</subsection>
|
||||||
|
|
||||||
<subsection name='(1) Scope of the Package'>
|
<subsection name='(1) Scope of the Package'>
|
||||||
|
|
||||||
<p>The Math project shall create and maintain a library of lightweight, self-contained mathematics
|
<p>The Math project shall create and maintain a library of lightweight, self-contained mathematics
|
||||||
and statistics components addressing the most common practical problems not immediately available in
|
and statistics components addressing the most common practical problems not immediately available in
|
||||||
the Java programming language or commons-lang. The guiding principles for commons-math will be:
|
the Java programming language or commons-lang. The guiding principles for commons-math will be:
|
||||||
|
|
||||||
<ol>
|
<ol>
|
||||||
<li>Real-world application use cases determine priority</li>
|
<li>Real-world application use cases determine priority</li>
|
||||||
<li>Emphasis on small, easily integrated components rather than large libraries with complex
|
<li>Emphasis on small, easily integrated components rather than large libraries with complex
|
||||||
dependencies</li>
|
dependencies</li>
|
||||||
<li>All algorithms are fully documented and follow generally accepted best practices</li>
|
<li>All algorithms are fully documented and follow generally accepted best practices</li>
|
||||||
<li>In situations where multiple standard algorithms exist, use the Strategy pattern to support
|
<li>In situations where multiple standard algorithms exist, use the Strategy pattern to support
|
||||||
multiple implementations</li>
|
multiple implementations</li>
|
||||||
<li>Limited dependencies. No external dependencies beyond Commons components and the JDK</li>
|
<li>Limited dependencies. No external dependencies beyond Commons components and the JDK</li>
|
||||||
</ol>
|
</ol>
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
|
|
||||||
<subsection name='(1.5) Interaction With Other Packages'>
|
<subsection name='(1.5) Interaction With Other Packages'>
|
||||||
|
|
||||||
<p><em>math</em> relies only on standard JDK 1.2 (or later) APIs for
|
<p><em>math</em> relies only on standard JDK 1.2 (or later) APIs for
|
||||||
|
@ -75,7 +75,7 @@ developers of the component.</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
<subsection name='(2) Initial Source of the Package'>
|
<subsection name='(2) Initial Source of the Package'>
|
||||||
|
|
||||||
<p>The initial codebase will consist of implementations of basic statistical algorithms such
|
<p>The initial codebase will consist of implementations of basic statistical algorithms such
|
||||||
as the following:
|
as the following:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Simple univariate statistics (mean, standard deviation, n, confidence intervals)</li>
|
<li>Simple univariate statistics (mean, standard deviation, n, confidence intervals)</li>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="analysis.html">
|
<document url="analysis.html">
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -215,7 +215,7 @@
|
||||||
This may again result in roots way off the true value, without
|
This may again result in roots way off the true value, without
|
||||||
indication. There is not much a generic algorithm can do if
|
indication. There is not much a generic algorithm can do if
|
||||||
ill-conditioned problems are met. A way around this is to transform
|
ill-conditioned problems are met. A way around this is to transform
|
||||||
the problem in order to get a better conditioned function. Proper
|
the problem in order to get a better conditioned function. Proper
|
||||||
selection of a root-finding algorithm and its configuration parameters
|
selection of a root-finding algorithm and its configuration parameters
|
||||||
requires knowledge of the analytical properties of the function under
|
requires knowledge of the analytical properties of the function under
|
||||||
analysis and numerical analysis techniques. Users are encouraged
|
analysis and numerical analysis techniques. Users are encouraged
|
||||||
|
@ -339,7 +339,7 @@ double c = UnivariateSolverUtils.forceSide(100, function,
|
||||||
+0.0001, the value may be decreased. For computing roots
|
+0.0001, the value may be decreased. For computing roots
|
||||||
much larger in absolute value than 100, the default absolute
|
much larger in absolute value than 100, the default absolute
|
||||||
accuracy may never be reached because the given relative
|
accuracy may never be reached because the given relative
|
||||||
accuracy is reached first.
|
accuracy is reached first.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -375,7 +375,7 @@ double c = UnivariateSolverUtils.forceSide(100, function,
|
||||||
<p>
|
<p>
|
||||||
A <a href="../apidocs/org/apache/commons/math4/analysis/interpolation/UnivariateInterpolator.html">
|
A <a href="../apidocs/org/apache/commons/math4/analysis/interpolation/UnivariateInterpolator.html">
|
||||||
UnivariateInterpolator</a> is used to find a univariate real-valued
|
UnivariateInterpolator</a> is used to find a univariate real-valued
|
||||||
function <code>f</code> which for a given set of ordered pairs
|
function <code>f</code> which for a given set of ordered pairs
|
||||||
(<code>x<sub>i</sub></code>,<code>y<sub>i</sub></code>) yields
|
(<code>x<sub>i</sub></code>,<code>y<sub>i</sub></code>) yields
|
||||||
<code>f(x<sub>i</sub>)=y<sub>i</sub></code> to the best accuracy possible. The result
|
<code>f(x<sub>i</sub>)=y<sub>i</sub></code> to the best accuracy possible. The result
|
||||||
is provided as an object implementing the <a
|
is provided as an object implementing the <a
|
||||||
|
@ -387,7 +387,7 @@ double c = UnivariateSolverUtils.forceSide(100, function,
|
||||||
interpolation algorithm is more determined by the kind of the interpolated function
|
interpolation algorithm is more determined by the kind of the interpolated function
|
||||||
rather than the set of points to interpolate.
|
rather than the set of points to interpolate.
|
||||||
There aren't currently any accuracy controls either, as interpolation
|
There aren't currently any accuracy controls either, as interpolation
|
||||||
accuracy is in general determined by the algorithm.
|
accuracy is in general determined by the algorithm.
|
||||||
</p>
|
</p>
|
||||||
<p>Typical usage:</p>
|
<p>Typical usage:</p>
|
||||||
<source>double x[] = { 0.0, 1.0, 2.0 };
|
<source>double x[] = { 0.0, 1.0, 2.0 };
|
||||||
|
@ -405,7 +405,7 @@ System.out println("f(" + interpolationX + ") = " + interpolatedY);</source>
|
||||||
is continuous, smooth and can be differentiated twice. The second
|
is continuous, smooth and can be differentiated twice. The second
|
||||||
derivative is continuous but not smooth. The x values passed to the
|
derivative is continuous but not smooth. The x values passed to the
|
||||||
interpolator must be ordered in ascending order. It is not valid to
|
interpolator must be ordered in ascending order. It is not valid to
|
||||||
evaluate the function for values outside the range
|
evaluate the function for values outside the range
|
||||||
<code>x<sub>0</sub></code>..<code>x<sub>N</sub></code>.
|
<code>x<sub>0</sub></code>..<code>x<sub>N</sub></code>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
@ -525,7 +525,7 @@ System.out.println("interpolation polynomial: " + interpolator.getPolynomials()[
|
||||||
trapezoid method</a></li>
|
trapezoid method</a></li>
|
||||||
<li><a href="../apidocs/org/apache/commons/math4/analysis/integration/LegendreGaussIntegrator.html">
|
<li><a href="../apidocs/org/apache/commons/math4/analysis/integration/LegendreGaussIntegrator.html">
|
||||||
Legendre-Gauss method</a></li>
|
Legendre-Gauss method</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
<subsection name="4.6 Polynomials" href="polynomials">
|
<subsection name="4.6 Polynomials" href="polynomials">
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="stat.html">
|
<document url="stat.html">
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="exceptions.html">
|
<document url="exceptions.html">
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -7,16 +7,16 @@
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
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 not use this file except in compliance with
|
||||||
the License. You may obtain a copy of the License at
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="filter.html">
|
<document url="filter.html">
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -34,11 +34,11 @@
|
||||||
<a href="../apidocs/org/apache/commons/math4/filter/KalmanFilter.html">
|
<a href="../apidocs/org/apache/commons/math4/filter/KalmanFilter.html">
|
||||||
KalmanFilter</a> provides a discrete-time filter to estimate
|
KalmanFilter</a> provides a discrete-time filter to estimate
|
||||||
a stochastic linear process.</p>
|
a stochastic linear process.</p>
|
||||||
|
|
||||||
<p>A Kalman filter is initialized with a <a href="../apidocs/org/apache/commons/math4/filter/ProcessModel.html">
|
<p>A Kalman filter is initialized with a <a href="../apidocs/org/apache/commons/math4/filter/ProcessModel.html">
|
||||||
ProcessModel</a> and a <a href="../apidocs/org/apache/commons/math4/filter/MeasurementModel.html">
|
ProcessModel</a> and a <a href="../apidocs/org/apache/commons/math4/filter/MeasurementModel.html">
|
||||||
MeasurementModel</a>, which contain the corresponding transformation and noise covariance matrices.
|
MeasurementModel</a>, which contain the corresponding transformation and noise covariance matrices.
|
||||||
The parameter names used in the respective models correspond to the following names commonly used
|
The parameter names used in the respective models correspond to the following names commonly used
|
||||||
in the mathematical literature:
|
in the mathematical literature:
|
||||||
<ul>
|
<ul>
|
||||||
<li>A - state transition matrix</li>
|
<li>A - state transition matrix</li>
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
<p>
|
<p>
|
||||||
<dl>
|
<dl>
|
||||||
<dt>Initialization</dt>
|
<dt>Initialization</dt>
|
||||||
<dd> The following code will create a Kalman filter using the provided
|
<dd> The following code will create a Kalman filter using the provided
|
||||||
DefaultMeasurementModel and DefaultProcessModel classes. To support dynamically changing
|
DefaultMeasurementModel and DefaultProcessModel classes. To support dynamically changing
|
||||||
process and measurement noises, simply implement your own models.
|
process and measurement noises, simply implement your own models.
|
||||||
<source>
|
<source>
|
||||||
|
@ -74,7 +74,7 @@ KalmanFilter filter = new KalmanFilter(pm, mm);
|
||||||
</source>
|
</source>
|
||||||
</dd>
|
</dd>
|
||||||
<dt>Iteration</dt>
|
<dt>Iteration</dt>
|
||||||
<dd>The following code illustrates how to perform the predict/correct cycle:
|
<dd>The following code illustrates how to perform the predict/correct cycle:
|
||||||
<source>
|
<source>
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// predict the state estimate one time-step ahead
|
// predict the state estimate one time-step ahead
|
||||||
|
@ -86,15 +86,15 @@ for (;;) {
|
||||||
|
|
||||||
// correct the state estimate with the latest measurement
|
// correct the state estimate with the latest measurement
|
||||||
filter.correct(z);
|
filter.correct(z);
|
||||||
|
|
||||||
double[] stateEstimate = filter.getStateEstimation();
|
double[] stateEstimate = filter.getStateEstimation();
|
||||||
// do something with it
|
// do something with it
|
||||||
}
|
}
|
||||||
</source>
|
</source>
|
||||||
</dd>
|
</dd>
|
||||||
<dt>Constant Voltage Example</dt>
|
<dt>Constant Voltage Example</dt>
|
||||||
<dd>The following example creates a Kalman filter for a static process: a system with a
|
<dd>The following example creates a Kalman filter for a static process: a system with a
|
||||||
constant voltage as internal state. We observe this process with an artificially
|
constant voltage as internal state. We observe this process with an artificially
|
||||||
imposed measurement noise of 0.1V and assume an internal process noise of 1e-5V.
|
imposed measurement noise of 0.1V and assume an internal process noise of 1e-5V.
|
||||||
<source>
|
<source>
|
||||||
double constantVoltage = 10d;
|
double constantVoltage = 10d;
|
||||||
|
@ -118,7 +118,7 @@ RealMatrix R = new Array2DRowRealMatrix(new double[] { measurementNoise });
|
||||||
|
|
||||||
ProcessModel pm = new DefaultProcessModel(A, B, Q, x, P0);
|
ProcessModel pm = new DefaultProcessModel(A, B, Q, x, P0);
|
||||||
MeasurementModel mm = new DefaultMeasurementModel(H, R);
|
MeasurementModel mm = new DefaultMeasurementModel(H, R);
|
||||||
KalmanFilter filter = new KalmanFilter(pm, mm);
|
KalmanFilter filter = new KalmanFilter(pm, mm);
|
||||||
|
|
||||||
// process and measurement noise vectors
|
// process and measurement noise vectors
|
||||||
RealVector pNoise = new ArrayRealVector(1);
|
RealVector pNoise = new ArrayRealVector(1);
|
||||||
|
@ -148,7 +148,7 @@ for (int i = 0; i < 60; i++) {
|
||||||
</source>
|
</source>
|
||||||
</dd>
|
</dd>
|
||||||
<dt>Increasing Speed Vehicle Example</dt>
|
<dt>Increasing Speed Vehicle Example</dt>
|
||||||
<dd>The following example creates a Kalman filter for a simple linear process: a
|
<dd>The following example creates a Kalman filter for a simple linear process: a
|
||||||
vehicle driving along a street with a velocity increasing at a constant rate. The process
|
vehicle driving along a street with a velocity increasing at a constant rate. The process
|
||||||
state is modeled as (position, velocity) and we only observe the position. A measurement
|
state is modeled as (position, velocity) and we only observe the position. A measurement
|
||||||
noise of 10m is imposed on the simulated measurement.
|
noise of 10m is imposed on the simulated measurement.
|
||||||
|
@ -217,9 +217,9 @@ for (int i = 0; i < 60; i++) {
|
||||||
double velocity = filter.getStateEstimation()[1];
|
double velocity = filter.getStateEstimation()[1];
|
||||||
}
|
}
|
||||||
</source>
|
</source>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
</section>
|
</section>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -7,16 +7,16 @@
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
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 not use this file except in compliance with
|
||||||
the License. You may obtain a copy of the License at
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="fraction.html">
|
<document url="fraction.html">
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -7,16 +7,16 @@
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
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 not use this file except in compliance with
|
||||||
the License. You may obtain a copy of the License at
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="genetics.html">
|
<document url="genetics.html">
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -26,17 +26,17 @@
|
||||||
<section name="16 Genetic Algorithms">
|
<section name="16 Genetic Algorithms">
|
||||||
<subsection name="16.1 Overview" href="overview">
|
<subsection name="16.1 Overview" href="overview">
|
||||||
<p>
|
<p>
|
||||||
The genetics package provides a framework and implementations for
|
The genetics package provides a framework and implementations for
|
||||||
genetic algorithms.
|
genetic algorithms.
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
<subsection name="16.2 GA Framework">
|
<subsection name="16.2 GA Framework">
|
||||||
<p>
|
<p>
|
||||||
<a href="../apidocs/org/apache/commons/math4/genetics/GeneticAlgorithm.html">
|
<a href="../apidocs/org/apache/commons/math4/genetics/GeneticAlgorithm.html">
|
||||||
GeneticAlgorithm</a> provides an execution framework for Genetic Algorithms (GA).
|
GeneticAlgorithm</a> provides an execution framework for Genetic Algorithms (GA).
|
||||||
<a href="../apidocs/org/apache/commons/math4/genetics/Population.html">
|
<a href="../apidocs/org/apache/commons/math4/genetics/Population.html">
|
||||||
Populations,</a> consisting of <a href="../apidocs/org/apache/commons/math4/genetics/Chromosome.html">
|
Populations,</a> consisting of <a href="../apidocs/org/apache/commons/math4/genetics/Chromosome.html">
|
||||||
Chromosomes</a> are evolved by the <code>GeneticAlgorithm</code> until a
|
Chromosomes</a> are evolved by the <code>GeneticAlgorithm</code> until a
|
||||||
<a href="../apidocs/org/apache/commons/math4/genetics/StoppingCondition.html">
|
<a href="../apidocs/org/apache/commons/math4/genetics/StoppingCondition.html">
|
||||||
StoppingCondition</a> is reached. Evolution is determined by <a href="../apidocs/org/apache/commons/math4/genetics/SelectionPolicy.html">
|
StoppingCondition</a> is reached. Evolution is determined by <a href="../apidocs/org/apache/commons/math4/genetics/SelectionPolicy.html">
|
||||||
SelectionPolicy</a>, <a href="../apidocs/org/apache/commons/math4/genetics/MutationPolicy.html">
|
SelectionPolicy</a>, <a href="../apidocs/org/apache/commons/math4/genetics/MutationPolicy.html">
|
||||||
|
@ -62,10 +62,10 @@
|
||||||
<li>Loop until new generation is filled:</li>
|
<li>Loop until new generation is filled:</li>
|
||||||
<ul><li>Apply configured <code>SelectionPolicy</code> to select a pair of parents
|
<ul><li>Apply configured <code>SelectionPolicy</code> to select a pair of parents
|
||||||
from <code>current</code></li>
|
from <code>current</code></li>
|
||||||
<li>With probability =
|
<li>With probability =
|
||||||
<a href="../apidocs/org/apache/commons/math4/genetics/GeneticAlgorithm.html#getCrossoverRate()">
|
<a href="../apidocs/org/apache/commons/math4/genetics/GeneticAlgorithm.html#getCrossoverRate()">
|
||||||
getCrossoverRate()</a>, apply configured <code>CrossoverPolicy</code> to parents</li>
|
getCrossoverRate()</a>, apply configured <code>CrossoverPolicy</code> to parents</li>
|
||||||
<li>With probability =
|
<li>With probability =
|
||||||
<a href="../apidocs/org/apache/commons/math4/genetics/GeneticAlgorithm.html#getMutationRate()">
|
<a href="../apidocs/org/apache/commons/math4/genetics/GeneticAlgorithm.html#getMutationRate()">
|
||||||
getMutationRate()</a>,
|
getMutationRate()</a>,
|
||||||
apply configured <code>MutationPolicy</code> to each of the offspring</li>
|
apply configured <code>MutationPolicy</code> to each of the offspring</li>
|
||||||
|
@ -73,7 +73,7 @@
|
||||||
space permitting</li>
|
space permitting</li>
|
||||||
</ul>
|
</ul>
|
||||||
<li>Return nextGeneration</li>
|
<li>Return nextGeneration</li>
|
||||||
</ol>
|
</ol>
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
<subsection name="16.3 Implementation">
|
<subsection name="16.3 Implementation">
|
||||||
|
@ -88,16 +88,16 @@ GeneticAlgorithm ga = new GeneticAlgorithm(
|
||||||
0.10,
|
0.10,
|
||||||
new TournamentSelection(TOURNAMENT_ARITY)
|
new TournamentSelection(TOURNAMENT_ARITY)
|
||||||
);
|
);
|
||||||
|
|
||||||
// initial population
|
// initial population
|
||||||
Population initial = getInitialPopulation();
|
Population initial = getInitialPopulation();
|
||||||
|
|
||||||
// stopping condition
|
// stopping condition
|
||||||
StoppingCondition stopCond = new FixedGenerationCount(NUM_GENERATIONS);
|
StoppingCondition stopCond = new FixedGenerationCount(NUM_GENERATIONS);
|
||||||
|
|
||||||
// run the algorithm
|
// run the algorithm
|
||||||
Population finalPopulation = ga.evolve(initial, stopCond);
|
Population finalPopulation = ga.evolve(initial, stopCond);
|
||||||
|
|
||||||
// best chromosome from the final population
|
// best chromosome from the final population
|
||||||
Chromosome bestFinal = finalPopulation.getFittestChromosome();
|
Chromosome bestFinal = finalPopulation.getFittestChromosome();
|
||||||
</source>
|
</source>
|
||||||
|
@ -122,7 +122,7 @@ Chromosome bestFinal = finalPopulation.getFittestChromosome();
|
||||||
<td>Each of the two selected chromosomes is selected based on an n-ary tournament -- this is done by drawing
|
<td>Each of the two selected chromosomes is selected based on an n-ary tournament -- this is done by drawing
|
||||||
n random chromosomes without replacement from the population, and then selecting the fittest chromosome among them.</td></tr>
|
n random chromosomes without replacement from the population, and then selecting the fittest chromosome among them.</td></tr>
|
||||||
</table><br/>
|
</table><br/>
|
||||||
The algorithm starts with an <code>initial</code> population of <code>Chromosomes.</code> and executes until
|
The algorithm starts with an <code>initial</code> population of <code>Chromosomes.</code> and executes until
|
||||||
the specified <a href="../apidocs/org/apache/commons/math4/genetics/StoppingCondition.html">StoppingCondition</a>
|
the specified <a href="../apidocs/org/apache/commons/math4/genetics/StoppingCondition.html">StoppingCondition</a>
|
||||||
is reached. In the example above, a
|
is reached. In the example above, a
|
||||||
<a href="../apidocs/org/apache/commons/math4/genetics/FixedGenerationCount.html">FixedGenerationCount</a>
|
<a href="../apidocs/org/apache/commons/math4/genetics/FixedGenerationCount.html">FixedGenerationCount</a>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="geometry.html">
|
<document url="geometry.html">
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="index.html">
|
<document url="index.html">
|
||||||
<properties>
|
<properties>
|
||||||
|
@ -58,24 +58,24 @@
|
||||||
<li><a href="linear.html#a3.1_Overview">3.1 Overview</a></li>
|
<li><a href="linear.html#a3.1_Overview">3.1 Overview</a></li>
|
||||||
<li><a href="linear.html#a3.2_Real_matrices">3.2 Real matrices</a></li>
|
<li><a href="linear.html#a3.2_Real_matrices">3.2 Real matrices</a></li>
|
||||||
<li><a href="linear.html#a3.3_Real_vectors">3.3 Real vectors</a></li>
|
<li><a href="linear.html#a3.3_Real_vectors">3.3 Real vectors</a></li>
|
||||||
<li><a href="linear.html#a3.4_Solving_linear_systems">3.4 Solving linear systems</a></li>
|
<li><a href="linear.html#a3.4_Solving_linear_systems">3.4 Solving linear systems</a></li>
|
||||||
<li><a href="linear.html#a3.5_Eigenvalueseigenvectors_and_singular_valuessingular_vectors">3.5 Eigenvalues/eigenvectors and singular values/singular vectors</a></li>
|
<li><a href="linear.html#a3.5_Eigenvalueseigenvectors_and_singular_valuessingular_vectors">3.5 Eigenvalues/eigenvectors and singular values/singular vectors</a></li>
|
||||||
<li><a href="linear.html#a3.6_Non-real_fields_complex_fractions_...">3.6 Non-real fields (complex, fractions ...)</a></li>
|
<li><a href="linear.html#a3.6_Non-real_fields_complex_fractions_...">3.6 Non-real fields (complex, fractions ...)</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="analysis.html">4. Numerical Analysis</a>
|
<li><a href="analysis.html">4. Numerical Analysis</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="analysis.html#a4.1_Overview">4.1 Overview</a></li>
|
<li><a href="analysis.html#a4.1_Overview">4.1 Overview</a></li>
|
||||||
<li><a href="analysis.html#a4.2_Error-handling">4.2 Error handling</a></li>
|
<li><a href="analysis.html#a4.2_Error-handling">4.2 Error handling</a></li>
|
||||||
<li><a href="analysis.html#a4.3_Root-finding">4.3 Root-finding</a></li>
|
<li><a href="analysis.html#a4.3_Root-finding">4.3 Root-finding</a></li>
|
||||||
<li><a href="analysis.html#a4.4_Interpolation">4.4 Interpolation</a></li>
|
<li><a href="analysis.html#a4.4_Interpolation">4.4 Interpolation</a></li>
|
||||||
<li><a href="analysis.html#a4.5_Integration">4.5 Integration</a></li>
|
<li><a href="analysis.html#a4.5_Integration">4.5 Integration</a></li>
|
||||||
<li><a href="analysis.html#a4.6_Polynomials">4.6 Polynomials</a></li>
|
<li><a href="analysis.html#a4.6_Polynomials">4.6 Polynomials</a></li>
|
||||||
<li><a href="analysis.html#a4.7_Differentiation">4.7 Differentiation</a></li>
|
<li><a href="analysis.html#a4.7_Differentiation">4.7 Differentiation</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="special.html">5. Special Functions</a>
|
<li><a href="special.html">5. Special Functions</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="special.html#a5.1_Overview">5.1 Overview</a></li>
|
<li><a href="special.html#a5.1_Overview">5.1 Overview</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="utilities.html">6. Utilities</a>
|
<li><a href="utilities.html">6. Utilities</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="utilities.html#a6.1_Overview">6.1 Overview</a></li>
|
<li><a href="utilities.html#a6.1_Overview">6.1 Overview</a></li>
|
||||||
|
@ -85,25 +85,25 @@
|
||||||
<li><a href="utilities.html#a6.5_binomial_coefficients_factorials_Stirling_numbers_and_other_common_math_functions">6.5 Binomial coefficients, factorials, Stirling numbers and other common math functions</a></li>
|
<li><a href="utilities.html#a6.5_binomial_coefficients_factorials_Stirling_numbers_and_other_common_math_functions">6.5 Binomial coefficients, factorials, Stirling numbers and other common math functions</a></li>
|
||||||
<li><a href="utilities.html#a6.6_fast_math">6.6 Fast mathematical functions</a></li>
|
<li><a href="utilities.html#a6.6_fast_math">6.6 Fast mathematical functions</a></li>
|
||||||
<li><a href="utilities.html#a6.7_miscellaneous">6.7 Miscellaneous</a></li>
|
<li><a href="utilities.html#a6.7_miscellaneous">6.7 Miscellaneous</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="complex.html">7. Complex Numbers</a>
|
<li><a href="complex.html">7. Complex Numbers</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="complex.html#a7.1_Overview">7.1 Overview</a></li>
|
<li><a href="complex.html#a7.1_Overview">7.1 Overview</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="distribution.html">8. Probability Distributions</a>
|
<li><a href="distribution.html">8. Probability Distributions</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="distribution.html#a8.1_Overview">8.1 Overview</a></li>
|
<li><a href="distribution.html#a8.1_Overview">8.1 Overview</a></li>
|
||||||
<li><a href="distribution.html#a8.2_Generating_data_like_an_input_file">8.2 Generating data 'like' an input file</a></li>
|
<li><a href="distribution.html#a8.2_Generating_data_like_an_input_file">8.2 Generating data 'like' an input file</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="fraction.html">9. Fractions</a>
|
<li><a href="fraction.html">9. Fractions</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="fraction.html#a9.1_Overview">9.1 Overview</a></li>
|
<li><a href="fraction.html#a9.1_Overview">9.1 Overview</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="transform.html">10. Transforms</a></li>
|
<li><a href="transform.html">10. Transforms</a></li>
|
||||||
<li><a href="geometry.html">11. Geometry</a>
|
<li><a href="geometry.html">11. Geometry</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="geometry.html#a11.1_Overview">11.1 Overview</a></li>
|
<li><a href="geometry.html#a11.1_Overview">11.1 Overview</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="optimization.html">12. Optimization</a>
|
<li><a href="optimization.html">12. Optimization</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="optimization.html#a12.1_Overview">12.1 Overview</a></li>
|
<li><a href="optimization.html#a12.1_Overview">12.1 Overview</a></li>
|
||||||
|
@ -111,7 +111,7 @@
|
||||||
<li><a href="optimization.html#a12.3_Linear_Programming">12.3 Linear Programming</a></li>
|
<li><a href="optimization.html#a12.3_Linear_Programming">12.3 Linear Programming</a></li>
|
||||||
<li><a href="optimization.html#a12.4_Direct_Methods">12.4 Direct Methods</a></li>
|
<li><a href="optimization.html#a12.4_Direct_Methods">12.4 Direct Methods</a></li>
|
||||||
<li><a href="optimization.html#a12.5_General_Case">12.5 General Case</a></li>
|
<li><a href="optimization.html#a12.5_General_Case">12.5 General Case</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="fitting.html">13. Curve Fitting</a>
|
<li><a href="fitting.html">13. Curve Fitting</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="fitting.html#a13.1_Overview">13.1 Overview</a></li>
|
<li><a href="fitting.html#a13.1_Overview">13.1 Overview</a></li>
|
||||||
|
@ -139,11 +139,11 @@
|
||||||
<li><a href="ode.html#a15.4_Available_Integrators">15.4 Available Integrators</a></li>
|
<li><a href="ode.html#a15.4_Available_Integrators">15.4 Available Integrators</a></li>
|
||||||
<li><a href="ode.html#a15.5_Derivatives">15.5 Derivatives</a></li>
|
<li><a href="ode.html#a15.5_Derivatives">15.5 Derivatives</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="genetics.html">16. Genetic Algorithms</a>
|
<li><a href="genetics.html">16. Genetic Algorithms</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="genetics.html#a16.1_Overview">16.1 Overview</a></li>
|
<li><a href="genetics.html#a16.1_Overview">16.1 Overview</a></li>
|
||||||
<li><a href="genetics.html#a16.2_GA_Framework">16.2 GA Framework</a></li>
|
<li><a href="genetics.html#a16.2_GA_Framework">16.2 GA Framework</a></li>
|
||||||
<li><a href="genetics.html#a16.3_Implementation">16.3 Implementation and Examples</a></li>
|
<li><a href="genetics.html#a16.3_Implementation">16.3 Implementation and Examples</a></li>
|
||||||
</ul></li>
|
</ul></li>
|
||||||
<li><a href="filter.html">17. Filters</a>
|
<li><a href="filter.html">17. Filters</a>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
<li><a href="ml.html#clustering">18.2 Clustering algorithms and distance measures</a></li>
|
<li><a href="ml.html#clustering">18.2 Clustering algorithms and distance measures</a></li>
|
||||||
<li><a href="ml.html#implementation">18.3 Implementation</a></li>
|
<li><a href="ml.html#implementation">18.3 Implementation</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="exceptions.html">19. Exceptions</a>
|
<li><a href="exceptions.html">19. Exceptions</a>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="exceptions.html#a19.1_Overview">19.1 Overview</a></li>
|
<li><a href="exceptions.html#a19.1_Overview">19.1 Overview</a></li>
|
||||||
|
@ -168,7 +168,7 @@
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</document>
|
</document>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="linear.html">
|
<document url="linear.html">
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
<subsection name="3.2 Real matrices" href="real_matrices">
|
<subsection name="3.2 Real matrices" href="real_matrices">
|
||||||
<p>
|
<p>
|
||||||
The <a href="../apidocs/org/apache/commons/math4/linear/RealMatrix.html">
|
The <a href="../apidocs/org/apache/commons/math4/linear/RealMatrix.html">
|
||||||
RealMatrix</a> interface represents a matrix with real numbers as
|
RealMatrix</a> interface represents a matrix with real numbers as
|
||||||
entries. The following basic matrix operations are supported:
|
entries. The following basic matrix operations are supported:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Matrix addition, subtraction, multiplication</li>
|
<li>Matrix addition, subtraction, multiplication</li>
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
<li>transpose</li>
|
<li>transpose</li>
|
||||||
<li>Norm and Trace</li>
|
<li>Norm and Trace</li>
|
||||||
<li>Operation on a vector</li>
|
<li>Operation on a vector</li>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
Example:
|
Example:
|
||||||
|
@ -85,7 +85,7 @@ RealMatrix pInverse = new LUDecomposition(p).getSolver().getInverse();
|
||||||
<subsection name="3.3 Real vectors" href="real_vectors">
|
<subsection name="3.3 Real vectors" href="real_vectors">
|
||||||
<p>
|
<p>
|
||||||
The <a href="../apidocs/org/apache/commons/math4/linear/RealVector.html">
|
The <a href="../apidocs/org/apache/commons/math4/linear/RealVector.html">
|
||||||
RealVector</a> interface represents a vector with real numbers as
|
RealVector</a> interface represents a vector with real numbers as
|
||||||
entries. The following basic matrix operations are supported:
|
entries. The following basic matrix operations are supported:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Vector addition, subtraction</li>
|
<li>Vector addition, subtraction</li>
|
||||||
|
@ -136,7 +136,7 @@ RealVector constants = new ArrayRealVector(new double[] { 1, -2, 1 }, false);
|
||||||
RealVector solution = solver.solve(constants);
|
RealVector solution = solver.solve(constants);
|
||||||
</source>
|
</source>
|
||||||
The <code>solution</code> vector will contain values for x
|
The <code>solution</code> vector will contain values for x
|
||||||
(<code>solution.getEntry(0)</code>), y (<code>solution.getEntry(1)</code>),
|
(<code>solution.getEntry(0)</code>), y (<code>solution.getEntry(1)</code>),
|
||||||
and z (<code>solution.getEntry(2)</code>) that solve the system.
|
and z (<code>solution.getEntry(2)</code>) that solve the system.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
@ -170,8 +170,8 @@ RealVector solution = solver.solve(constants);
|
||||||
In this case, the solution will be provided also as an array of double.
|
In this case, the solution will be provided also as an array of double.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
It is possible to solve multiple systems with the same coefficient matrix
|
It is possible to solve multiple systems with the same coefficient matrix
|
||||||
in one method call. To do this, create a matrix whose column vectors correspond
|
in one method call. To do this, create a matrix whose column vectors correspond
|
||||||
to the constant vectors for the systems to be solved and use <code>solve(RealMatrix),</code>
|
to the constant vectors for the systems to be solved and use <code>solve(RealMatrix),</code>
|
||||||
which returns a matrix with column vectors representing the solutions.
|
which returns a matrix with column vectors representing the solutions.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="ml.html">
|
<document url="ml.html">
|
||||||
|
|
||||||
|
@ -39,10 +39,10 @@
|
||||||
The following algorithms are available:
|
The following algorithms are available:
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="../apidocs/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.html">KMeans++</a>:
|
<li><a href="../apidocs/org/apache/commons/math4/ml/clustering/KMeansPlusPlusClusterer.html">KMeans++</a>:
|
||||||
It is based on the well-known kMeans algorithm, but uses a different method for
|
It is based on the well-known kMeans algorithm, but uses a different method for
|
||||||
choosing the initial values (or "seeds") and thus avoids cases where KMeans sometimes
|
choosing the initial values (or "seeds") and thus avoids cases where KMeans sometimes
|
||||||
results in poor clusterings. KMeans/KMeans++ clustering aims to partition n observations
|
results in poor clusterings. KMeans/KMeans++ clustering aims to partition n observations
|
||||||
into k clusters in such that each point belongs to the cluster with the nearest center.
|
into k clusters in such that each point belongs to the cluster with the nearest center.
|
||||||
</li>
|
</li>
|
||||||
<li><a href="../apidocs/org/apache/commons/math4/ml/clustering/FuzzyKMeansClusterer.html">Fuzzy-KMeans</a>:
|
<li><a href="../apidocs/org/apache/commons/math4/ml/clustering/FuzzyKMeansClusterer.html">Fuzzy-KMeans</a>:
|
||||||
A variation of the classical K-Means algorithm, with the major difference that a single
|
A variation of the classical K-Means algorithm, with the major difference that a single
|
||||||
|
@ -52,7 +52,7 @@
|
||||||
slower than the original kMeans algorithm.
|
slower than the original kMeans algorithm.
|
||||||
</li>
|
</li>
|
||||||
<li><a href="../apidocs/org/apache/commons/math4/ml/clustering/DBSCANClusterer.html">DBSCAN</a>:
|
<li><a href="../apidocs/org/apache/commons/math4/ml/clustering/DBSCANClusterer.html">DBSCAN</a>:
|
||||||
Density-based spatial clustering of applications with noise (DBSCAN) finds a number of
|
Density-based spatial clustering of applications with noise (DBSCAN) finds a number of
|
||||||
clusters starting from the estimated density distribution of corresponding nodes. The
|
clusters starting from the estimated density distribution of corresponding nodes. The
|
||||||
main advantages over KMeans/KMeans++ are that DBSCAN does not require the specification
|
main advantages over KMeans/KMeans++ are that DBSCAN does not require the specification
|
||||||
of an initial number of clusters and can find arbitrarily shaped clusters.
|
of an initial number of clusters and can find arbitrarily shaped clusters.
|
||||||
|
@ -114,18 +114,18 @@ public static class LocationWrapper implements Clusterable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</source>
|
</source>
|
||||||
Now we will create a list of these wrapper objects (one for each location),
|
Now we will create a list of these wrapper objects (one for each location),
|
||||||
which serves as input to our clustering algorithm.
|
which serves as input to our clustering algorithm.
|
||||||
<source>
|
<source>
|
||||||
// we have a list of our locations we want to cluster. create a
|
// we have a list of our locations we want to cluster. create a
|
||||||
List<Location> locations = ...;
|
List<Location> locations = ...;
|
||||||
List<LocationWrapper> clusterInput = new ArrayList<LocationWrapper>(locations.size());
|
List<LocationWrapper> clusterInput = new ArrayList<LocationWrapper>(locations.size());
|
||||||
for (Location location : locations)
|
for (Location location : locations)
|
||||||
clusterInput.add(new LocationWrapper(location));
|
clusterInput.add(new LocationWrapper(location));
|
||||||
</source>
|
</source>
|
||||||
Finally, we can apply our clustering algorithm and output the found clusters.
|
Finally, we can apply our clustering algorithm and output the found clusters.
|
||||||
<source>
|
<source>
|
||||||
// initialize a new clustering algorithm.
|
// initialize a new clustering algorithm.
|
||||||
// we use KMeans++ with 10 clusters and 10000 iterations maximum.
|
// we use KMeans++ with 10 clusters and 10000 iterations maximum.
|
||||||
// we did not specify a distance measure; the default (euclidean distance) is used.
|
// we did not specify a distance measure; the default (euclidean distance) is used.
|
||||||
KMeansPlusPlusClusterer<LocationWrapper> clusterer = new KMeansPlusPlusClusterer<LocationWrapper>(10, 10000);
|
KMeansPlusPlusClusterer<LocationWrapper> clusterer = new KMeansPlusPlusClusterer<LocationWrapper>(10, 10000);
|
||||||
|
@ -143,4 +143,4 @@ for (int i=0; i<clusterResults.size(); i++) {
|
||||||
</subsection>
|
</subsection>
|
||||||
</section>
|
</section>
|
||||||
</body>
|
</body>
|
||||||
</document>
|
</document>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="ode.html">
|
<document url="ode.html">
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ dp853.integrate(ode, 0.0, y, 16.0, y); // now y contains final state at time t=1
|
||||||
StepHandler stepHandler = new StepHandler() {
|
StepHandler stepHandler = new StepHandler() {
|
||||||
public void init(double t0, double[] y0, double t) {
|
public void init(double t0, double[] y0, double t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||||
double t = interpolator.getCurrentTime();
|
double t = interpolator.getCurrentTime();
|
||||||
double[] y = interpolator.getInterpolatedState();
|
double[] y = interpolator.getInterpolatedState();
|
||||||
|
|
|
@ -261,7 +261,7 @@
|
||||||
|
|
||||||
We are looking to find the best parameters [a, b, c] for the quadratic function
|
We are looking to find the best parameters [a, b, c] for the quadratic function
|
||||||
<b><code>f(x) = a x<sup>2</sup> + b x + c</code></b>.
|
<b><code>f(x) = a x<sup>2</sup> + b x + c</code></b>.
|
||||||
The data set below was generated using [a = 8, b = 10, c = 16].
|
The data set below was generated using [a = 8, b = 10, c = 16].
|
||||||
A random number between zero and one was added to each y value calculated.
|
A random number between zero and one was added to each y value calculated.
|
||||||
|
|
||||||
<table cellspacing="0" cellpadding="3">
|
<table cellspacing="0" cellpadding="3">
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document>
|
<document>
|
||||||
<properties>
|
<properties>
|
||||||
<title>User Guide - Overview</title>
|
<title>User Guide - Overview</title>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<section name="Overview">
|
<section name="Overview">
|
||||||
|
@ -32,22 +32,22 @@
|
||||||
This guide is intended to help programmers quickly find what they need to develop
|
This guide is intended to help programmers quickly find what they need to develop
|
||||||
solutions using Commons Math. It also provides a supplement to the javadoc API documentation,
|
solutions using Commons Math. It also provides a supplement to the javadoc API documentation,
|
||||||
providing a little more explanation of the mathematical objects and functions included
|
providing a little more explanation of the mathematical objects and functions included
|
||||||
in the package.
|
in the package.
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
|
|
||||||
<subsection name="0.2 What's in commons-math" href="summary">
|
<subsection name="0.2 What's in commons-math" href="summary">
|
||||||
<p>
|
<p>
|
||||||
Commons Math is made up of a small set of math/stat utilities addressing
|
Commons Math is made up of a small set of math/stat utilities addressing
|
||||||
programming problems like the ones in the list below. This list is not exhaustive,
|
programming problems like the ones in the list below. This list is not exhaustive,
|
||||||
it's just meant to give a feel for the kinds of things that Commons Math provides.
|
it's just meant to give a feel for the kinds of things that Commons Math provides.
|
||||||
<ul>
|
<ul>
|
||||||
<li>Computing means, variances and other summary statistics for a list of numbers</li>
|
<li>Computing means, variances and other summary statistics for a list of numbers</li>
|
||||||
<li>Fitting a line to a set of data points using linear regression</li>
|
<li>Fitting a line to a set of data points using linear regression</li>
|
||||||
<li>Fitting a curve to a set of data points</li>
|
<li>Fitting a curve to a set of data points</li>
|
||||||
<li>Finding a smooth curve that passes through a collection of points (interpolation)</li>
|
<li>Finding a smooth curve that passes through a collection of points (interpolation)</li>
|
||||||
<li>Fitting a parametric model to a set of measurements using least-squares methods</li>
|
<li>Fitting a parametric model to a set of measurements using least-squares methods</li>
|
||||||
<li>Solving equations involving real-valued functions (i.e. root-finding)</li>
|
<li>Solving equations involving real-valued functions (i.e. root-finding)</li>
|
||||||
<li>Solving systems of linear equations</li>
|
<li>Solving systems of linear equations</li>
|
||||||
<li>Solving Ordinary Differential Equations</li>
|
<li>Solving Ordinary Differential Equations</li>
|
||||||
<li>Minimizing multi-dimensional functions</li>
|
<li>Minimizing multi-dimensional functions</li>
|
||||||
|
@ -57,13 +57,13 @@
|
||||||
<li>Performing statistical significance tests</li>
|
<li>Performing statistical significance tests</li>
|
||||||
<li>Miscellaneous mathematical functions such as factorials, binomial
|
<li>Miscellaneous mathematical functions such as factorials, binomial
|
||||||
coefficients and "special functions" (e.g. gamma, beta functions)</li>
|
coefficients and "special functions" (e.g. gamma, beta functions)</li>
|
||||||
</ul></p>
|
</ul></p>
|
||||||
<p>
|
<p>
|
||||||
We are actively seeking ideas for additional components that fit into the
|
We are actively seeking ideas for additional components that fit into the
|
||||||
<a href="../index.html#summary">Commons Math vision</a> of a set of lightweight,
|
<a href="../index.html#summary">Commons Math vision</a> of a set of lightweight,
|
||||||
self-contained math/stat components useful for solving common programming problems.
|
self-contained math/stat components useful for solving common programming problems.
|
||||||
Suggestions for new components or enhancements to existing functionality are always welcome!
|
Suggestions for new components or enhancements to existing functionality are always welcome!
|
||||||
All feedback/suggestions for improvement should be sent to the
|
All feedback/suggestions for improvement should be sent to the
|
||||||
<a href="http://commons.apache.org/mail-lists.html">commons-dev mailing list</a> with
|
<a href="http://commons.apache.org/mail-lists.html">commons-dev mailing list</a> with
|
||||||
[math] at the beginning of the subject line.
|
[math] at the beginning of the subject line.
|
||||||
</p>
|
</p>
|
||||||
|
@ -96,15 +96,15 @@
|
||||||
|
|
||||||
<subsection name="0.4 How interface contracts are specified in commons-math javadoc" href="contracts">
|
<subsection name="0.4 How interface contracts are specified in commons-math javadoc" href="contracts">
|
||||||
<p>
|
<p>
|
||||||
You should always read the javadoc class and method comments carefully when using
|
You should always read the javadoc class and method comments carefully when using
|
||||||
Commons Math components in your programs. The javadoc provides references to the algorithms
|
Commons Math components in your programs. The javadoc provides references to the algorithms
|
||||||
that are used, usage notes about limitations, performance, etc. as well as interface contracts.
|
that are used, usage notes about limitations, performance, etc. as well as interface contracts.
|
||||||
Interface contracts are specified in terms of preconditions (what has to be true in order
|
Interface contracts are specified in terms of preconditions (what has to be true in order
|
||||||
for the method to return valid results), special values returned (e.g. Double.NaN)
|
for the method to return valid results), special values returned (e.g. Double.NaN)
|
||||||
or exceptions that may be thrown if the preconditions are not met, and definitions for returned
|
or exceptions that may be thrown if the preconditions are not met, and definitions for returned
|
||||||
values/objects or state changes.</p>
|
values/objects or state changes.</p>
|
||||||
<p>
|
<p>
|
||||||
When the actual parameters provided to a method or the internal state of an object
|
When the actual parameters provided to a method or the internal state of an object
|
||||||
make a computation meaningless, a
|
make a computation meaningless, a
|
||||||
<a href="../apidocs/org/apache/commons/math4/exception/MathIllegalArgumentException.html">
|
<a href="../apidocs/org/apache/commons/math4/exception/MathIllegalArgumentException.html">
|
||||||
MathIllegalArgumentException</a> or
|
MathIllegalArgumentException</a> or
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="random.html">
|
<document url="random.html">
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ import org.apache.commons.rng.RandomSource;
|
||||||
|
|
||||||
// Import common PRNG interface and factory class that instantiates the PRNG.
|
// Import common PRNG interface and factory class that instantiates the PRNG.
|
||||||
// Create (and possibly seed) a PRNG.
|
// Create (and possibly seed) a PRNG.
|
||||||
long seed = 17399225432L; // Fixed seed means same results every time
|
long seed = 17399225432L; // Fixed seed means same results every time
|
||||||
UniformRandomProvider rng = RandomSource.create(RandomSource.MT, seed);
|
UniformRandomProvider rng = RandomSource.create(RandomSource.MT, seed);
|
||||||
|
|
||||||
// Create a a factory of correlated vectors.
|
// Create a a factory of correlated vectors.
|
||||||
|
|
|
@ -7,16 +7,16 @@
|
||||||
The ASF licenses this file to You under the Apache License, Version 2.0
|
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 not use this file except in compliance with
|
||||||
the License. You may obtain a copy of the License at
|
the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="fraction.html">
|
<document url="fraction.html">
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -118,7 +118,7 @@
|
||||||
</table>
|
</table>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<code>SummaryStatistics</code> can be aggregated using
|
<code>SummaryStatistics</code> can be aggregated using
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatistics.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatistics.html">
|
||||||
AggregateSummaryStatistics.</a> This class can be used to concurrently
|
AggregateSummaryStatistics.</a> This class can be used to concurrently
|
||||||
gather statistics for multiple datasets as well as for a combined sample
|
gather statistics for multiple datasets as well as for a combined sample
|
||||||
|
@ -135,11 +135,11 @@
|
||||||
is thread-safe.
|
is thread-safe.
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/SynchronizedDescriptiveStatistics.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/SynchronizedDescriptiveStatistics.html">
|
||||||
SynchronizedDescriptiveStatistics</a> and
|
SynchronizedDescriptiveStatistics</a> and
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/SynchronizedSummaryStatistics.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/SynchronizedSummaryStatistics.html">
|
||||||
SynchronizedSummaryStatistics</a>, respectively, provide thread-safe
|
SynchronizedSummaryStatistics</a>, respectively, provide thread-safe
|
||||||
versions for applications that require concurrent access to statistical
|
versions for applications that require concurrent access to statistical
|
||||||
aggregates by multiple threads.
|
aggregates by multiple threads.
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/SynchronizedMultiVariateSummaryStatistics.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/SynchronizedMultiVariateSummaryStatistics.html">
|
||||||
SynchronizedMultivariateSummaryStatistics</a> provides thread-safe
|
SynchronizedMultivariateSummaryStatistics</a> provides thread-safe
|
||||||
<code>MultivariateSummaryStatistics.</code>
|
<code>MultivariateSummaryStatistics.</code>
|
||||||
</p>
|
</p>
|
||||||
|
@ -239,14 +239,14 @@ DescriptiveStatistics stats = new SynchronizedDescriptiveStatistics();
|
||||||
</dd>
|
</dd>
|
||||||
<dt>Compute statistics for multiple samples and overall statistics concurrently</dt>
|
<dt>Compute statistics for multiple samples and overall statistics concurrently</dt>
|
||||||
<br/>
|
<br/>
|
||||||
<dd>There are two ways to do this using <code>AggregateSummaryStatistics.</code>
|
<dd>There are two ways to do this using <code>AggregateSummaryStatistics.</code>
|
||||||
The first is to use an <code>AggregateSummaryStatistics</code> instance
|
The first is to use an <code>AggregateSummaryStatistics</code> instance
|
||||||
to accumulate overall statistics contributed by <code>SummaryStatistics</code>
|
to accumulate overall statistics contributed by <code>SummaryStatistics</code>
|
||||||
instances created using
|
instances created using
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatistics.html#createContributingStatistics()">
|
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatistics.html#createContributingStatistics()">
|
||||||
AggregateSummaryStatistics.createContributingStatistics()</a>:
|
AggregateSummaryStatistics.createContributingStatistics()</a>:
|
||||||
<source>
|
<source>
|
||||||
// Create a AggregateSummaryStatistics instance to accumulate the overall statistics
|
// Create a AggregateSummaryStatistics instance to accumulate the overall statistics
|
||||||
// and AggregatingSummaryStatistics for the subsamples
|
// and AggregatingSummaryStatistics for the subsamples
|
||||||
AggregateSummaryStatistics aggregate = new AggregateSummaryStatistics();
|
AggregateSummaryStatistics aggregate = new AggregateSummaryStatistics();
|
||||||
SummaryStatistics setOneStats = aggregate.createContributingStatistics();
|
SummaryStatistics setOneStats = aggregate.createContributingStatistics();
|
||||||
|
@ -501,7 +501,7 @@ System.out.println(regression.getSlopeStdErr());
|
||||||
System.out.println(regression.getInterceptStdErr() );
|
System.out.println(regression.getInterceptStdErr() );
|
||||||
// will return Double.NaN, since we constrained the parameter to zero
|
// will return Double.NaN, since we constrained the parameter to zero
|
||||||
</source>
|
</source>
|
||||||
Caution must be exercised when interpreting the slope when no constant is being estimated. The slope
|
Caution must be exercised when interpreting the slope when no constant is being estimated. The slope
|
||||||
may be biased.
|
may be biased.
|
||||||
</dd>
|
</dd>
|
||||||
|
|
||||||
|
@ -520,12 +520,12 @@ System.out.println(regression.getInterceptStdErr() );
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
where Y is an n-vector <b>regressand</b>, X is a [n,k] matrix whose k columns are called
|
where Y is an n-vector <b>regressand</b>, X is a [n,k] matrix whose k columns are called
|
||||||
<b>regressors</b>, b is k-vector of <b>regression parameters</b> and u is an n-vector
|
<b>regressors</b>, b is k-vector of <b>regression parameters</b> and u is an n-vector
|
||||||
of <b>error terms</b> or <b>residuals</b>.
|
of <b>error terms</b> or <b>residuals</b>.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/regression/OLSMultipleLinearRegression.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/regression/OLSMultipleLinearRegression.html">
|
||||||
OLSMultipleLinearRegression</a> provides Ordinary Least Squares Regression, and
|
OLSMultipleLinearRegression</a> provides Ordinary Least Squares Regression, and
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegression.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegression.html">
|
||||||
GLSMultipleLinearRegression</a> implements Generalized Least Squares. See the javadoc for these
|
GLSMultipleLinearRegression</a> implements Generalized Least Squares. See the javadoc for these
|
||||||
classes for details on the algorithms and formulas used.
|
classes for details on the algorithms and formulas used.
|
||||||
|
@ -535,9 +535,9 @@ System.out.println(regression.getInterceptStdErr() );
|
||||||
the regressand (Y) value, followed by regressor values; or using a double[][] array with rows corresponding to
|
the regressand (Y) value, followed by regressor values; or using a double[][] array with rows corresponding to
|
||||||
observations. GLS models also require a double[][] array representing the covariance matrix of the error terms. See
|
observations. GLS models also require a double[][] array representing the covariance matrix of the error terms. See
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/regression/AbstractMultipleLinearRegression.html#newSampleData(double[], int, int)">
|
<a href="../apidocs/org/apache/commons/math4/stat/regression/AbstractMultipleLinearRegression.html#newSampleData(double[], int, int)">
|
||||||
AbstractMultipleLinearRegression#newSampleData(double[],int,int)</a>,
|
AbstractMultipleLinearRegression#newSampleData(double[],int,int)</a>,
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/regression/OLSMultipleLinearRegression.html#newSampleData(double[], double[][])">
|
<a href="../apidocs/org/apache/commons/math4/stat/regression/OLSMultipleLinearRegression.html#newSampleData(double[], double[][])">
|
||||||
OLSMultipleLinearRegression#newSampleData(double[], double[][])</a> and
|
OLSMultipleLinearRegression#newSampleData(double[], double[][])</a> and
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegression.html#newSampleData(double[], double[][], double[][])">
|
<a href="../apidocs/org/apache/commons/math4/stat/regression/GLSMultipleLinearRegression.html#newSampleData(double[], double[][], double[][])">
|
||||||
GLSMultipleLinearRegression#newSampleData(double[],double[][],double[][])</a> for details.
|
GLSMultipleLinearRegression#newSampleData(double[],double[][],double[][])</a> for details.
|
||||||
</p>
|
</p>
|
||||||
|
@ -545,7 +545,7 @@ System.out.println(regression.getInterceptStdErr() );
|
||||||
<strong>Usage Notes</strong>: <ul>
|
<strong>Usage Notes</strong>: <ul>
|
||||||
<li> Data are validated when invoking any of the newSample, newX, newY or newCovariance methods and
|
<li> Data are validated when invoking any of the newSample, newX, newY or newCovariance methods and
|
||||||
<code>IllegalArgumentException</code> is thrown when input data arrays do not have matching dimensions
|
<code>IllegalArgumentException</code> is thrown when input data arrays do not have matching dimensions
|
||||||
or do not contain sufficient data to estimate the model.
|
or do not contain sufficient data to estimate the model.
|
||||||
</li>
|
</li>
|
||||||
<li> By default, regression models are estimated with intercept terms. In the notation above, this implies that the
|
<li> By default, regression models are estimated with intercept terms. In the notation above, this implies that the
|
||||||
X matrix contains an initial row identically equal to 1. X data supplied to the newX or newSample methods should not
|
X matrix contains an initial row identically equal to 1. X data supplied to the newX or newSample methods should not
|
||||||
|
@ -568,13 +568,13 @@ x[1] = new double[]{2.0, 0, 0, 0, 0};
|
||||||
x[2] = new double[]{0, 3.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[3] = new double[]{0, 0, 4.0, 0, 0};
|
||||||
x[4] = new double[]{0, 0, 0, 5.0, 0};
|
x[4] = new double[]{0, 0, 0, 5.0, 0};
|
||||||
x[5] = new double[]{0, 0, 0, 0, 6.0};
|
x[5] = new double[]{0, 0, 0, 0, 6.0};
|
||||||
regression.newSampleData(y, x);
|
regression.newSampleData(y, x);
|
||||||
</source>
|
</source>
|
||||||
</dd>
|
</dd>
|
||||||
<dd>Get regression parameters and diagnostics:
|
<dd>Get regression parameters and diagnostics:
|
||||||
<source>
|
<source>
|
||||||
double[] beta = regression.estimateRegressionParameters();
|
double[] beta = regression.estimateRegressionParameters();
|
||||||
|
|
||||||
double[] residuals = regression.estimateResiduals();
|
double[] residuals = regression.estimateResiduals();
|
||||||
|
|
||||||
|
@ -599,7 +599,7 @@ x[1] = new double[]{2.0, 0, 0, 0, 0};
|
||||||
x[2] = new double[]{0, 3.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[3] = new double[]{0, 0, 4.0, 0, 0};
|
||||||
x[4] = new double[]{0, 0, 0, 5.0, 0};
|
x[4] = new double[]{0, 0, 0, 5.0, 0};
|
||||||
x[5] = new double[]{0, 0, 0, 0, 6.0};
|
x[5] = new double[]{0, 0, 0, 0, 6.0};
|
||||||
double[][] omega = new double[6][];
|
double[][] omega = new double[6][];
|
||||||
omega[0] = new double[]{1.1, 0, 0, 0, 0, 0};
|
omega[0] = new double[]{1.1, 0, 0, 0, 0, 0};
|
||||||
omega[1] = new double[]{0, 2.2, 0, 0, 0, 0};
|
omega[1] = new double[]{0, 2.2, 0, 0, 0, 0};
|
||||||
|
@ -607,19 +607,19 @@ omega[2] = new double[]{0, 0, 3.3, 0, 0, 0};
|
||||||
omega[3] = new double[]{0, 0, 0, 4.4, 0, 0};
|
omega[3] = new double[]{0, 0, 0, 4.4, 0, 0};
|
||||||
omega[4] = new double[]{0, 0, 0, 0, 5.5, 0};
|
omega[4] = new double[]{0, 0, 0, 0, 5.5, 0};
|
||||||
omega[5] = new double[]{0, 0, 0, 0, 0, 6.6};
|
omega[5] = new double[]{0, 0, 0, 0, 0, 6.6};
|
||||||
regression.newSampleData(y, x, omega);
|
regression.newSampleData(y, x, omega);
|
||||||
</source>
|
</source>
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
<subsection name="1.6 Rank transformations">
|
<subsection name="1.6 Rank transformations">
|
||||||
<p>
|
<p>
|
||||||
Some statistical algorithms require that input data be replaced by ranks.
|
Some statistical algorithms require that input data be replaced by ranks.
|
||||||
The <a href="../apidocs/org/apache/commons/math4/stat/ranking/package-summary.html">
|
The <a href="../apidocs/org/apache/commons/math4/stat/ranking/package-summary.html">
|
||||||
org.apache.commons.math4.stat.ranking</a> package provides rank transformation.
|
org.apache.commons.math4.stat.ranking</a> package provides rank transformation.
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/ranking/RankingAlgorithm.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/ranking/RankingAlgorithm.html">
|
||||||
RankingAlgorithm</a> defines the interface for ranking.
|
RankingAlgorithm</a> defines the interface for ranking.
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/ranking/NaturalRanking.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/ranking/NaturalRanking.html">
|
||||||
NaturalRanking</a> provides an implementation that has two configuration options.
|
NaturalRanking</a> provides an implementation that has two configuration options.
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -640,7 +640,7 @@ double[] ranks = ranking.rank(exampleData);
|
||||||
</source>
|
</source>
|
||||||
results in <code>ranks</code> containing <code>{6, 5, 7, 8, 5, 9, 2, 2, 5}.</code>
|
results in <code>ranks</code> containing <code>{6, 5, 7, 8, 5, 9, 2, 2, 5}.</code>
|
||||||
<source>
|
<source>
|
||||||
new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData);
|
new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData);
|
||||||
</source>
|
</source>
|
||||||
returns <code>{5, 2, 6, 7, 3, 8, 1, 4}.</code>
|
returns <code>{5, 2, 6, 7, 3, 8, 1, 4}.</code>
|
||||||
</p>
|
</p>
|
||||||
|
@ -648,20 +648,20 @@ new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData
|
||||||
The default <code>NaNStrategy</code> is NaNStrategy.MAXIMAL. This makes <code>NaN</code>
|
The default <code>NaNStrategy</code> is NaNStrategy.MAXIMAL. This makes <code>NaN</code>
|
||||||
values larger than any other value (including <code>Double.POSITIVE_INFINITY</code>). The
|
values larger than any other value (including <code>Double.POSITIVE_INFINITY</code>). The
|
||||||
default <code>TiesStrategy</code> is <code>TiesStrategy.AVERAGE,</code> which assigns tied
|
default <code>TiesStrategy</code> is <code>TiesStrategy.AVERAGE,</code> which assigns tied
|
||||||
values the average of the ranks applicable to the sequence of ties. See the
|
values the average of the ranks applicable to the sequence of ties. See the
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/ranking/NaturalRanking.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/ranking/NaturalRanking.html">
|
||||||
NaturalRanking</a> for more examples and <a href="../apidocs/org/apache/commons/math4/stat/ranking/TiesStrategy.html">
|
NaturalRanking</a> for more examples and <a href="../apidocs/org/apache/commons/math4/stat/ranking/TiesStrategy.html">
|
||||||
TiesStrategy</a> and <a href="../apidocs/org/apache/commons/math4/stat/ranking/NaNStrategy.html">NaNStrategy</a>
|
TiesStrategy</a> and <a href="../apidocs/org/apache/commons/math4/stat/ranking/NaNStrategy.html">NaNStrategy</a>
|
||||||
for details on these configuration options.
|
for details on these configuration options.
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
<subsection name="1.7 Covariance and correlation">
|
<subsection name="1.7 Covariance and correlation">
|
||||||
<p>
|
<p>
|
||||||
The <a href="../apidocs/org/apache/commons/math4/stat/correlation/package-summary.html">
|
The <a href="../apidocs/org/apache/commons/math4/stat/correlation/package-summary.html">
|
||||||
org.apache.commons.math4.stat.correlation</a> package computes covariances
|
org.apache.commons.math4.stat.correlation</a> package computes covariances
|
||||||
and correlations for pairs of arrays or columns of a matrix.
|
and correlations for pairs of arrays or columns of a matrix.
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/correlation/Covariance.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/correlation/Covariance.html">
|
||||||
Covariance</a> computes covariances,
|
Covariance</a> computes covariances,
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/correlation/PearsonsCorrelation.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/correlation/PearsonsCorrelation.html">
|
||||||
PearsonsCorrelation</a> provides Pearson's Product-Moment correlation coefficients,
|
PearsonsCorrelation</a> provides Pearson's Product-Moment correlation coefficients,
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/correlation/SpearmansCorrelation.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/correlation/SpearmansCorrelation.html">
|
||||||
|
@ -676,10 +676,10 @@ new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData
|
||||||
Unbiased covariances are given by the formula <br/>
|
Unbiased covariances are given by the formula <br/>
|
||||||
<code>cov(X, Y) = sum [(x<sub>i</sub> - E(X))(y<sub>i</sub> - E(Y))] / (n - 1)</code>
|
<code>cov(X, Y) = sum [(x<sub>i</sub> - E(X))(y<sub>i</sub> - E(Y))] / (n - 1)</code>
|
||||||
where <code>E(X)</code> is the mean of <code>X</code> and <code>E(Y)</code>
|
where <code>E(X)</code> is the mean of <code>X</code> and <code>E(Y)</code>
|
||||||
is the mean of the <code>Y</code> values. Non-bias-corrected estimates use
|
is the mean of the <code>Y</code> values. Non-bias-corrected estimates use
|
||||||
<code>n</code> in place of <code>n - 1.</code> Whether or not covariances are
|
<code>n</code> in place of <code>n - 1.</code> Whether or not covariances are
|
||||||
bias-corrected is determined by the optional parameter, "biasCorrected," which
|
bias-corrected is determined by the optional parameter, "biasCorrected," which
|
||||||
defaults to <code>true.</code>
|
defaults to <code>true.</code>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/correlation/PearsonsCorrelation.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/correlation/PearsonsCorrelation.html">
|
||||||
|
@ -691,7 +691,7 @@ new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData
|
||||||
<li>
|
<li>
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/correlation/SpearmansCorrelation.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/correlation/SpearmansCorrelation.html">
|
||||||
SpearmansCorrelation</a> applies a rank transformation to the input data and computes Pearson's
|
SpearmansCorrelation</a> applies a rank transformation to the input data and computes Pearson's
|
||||||
correlation on the ranked data. The ranking algorithm is configurable. By default,
|
correlation on the ranked data. The ranking algorithm is configurable. By default,
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/ranking/NaturalRanking.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/ranking/NaturalRanking.html">
|
||||||
NaturalRanking</a> with default strategies for handling ties and NaN values is used.
|
NaturalRanking</a> with default strategies for handling ties and NaN values is used.
|
||||||
</li>
|
</li>
|
||||||
|
@ -699,7 +699,7 @@ new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/correlation/KendallsCorrelation.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/correlation/KendallsCorrelation.html">
|
||||||
KendallsCorrelation</a> computes the association between two measured quantities. A tau test
|
KendallsCorrelation</a> computes the association between two measured quantities. A tau test
|
||||||
is a non-parametric hypothesis test for statistical dependence based on the tau coefficient.
|
is a non-parametric hypothesis test for statistical dependence based on the tau coefficient.
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
|
@ -727,7 +727,7 @@ new Covariance().computeCovarianceMatrix(data)
|
||||||
</source>
|
</source>
|
||||||
The i-jth entry of the returned matrix is the unbiased covariance of the ith and jth
|
The i-jth entry of the returned matrix is the unbiased covariance of the ith and jth
|
||||||
columns of <code>data.</code> As above, to get non-bias-corrected covariances,
|
columns of <code>data.</code> As above, to get non-bias-corrected covariances,
|
||||||
use
|
use
|
||||||
<source>
|
<source>
|
||||||
computeCovarianceMatrix(data, false)
|
computeCovarianceMatrix(data, false)
|
||||||
</source>
|
</source>
|
||||||
|
@ -750,7 +750,7 @@ new PearsonsCorrelation().correlation(x, y)
|
||||||
new PearsonsCorrelation().computeCorrelationMatrix(data)
|
new PearsonsCorrelation().computeCorrelationMatrix(data)
|
||||||
</source>
|
</source>
|
||||||
The i-jth entry of the returned matrix is the Pearson's product-moment correlation between the
|
The i-jth entry of the returned matrix is the Pearson's product-moment correlation between the
|
||||||
ith and jth columns of <code>data.</code>
|
ith and jth columns of <code>data.</code>
|
||||||
</dd>
|
</dd>
|
||||||
<br/>
|
<br/>
|
||||||
<dt><strong>Pearson's correlation significance and standard errors</strong></dt>
|
<dt><strong>Pearson's correlation significance and standard errors</strong></dt>
|
||||||
|
@ -768,7 +768,7 @@ correlation.getCorrelationStandardErrors();
|
||||||
</source>
|
</source>
|
||||||
The formula used to compute the standard error is <br/>
|
The formula used to compute the standard error is <br/>
|
||||||
<code>SE<sub>r</sub> = ((1 - r<sup>2</sup>) / (n - 2))<sup>1/2</sup></code><br/>
|
<code>SE<sub>r</sub> = ((1 - r<sup>2</sup>) / (n - 2))<sup>1/2</sup></code><br/>
|
||||||
where <code>r</code> is the estimated correlation coefficient and
|
where <code>r</code> is the estimated correlation coefficient and
|
||||||
<code>n</code> is the number of observations in the source dataset.<br/><br/>
|
<code>n</code> is the number of observations in the source dataset.<br/><br/>
|
||||||
<strong>p-values</strong> for the (2-sided) null hypotheses that elements of
|
<strong>p-values</strong> for the (2-sided) null hypotheses that elements of
|
||||||
a correlation matrix are zero populate the RealMatrix returned by
|
a correlation matrix are zero populate the RealMatrix returned by
|
||||||
|
@ -780,9 +780,9 @@ correlation.getCorrelationPValues()
|
||||||
a value with absolute value greater than or equal to <br/>
|
a value with absolute value greater than or equal to <br/>
|
||||||
<code>|r<sub>ij</sub>|((n - 2) / (1 - r<sub>ij</sub><sup>2</sup>))<sup>1/2</sup></code>,
|
<code>|r<sub>ij</sub>|((n - 2) / (1 - r<sub>ij</sub><sup>2</sup>))<sup>1/2</sup></code>,
|
||||||
where <code>r<sub>ij</sub></code> is the estimated correlation between the ith and jth
|
where <code>r<sub>ij</sub></code> is the estimated correlation between the ith and jth
|
||||||
columns of the source array or RealMatrix. This is sometimes referred to as the
|
columns of the source array or RealMatrix. This is sometimes referred to as the
|
||||||
<i>significance</i> of the coefficient.<br/><br/>
|
<i>significance</i> of the coefficient.<br/><br/>
|
||||||
For example, if <code>data</code> is a RealMatrix with 2 columns and 10 rows, then
|
For example, if <code>data</code> is a RealMatrix with 2 columns and 10 rows, then
|
||||||
<source>
|
<source>
|
||||||
new PearsonsCorrelation(data).getCorrelationPValues().getEntry(0,1)
|
new PearsonsCorrelation(data).getCorrelationPValues().getEntry(0,1)
|
||||||
</source>
|
</source>
|
||||||
|
@ -798,13 +798,13 @@ new PearsonsCorrelation(data).getCorrelationPValues().getEntry(0,1)
|
||||||
<source>
|
<source>
|
||||||
new SpearmansCorrelation().correlation(x, y)
|
new SpearmansCorrelation().correlation(x, y)
|
||||||
</source>
|
</source>
|
||||||
This is equivalent to
|
This is equivalent to
|
||||||
<source>
|
<source>
|
||||||
RankingAlgorithm ranking = new NaturalRanking();
|
RankingAlgorithm ranking = new NaturalRanking();
|
||||||
new PearsonsCorrelation().correlation(ranking.rank(x), ranking.rank(y))
|
new PearsonsCorrelation().correlation(ranking.rank(x), ranking.rank(y))
|
||||||
</source>
|
</source>
|
||||||
</dd>
|
</dd>
|
||||||
<br/>
|
<br/>
|
||||||
<dt><strong>Kendalls's tau rank correlation coefficient</strong></dt>
|
<dt><strong>Kendalls's tau rank correlation coefficient</strong></dt>
|
||||||
<br/>
|
<br/>
|
||||||
<dd>To compute the Kendall's tau rank correlation between two double arrays
|
<dd>To compute the Kendall's tau rank correlation between two double arrays
|
||||||
|
@ -823,7 +823,7 @@ new KendallsCorrelation().correlation(x, y)
|
||||||
<a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc22.htm">
|
<a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc22.htm">
|
||||||
Student's t</a>,
|
Student's t</a>,
|
||||||
<a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm">
|
<a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm">
|
||||||
Chi-Square</a>,
|
Chi-Square</a>,
|
||||||
<a href="http://en.wikipedia.org/wiki/G-test">G Test</a>,
|
<a href="http://en.wikipedia.org/wiki/G-test">G Test</a>,
|
||||||
<a href="http://www.itl.nist.gov/div898/handbook/prc/section4/prc43.htm">
|
<a href="http://www.itl.nist.gov/div898/handbook/prc/section4/prc43.htm">
|
||||||
One-Way ANOVA</a>,
|
One-Way ANOVA</a>,
|
||||||
|
@ -853,7 +853,7 @@ new KendallsCorrelation().correlation(x, y)
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/inference/BinomialTest.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/inference/BinomialTest.html">
|
||||||
BinomialTest</a> and
|
BinomialTest</a> and
|
||||||
<a href="../apidocs/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTest.html">
|
<a href="../apidocs/org/apache/commons/math4/stat/inference/KolmogorovSmirnovTest.html">
|
||||||
KolmogorovSmirnovTest</a>.
|
KolmogorovSmirnovTest</a>.
|
||||||
The <a href="../apidocs/org/apache/commons/math4/stat/inference/TestUtils.html">
|
The <a href="../apidocs/org/apache/commons/math4/stat/inference/TestUtils.html">
|
||||||
TestUtils</a> class provides static methods to get test instances or
|
TestUtils</a> class provides static methods to get test instances or
|
||||||
to compute test statistics directly. The examples below all use the
|
to compute test statistics directly. The examples below all use the
|
||||||
|
@ -891,7 +891,7 @@ new KendallsCorrelation().correlation(x, y)
|
||||||
<li>The G test implementation provides two p-values:
|
<li>The G test implementation provides two p-values:
|
||||||
<code>gTest(expected, observed)</code>, which is the tail probability beyond
|
<code>gTest(expected, observed)</code>, which is the tail probability beyond
|
||||||
<code>g(expected, observed)</code> in the ChiSquare distribution with degrees
|
<code>g(expected, observed)</code> in the ChiSquare distribution with degrees
|
||||||
of freedom one less than the common length of input arrays and
|
of freedom one less than the common length of input arrays and
|
||||||
<code>gTestIntrinsic(expected, observed)</code> which is the same tail
|
<code>gTestIntrinsic(expected, observed)</code> which is the same tail
|
||||||
probability computed using a ChiSquare distribution with one less degeree
|
probability computed using a ChiSquare distribution with one less degeree
|
||||||
of freedom. </li>
|
of freedom. </li>
|
||||||
|
@ -908,9 +908,9 @@ new KendallsCorrelation().correlation(x, y)
|
||||||
\(F_n\) is the empirical distribution of the \(n\) sample data points. Both
|
\(F_n\) is the empirical distribution of the \(n\) sample data points. Both
|
||||||
one-sample tests against a <code>RealDistribution</code> and two-sample tests
|
one-sample tests against a <code>RealDistribution</code> and two-sample tests
|
||||||
(comparing two empirical distributions) are supported. For one-sample tests,
|
(comparing two empirical distributions) are supported. For one-sample tests,
|
||||||
the distribution of \(D_n\) is estimated using the method in
|
the distribution of \(D_n\) is estimated using the method in
|
||||||
<a href="http://www.jstatsoft.org/v08/i18/">Evaluating Kolmogorov's Distribution</a> by
|
<a href="http://www.jstatsoft.org/v08/i18/">Evaluating Kolmogorov's Distribution</a> by
|
||||||
George Marsaglia, Wai Wan Tsang, and Jingbo Wang, with quick decisions in some cases
|
George Marsaglia, Wai Wan Tsang, and Jingbo Wang, with quick decisions in some cases
|
||||||
for extreme values using the method described in
|
for extreme values using the method described in
|
||||||
<a href="http://www.jstatsoft.org/v39/i11/"> Computing the Two-Sided Kolmogorov-Smirnov
|
<a href="http://www.jstatsoft.org/v39/i11/"> Computing the Two-Sided Kolmogorov-Smirnov
|
||||||
Distribution</a> by Richard Simard and Pierre L'Ecuyer. In the 2-sample case, estimation
|
Distribution</a> by Richard Simard and Pierre L'Ecuyer. In the 2-sample case, estimation
|
||||||
|
@ -1163,7 +1163,7 @@ System.out.println(TestUtils.gTestDataSetsComparison(obs1, obs2)); // p-value
|
||||||
<source>
|
<source>
|
||||||
new GTest().rootLogLikelihoodRatio(5, 1995, 0, 100000);
|
new GTest().rootLogLikelihoodRatio(5, 1995, 0, 100000);
|
||||||
</source>
|
</source>
|
||||||
returns the root log likelihood associated with the null hypothesis that A
|
returns the root log likelihood associated with the null hypothesis that A
|
||||||
and B are independent.
|
and B are independent.
|
||||||
</dd>
|
</dd>
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -1219,7 +1219,7 @@ TestUtils.kolmogorovSmirnovStatistic(unitNormal, sample)
|
||||||
<source>
|
<source>
|
||||||
TestUtils.kolmogorovSmirnovStatistic(x, y)
|
TestUtils.kolmogorovSmirnovStatistic(x, y)
|
||||||
</source>
|
</source>
|
||||||
to compute the D-statistic and
|
to compute the D-statistic and
|
||||||
<source>
|
<source>
|
||||||
TestUtils.kolmogorovSmirnovTest(x, y)
|
TestUtils.kolmogorovSmirnovTest(x, y)
|
||||||
</source>
|
</source>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="transform.html">
|
<document url="transform.html">
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||||
<document url="utilities.html">
|
<document url="utilities.html">
|
||||||
|
|
||||||
|
@ -39,14 +39,14 @@
|
||||||
|
|
||||||
<subsection name="6.2 Double array utilities" href="arrays">
|
<subsection name="6.2 Double array utilities" href="arrays">
|
||||||
<p>
|
<p>
|
||||||
To maintain statistics based on a "rolling" window of values, a resizable
|
To maintain statistics based on a "rolling" window of values, a resizable
|
||||||
array implementation was developed and is provided for reuse in the
|
array implementation was developed and is provided for reuse in the
|
||||||
<code>util</code> package. The core functionality provided is described in
|
<code>util</code> package. The core functionality provided is described in
|
||||||
the documentation for the interface,
|
the documentation for the interface,
|
||||||
<a href="../apidocs/org/apache/commons/math4/util/DoubleArray.html">
|
<a href="../apidocs/org/apache/commons/math4/util/DoubleArray.html">
|
||||||
DoubleArray</a>. This interface adds one method,
|
DoubleArray</a>. This interface adds one method,
|
||||||
<code>addElementRolling(double)</code> to basic list accessors.
|
<code>addElementRolling(double)</code> to basic list accessors.
|
||||||
The <code>addElementRolling</code> method adds an element
|
The <code>addElementRolling</code> method adds an element
|
||||||
(the actual parameter) to the end of the list and removes the first element
|
(the actual parameter) to the end of the list and removes the first element
|
||||||
in the list.
|
in the list.
|
||||||
</p>
|
</p>
|
||||||
|
@ -64,10 +64,10 @@
|
||||||
the end needs to be created. Both of these operations are handled
|
the end needs to be created. Both of these operations are handled
|
||||||
automatically, with frequency / effect driven by the configuration
|
automatically, with frequency / effect driven by the configuration
|
||||||
properties <code>expansionMode</code>, <code>expansionFactor</code> and
|
properties <code>expansionMode</code>, <code>expansionFactor</code> and
|
||||||
<code>contractionCriteria.</code> See
|
<code>contractionCriteria.</code> See
|
||||||
<a href="../apidocs/org/apache/commons/math4/util/ResizableDoubleArray.html">
|
<a href="../apidocs/org/apache/commons/math4/util/ResizableDoubleArray.html">
|
||||||
ResizableDoubleArray</a>
|
ResizableDoubleArray</a>
|
||||||
for details.
|
for details.
|
||||||
</p>
|
</p>
|
||||||
</subsection>
|
</subsection>
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@
|
||||||
default: return 6.0;
|
default: return 6.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getB(int n, double x) {
|
public double getB(int n, double x) {
|
||||||
double y = (2.0 * n) - 1.0;
|
double y = (2.0 * n) - 1.0;
|
||||||
return y * y;
|
return y * y;
|
||||||
|
@ -129,7 +129,7 @@
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getB(int n, double x) {
|
public double getB(int n, double x) {
|
||||||
if (n % 2 == 0) {
|
if (n % 2 == 0) {
|
||||||
return -x;
|
return -x;
|
||||||
|
@ -151,17 +151,17 @@
|
||||||
<a href="../apidocs/org/apache/commons/math4/util/ArithmeticUtils.html">ArithmeticUtils</a>
|
<a href="../apidocs/org/apache/commons/math4/util/ArithmeticUtils.html">ArithmeticUtils</a>
|
||||||
utility class. ArithmeticUtils currently includes methods to compute the following: <ul>
|
utility class. ArithmeticUtils currently includes methods to compute the following: <ul>
|
||||||
<li>
|
<li>
|
||||||
Binomial coefficients -- "n choose k" available as an (exact) long value,
|
Binomial coefficients -- "n choose k" available as an (exact) long value,
|
||||||
<code>binomialCoefficient(int, int)</code> for small n, k; as a double,
|
<code>binomialCoefficient(int, int)</code> for small n, k; as a double,
|
||||||
<code>binomialCoefficientDouble(int, int)</code> for larger values; and in
|
<code>binomialCoefficientDouble(int, int)</code> for larger values; and in
|
||||||
a "super-sized" version, <code>binomialCoefficientLog(int, int)</code>
|
a "super-sized" version, <code>binomialCoefficientLog(int, int)</code>
|
||||||
that returns the natural logarithm of the value.</li>
|
that returns the natural logarithm of the value.</li>
|
||||||
<li>
|
<li>
|
||||||
Stirling numbers of the second kind -- S(n,k) as an exact long value
|
Stirling numbers of the second kind -- S(n,k) as an exact long value
|
||||||
<code>stirlingS2(int, int)</code> for small n, k.</li>
|
<code>stirlingS2(int, int)</code> for small n, k.</li>
|
||||||
<li>
|
<li>
|
||||||
Factorials -- like binomial coefficients, these are available as exact long
|
Factorials -- like binomial coefficients, these are available as exact long
|
||||||
values, <code>factorial(int)</code>; doubles,
|
values, <code>factorial(int)</code>; doubles,
|
||||||
<code>factorialDouble(int)</code>; or logs, <code>factorialLog(int)</code>. </li>
|
<code>factorialDouble(int)</code>; or logs, <code>factorialLog(int)</code>. </li>
|
||||||
<li>
|
<li>
|
||||||
Least common multiple and greatest common denominator functions.
|
Least common multiple and greatest common denominator functions.
|
||||||
|
@ -186,7 +186,7 @@
|
||||||
<p>
|
<p>
|
||||||
FastMath speed is achieved by relying heavily on optimizing compilers to
|
FastMath speed is achieved by relying heavily on optimizing compilers to
|
||||||
native code present in many JVM todays and use of large tables. Precomputed
|
native code present in many JVM todays and use of large tables. Precomputed
|
||||||
literal arrays are provided in this class to speed up load time. These
|
literal arrays are provided in this class to speed up load time. These
|
||||||
precomputed tables are used in the default configuration, to improve speed
|
precomputed tables are used in the default configuration, to improve speed
|
||||||
even at first use of the class. If users prefer to compute the tables
|
even at first use of the class. If users prefer to compute the tables
|
||||||
automatically at load time, they can change a compile-time constant. This will
|
automatically at load time, they can change a compile-time constant. This will
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class ClusterAlgorithmComparison {
|
||||||
if (factor < 0 || factor > 1) {
|
if (factor < 0 || factor > 1) {
|
||||||
throw new IllegalArgumentException();
|
throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
ContinuousDistribution.Sampler dist = new NormalDistribution(0.0, noise).createSampler(rng);
|
ContinuousDistribution.Sampler dist = new NormalDistribution(0.0, noise).createSampler(rng);
|
||||||
|
|
||||||
List<Vector2D> points = new ArrayList<>();
|
List<Vector2D> points = new ArrayList<>();
|
||||||
|
@ -77,11 +77,11 @@ public class ClusterAlgorithmComparison {
|
||||||
for (double angle = 0; angle < range; angle += step) {
|
for (double angle = 0; angle < range; angle += step) {
|
||||||
Vector2D outerCircle = Vector2D.of(FastMath.cos(angle), FastMath.sin(angle));
|
Vector2D outerCircle = Vector2D.of(FastMath.cos(angle), FastMath.sin(angle));
|
||||||
Vector2D innerCircle = outerCircle.multiply(factor);
|
Vector2D innerCircle = outerCircle.multiply(factor);
|
||||||
|
|
||||||
points.add(outerCircle.add(generateNoiseVector(dist)));
|
points.add(outerCircle.add(generateNoiseVector(dist)));
|
||||||
points.add(innerCircle.add(generateNoiseVector(dist)));
|
points.add(innerCircle.add(generateNoiseVector(dist)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shuffle) {
|
if (shuffle) {
|
||||||
ListSampler.shuffle(rng, points);
|
ListSampler.shuffle(rng, points);
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ public class ClusterAlgorithmComparison {
|
||||||
|
|
||||||
int nSamplesOut = samples / 2;
|
int nSamplesOut = samples / 2;
|
||||||
int nSamplesIn = samples - nSamplesOut;
|
int nSamplesIn = samples - nSamplesOut;
|
||||||
|
|
||||||
List<Vector2D> points = new ArrayList<>();
|
List<Vector2D> points = new ArrayList<>();
|
||||||
double range = FastMath.PI;
|
double range = FastMath.PI;
|
||||||
double step = range / (nSamplesOut / 2.0);
|
double step = range / (nSamplesOut / 2.0);
|
||||||
|
@ -111,7 +111,7 @@ public class ClusterAlgorithmComparison {
|
||||||
Vector2D innerCircle = Vector2D.of(1 - FastMath.cos(angle), 1 - FastMath.sin(angle) - 0.5);
|
Vector2D innerCircle = Vector2D.of(1 - FastMath.cos(angle), 1 - FastMath.sin(angle) - 0.5);
|
||||||
points.add(innerCircle.add(generateNoiseVector(dist)));
|
points.add(innerCircle.add(generateNoiseVector(dist)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shuffle) {
|
if (shuffle) {
|
||||||
ListSampler.shuffle(rng, points);
|
ListSampler.shuffle(rng, points);
|
||||||
}
|
}
|
||||||
|
@ -133,29 +133,29 @@ public class ClusterAlgorithmComparison {
|
||||||
for (int i = 0; i < centers; i++) {
|
for (int i = 0; i < centers; i++) {
|
||||||
centerPoints[i] = Vector2D.of(uniform.sample(), uniform.sample());
|
centerPoints[i] = Vector2D.of(uniform.sample(), uniform.sample());
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] nSamplesPerCenter = new int[centers];
|
int[] nSamplesPerCenter = new int[centers];
|
||||||
int count = samples / centers;
|
int count = samples / centers;
|
||||||
Arrays.fill(nSamplesPerCenter, count);
|
Arrays.fill(nSamplesPerCenter, count);
|
||||||
|
|
||||||
for (int i = 0; i < samples % centers; i++) {
|
for (int i = 0; i < samples % centers; i++) {
|
||||||
nSamplesPerCenter[i]++;
|
nSamplesPerCenter[i]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Vector2D> points = new ArrayList<>();
|
List<Vector2D> points = new ArrayList<>();
|
||||||
for (int i = 0; i < centers; i++) {
|
for (int i = 0; i < centers; i++) {
|
||||||
for (int j = 0; j < nSamplesPerCenter[i]; j++) {
|
for (int j = 0; j < nSamplesPerCenter[i]; j++) {
|
||||||
points.add(centerPoints[i].add(generateNoiseVector(gauss)));
|
points.add(centerPoints[i].add(generateNoiseVector(gauss)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shuffle) {
|
if (shuffle) {
|
||||||
ListSampler.shuffle(rng, points);
|
ListSampler.shuffle(rng, points);
|
||||||
}
|
}
|
||||||
|
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Vector2D> makeRandom(int samples) {
|
public static List<Vector2D> makeRandom(int samples) {
|
||||||
SobolSequenceGenerator generator = new SobolSequenceGenerator(2);
|
SobolSequenceGenerator generator = new SobolSequenceGenerator(2);
|
||||||
generator.skipTo(999999);
|
generator.skipTo(999999);
|
||||||
|
@ -167,14 +167,14 @@ public class ClusterAlgorithmComparison {
|
||||||
Vector2D point = Vector2D.of(vector);
|
Vector2D point = Vector2D.of(vector);
|
||||||
points.add(point);
|
points.add(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector2D generateNoiseVector(ContinuousDistribution.Sampler distribution) {
|
public static Vector2D generateNoiseVector(ContinuousDistribution.Sampler distribution) {
|
||||||
return Vector2D.of(distribution.sample(), distribution.sample());
|
return Vector2D.of(distribution.sample(), distribution.sample());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<DoublePoint> normalize(final List<Vector2D> input,
|
public static List<DoublePoint> normalize(final List<Vector2D> input,
|
||||||
double minX,
|
double minX,
|
||||||
double maxX,
|
double maxX,
|
||||||
|
@ -191,16 +191,16 @@ public class ClusterAlgorithmComparison {
|
||||||
}
|
}
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public static class Display extends ExampleFrame {
|
public static class Display extends ExampleFrame {
|
||||||
|
|
||||||
public Display() {
|
public Display() {
|
||||||
setTitle("Commons-Math: Cluster algorithm comparison");
|
setTitle("Commons-Math: Cluster algorithm comparison");
|
||||||
setSize(800, 800);
|
setSize(800, 800);
|
||||||
|
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
int nSamples = 1500;
|
int nSamples = 1500;
|
||||||
|
|
||||||
final long seed = RandomSource.createLong(); // Random seed.
|
final long seed = RandomSource.createLong(); // Random seed.
|
||||||
|
@ -213,7 +213,7 @@ public class ClusterAlgorithmComparison {
|
||||||
datasets.add(normalize(makeRandom(nSamples), -1, 1, -1, 1));
|
datasets.add(normalize(makeRandom(nSamples), -1, 1, -1, 1));
|
||||||
|
|
||||||
List<Pair<String, Clusterer<DoublePoint>>> algorithms = new ArrayList<>();
|
List<Pair<String, Clusterer<DoublePoint>>> algorithms = new ArrayList<>();
|
||||||
|
|
||||||
algorithms.add(new Pair<String, Clusterer<DoublePoint>>("KMeans\n(k=2)",
|
algorithms.add(new Pair<String, Clusterer<DoublePoint>>("KMeans\n(k=2)",
|
||||||
new KMeansPlusPlusClusterer<>(2)));
|
new KMeansPlusPlusClusterer<>(2)));
|
||||||
algorithms.add(new Pair<String, Clusterer<DoublePoint>>("KMeans\n(k=3)",
|
algorithms.add(new Pair<String, Clusterer<DoublePoint>>("KMeans\n(k=3)",
|
||||||
|
@ -224,7 +224,7 @@ public class ClusterAlgorithmComparison {
|
||||||
new FuzzyKMeansClusterer<>(3, 10)));
|
new FuzzyKMeansClusterer<>(3, 10)));
|
||||||
algorithms.add(new Pair<String, Clusterer<DoublePoint>>("DBSCAN\n(eps=.1, min=3)",
|
algorithms.add(new Pair<String, Clusterer<DoublePoint>>("DBSCAN\n(eps=.1, min=3)",
|
||||||
new DBSCANClusterer<>(0.1, 3)));
|
new DBSCANClusterer<>(0.1, 3)));
|
||||||
|
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.VERTICAL;
|
c.fill = GridBagConstraints.VERTICAL;
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
|
@ -248,7 +248,7 @@ public class ClusterAlgorithmComparison {
|
||||||
c.gridx++;
|
c.gridx++;
|
||||||
}
|
}
|
||||||
c.gridy++;
|
c.gridy++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +264,7 @@ public class ClusterAlgorithmComparison {
|
||||||
this.clusters = clusters;
|
this.clusters = clusters;
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
|
@ -276,10 +276,10 @@ public class ClusterAlgorithmComparison {
|
||||||
int h = getHeight();
|
int h = getHeight();
|
||||||
|
|
||||||
g2.clearRect(0, 0, w, h);
|
g2.clearRect(0, 0, w, h);
|
||||||
|
|
||||||
g2.setPaint(Color.black);
|
g2.setPaint(Color.black);
|
||||||
g2.drawRect(0, 0, w - 1, h - 1);
|
g2.drawRect(0, 0, w - 1, h - 1);
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
Color[] colors = new Color[] { Color.red, Color.blue, Color.green.darker() };
|
Color[] colors = new Color[] { Color.red, Color.blue, Color.green.darker() };
|
||||||
for (Cluster<DoublePoint> cluster : clusters) {
|
for (Cluster<DoublePoint> cluster : clusters) {
|
||||||
|
@ -289,7 +289,7 @@ public class ClusterAlgorithmComparison {
|
||||||
double[] arr = p.getPoint();
|
double[] arr = p.getPoint();
|
||||||
g2.fill(new Ellipse2D.Double(arr[0] - 1, arr[1] - 1, 3, 3));
|
g2.fill(new Ellipse2D.Double(arr[0] - 1, arr[1] - 1, 3, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
Clusterable p = transform(cluster.centroid(), w, h);
|
Clusterable p = transform(cluster.centroid(), w, h);
|
||||||
double[] arr = p.getPoint();
|
double[] arr = p.getPoint();
|
||||||
Shape s = new Ellipse2D.Double(arr[0] - 4, arr[1] - 4, 8, 8);
|
Shape s = new Ellipse2D.Double(arr[0] - 4, arr[1] - 4, 8, 8);
|
||||||
|
@ -297,11 +297,11 @@ public class ClusterAlgorithmComparison {
|
||||||
g2.setPaint(Color.black);
|
g2.setPaint(Color.black);
|
||||||
g2.draw(s);
|
g2.draw(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
g2.setPaint(Color.black);
|
g2.setPaint(Color.black);
|
||||||
g2.drawString(String.format("%.2f s", duration / 1e3), w - 40, h - 5);
|
g2.drawString(String.format("%.2f s", duration / 1e3), w - 40, h - 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize() {
|
public Dimension getPreferredSize() {
|
||||||
return new Dimension(150, 150);
|
return new Dimension(150, 150);
|
||||||
|
|
|
@ -39,12 +39,12 @@ public class ExampleUtils {
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public static class ExampleFrame extends JFrame {
|
public static class ExampleFrame extends JFrame {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the main panel which should be printed by the screenshot action.
|
* Returns the main panel which should be printed by the screenshot action.
|
||||||
* <p>
|
* <p>
|
||||||
* By default, it returns the content pane of this frame, but can be overridden
|
* By default, it returns the content pane of this frame, but can be overridden
|
||||||
* in case the frame has a global scroll pane which would cut off any offscreen content.
|
* in case the frame has a global scroll pane which would cut off any offscreen content.
|
||||||
*
|
*
|
||||||
* @return the main panel to print
|
* @return the main panel to print
|
||||||
*/
|
*/
|
||||||
|
@ -73,14 +73,14 @@ public class ExampleUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
JMenuItem exit = new JMenuItem("Exit");
|
JMenuItem exit = new JMenuItem("Exit");
|
||||||
exit.addActionListener(new ActionListener() {
|
exit.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
JMenu menu = new JMenu("File");
|
JMenu menu = new JMenu("File");
|
||||||
menu.add(screenshot);
|
menu.add(screenshot);
|
||||||
menu.add(exit);
|
menu.add(exit);
|
||||||
|
@ -102,7 +102,7 @@ public class ExampleUtils {
|
||||||
component.paint(image.getGraphics());
|
component.paint(image.getGraphics());
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BufferedImage resizeImage(BufferedImage originalImage, int width, int height, int type) throws IOException {
|
public static BufferedImage resizeImage(BufferedImage originalImage, int width, int height, int type) throws IOException {
|
||||||
BufferedImage resizedImage = new BufferedImage(width, height, type);
|
BufferedImage resizedImage = new BufferedImage(width, height, type);
|
||||||
Graphics2D g = resizedImage.createGraphics();
|
Graphics2D g = resizedImage.createGraphics();
|
||||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.commons.math4.util.FastMath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performance benchmark for FastMath.
|
* Performance benchmark for FastMath.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class FastMathTestPerformance {
|
public class FastMathTestPerformance {
|
||||||
private static final int RUNS = Integer.parseInt(System.getProperty("testRuns","10000000"));
|
private static final int RUNS = Integer.parseInt(System.getProperty("testRuns","10000000"));
|
||||||
|
@ -288,7 +288,7 @@ public class FastMathTestPerformance {
|
||||||
report("cos",strictTime,fastTime,mathTime);
|
report("cos",strictTime,fastTime,mathTime);
|
||||||
assertTrue(!Double.isNaN(x));
|
assertTrue(!Double.isNaN(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testAcos() {
|
private static void testAcos() {
|
||||||
double x = 0;
|
double x = 0;
|
||||||
long time = System.nanoTime();
|
long time = System.nanoTime();
|
||||||
|
@ -594,7 +594,7 @@ public class FastMathTestPerformance {
|
||||||
report("tanh",strictTime,fastTime,mathTime);
|
report("tanh",strictTime,fastTime,mathTime);
|
||||||
assertTrue(!Double.isNaN(x));
|
assertTrue(!Double.isNaN(x));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testExpm1() {
|
private static void testExpm1() {
|
||||||
double x = 0;
|
double x = 0;
|
||||||
long time = System.nanoTime();
|
long time = System.nanoTime();
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class LowDiscrepancyGeneratorComparison {
|
||||||
|
|
||||||
// normalize points first
|
// normalize points first
|
||||||
points = normalize(points);
|
points = normalize(points);
|
||||||
|
|
||||||
// now test if the sample is within the unit circle
|
// now test if the sample is within the unit circle
|
||||||
List<Vector2D> circlePoints = new ArrayList<>();
|
List<Vector2D> circlePoints = new ArrayList<>();
|
||||||
for (Vector2D p : points) {
|
for (Vector2D p : points) {
|
||||||
|
@ -80,7 +80,7 @@ public class LowDiscrepancyGeneratorComparison {
|
||||||
Vector2D point = Vector2D.of(vector);
|
Vector2D point = Vector2D.of(vector);
|
||||||
points.add(point);
|
points.add(point);
|
||||||
}
|
}
|
||||||
|
|
||||||
return normalize(points);
|
return normalize(points);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,16 +92,16 @@ public class LowDiscrepancyGeneratorComparison {
|
||||||
minX = FastMath.min(minX, p.getX());
|
minX = FastMath.min(minX, p.getX());
|
||||||
maxX = FastMath.max(maxX, p.getX());
|
maxX = FastMath.max(maxX, p.getX());
|
||||||
}
|
}
|
||||||
|
|
||||||
double minY, maxY;
|
double minY, maxY;
|
||||||
|
|
||||||
// use the minimum to detect if we either have input values in the range [0, 1] or [-sqrt(3), sqrt(3)]
|
// use the minimum to detect if we either have input values in the range [0, 1] or [-sqrt(3), sqrt(3)]
|
||||||
if (FastMath.abs(minX) < 0.1) {
|
if (FastMath.abs(minX) < 0.1) {
|
||||||
minX = minY = 0.0;
|
minX = minY = 0.0;
|
||||||
maxX = maxY = 1.0;
|
maxX = maxY = 1.0;
|
||||||
} else {
|
} else {
|
||||||
minX = minY = -FastMath.sqrt(3);
|
minX = minY = -FastMath.sqrt(3);
|
||||||
maxX = maxY = FastMath.sqrt(3);
|
maxX = maxY = FastMath.sqrt(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
double rangeX = maxX - minX;
|
double rangeX = maxX - minX;
|
||||||
|
@ -116,16 +116,16 @@ public class LowDiscrepancyGeneratorComparison {
|
||||||
}
|
}
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public static class Display extends ExampleFrame {
|
public static class Display extends ExampleFrame {
|
||||||
|
|
||||||
public Display() {
|
public Display() {
|
||||||
setTitle("Commons-Math: Pseudo/Quasi-random examples");
|
setTitle("Commons-Math: Pseudo/Quasi-random examples");
|
||||||
setSize(800, 800);
|
setSize(800, 800);
|
||||||
|
|
||||||
setLayout(new GridBagLayout());
|
setLayout(new GridBagLayout());
|
||||||
|
|
||||||
int[] datasets = new int[] { 256, 1000, 2500, 1000 };
|
int[] datasets = new int[] { 256, 1000, 2500, 1000 };
|
||||||
List<Pair<String, RandomVectorGenerator>> generators = new ArrayList<Pair<String, RandomVectorGenerator>>();
|
List<Pair<String, RandomVectorGenerator>> generators = new ArrayList<Pair<String, RandomVectorGenerator>>();
|
||||||
|
|
||||||
|
@ -137,18 +137,18 @@ public class LowDiscrepancyGeneratorComparison {
|
||||||
RandomSource.create(RandomSource.MT, 123456789),
|
RandomSource.create(RandomSource.MT, 123456789),
|
||||||
RandomSource.create(RandomSource.MT, 987654321)
|
RandomSource.create(RandomSource.MT, 987654321)
|
||||||
};
|
};
|
||||||
|
|
||||||
public double[] nextVector() {
|
public double[] nextVector() {
|
||||||
final double[] vector = new double[2];
|
final double[] vector = new double[2];
|
||||||
vector[0] = rngs[0].nextDouble();
|
vector[0] = rngs[0].nextDouble();
|
||||||
vector[1] = rngs[1].nextDouble();
|
vector[1] = rngs[1].nextDouble();
|
||||||
return vector;
|
return vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
}));
|
}));
|
||||||
generators.add(new Pair<>("HaltonSequence", new HaltonSequenceGenerator(2)));
|
generators.add(new Pair<>("HaltonSequence", new HaltonSequenceGenerator(2)));
|
||||||
generators.add(new Pair<>("SobolSequence", new SobolSequenceGenerator(2)));
|
generators.add(new Pair<>("SobolSequence", new SobolSequenceGenerator(2)));
|
||||||
|
|
||||||
GridBagConstraints c = new GridBagConstraints();
|
GridBagConstraints c = new GridBagConstraints();
|
||||||
c.fill = GridBagConstraints.VERTICAL;
|
c.fill = GridBagConstraints.VERTICAL;
|
||||||
c.gridx = 1;
|
c.gridx = 1;
|
||||||
|
@ -163,7 +163,7 @@ public class LowDiscrepancyGeneratorComparison {
|
||||||
c.gridx++;
|
c.gridx++;
|
||||||
}
|
}
|
||||||
int saveY = ++c.gridy;
|
int saveY = ++c.gridy;
|
||||||
|
|
||||||
c.gridx = 0;
|
c.gridx = 0;
|
||||||
for (int type = 0; type < 4; type++) {
|
for (int type = 0; type < 4; type++) {
|
||||||
JLabel text = new JLabel("n=" + String.valueOf(datasets[type]));
|
JLabel text = new JLabel("n=" + String.valueOf(datasets[type]));
|
||||||
|
@ -198,7 +198,7 @@ public class LowDiscrepancyGeneratorComparison {
|
||||||
}
|
}
|
||||||
|
|
||||||
c.gridy++;
|
c.gridy++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ public class LowDiscrepancyGeneratorComparison {
|
||||||
public Plot(final List<Vector2D> points) {
|
public Plot(final List<Vector2D> points) {
|
||||||
this.points = points;
|
this.points = points;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void paintComponent(Graphics g) {
|
protected void paintComponent(Graphics g) {
|
||||||
super.paintComponent(g);
|
super.paintComponent(g);
|
||||||
|
@ -224,17 +224,17 @@ public class LowDiscrepancyGeneratorComparison {
|
||||||
int h = getHeight();
|
int h = getHeight();
|
||||||
|
|
||||||
g2.clearRect(0, 0, w, h);
|
g2.clearRect(0, 0, w, h);
|
||||||
|
|
||||||
g2.setPaint(Color.black);
|
g2.setPaint(Color.black);
|
||||||
g2.drawRect(0, 0, w - 1, h - 1);
|
g2.drawRect(0, 0, w - 1, h - 1);
|
||||||
|
|
||||||
for (Vector2D point : points) {
|
for (Vector2D point : points) {
|
||||||
Vector2D p = transform(point, w, h);
|
Vector2D p = transform(point, w, h);
|
||||||
double[] arr = p.toArray();
|
double[] arr = p.toArray();
|
||||||
g2.draw(new Rectangle2D.Double(arr[0] - 1, arr[1] - 1, 2, 2));
|
g2.draw(new Rectangle2D.Double(arr[0] - 1, arr[1] - 1, 2, 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension getPreferredSize() {
|
public Dimension getPreferredSize() {
|
||||||
return new Dimension(140, 140);
|
return new Dimension(140, 140);
|
||||||
|
|
|
@ -53,35 +53,35 @@ import com.xeiam.xchart.StyleManager.LegendPosition;
|
||||||
public class CannonballExample {
|
public class CannonballExample {
|
||||||
|
|
||||||
public static class Cannonball {
|
public static class Cannonball {
|
||||||
|
|
||||||
private final double[] gravity = { 0, -9.81 };
|
private final double[] gravity = { 0, -9.81 };
|
||||||
private final double[] velocity;
|
private final double[] velocity;
|
||||||
private final double[] location;
|
private final double[] location;
|
||||||
|
|
||||||
private final double timeslice;
|
private final double timeslice;
|
||||||
private final double measurementNoise;
|
private final double measurementNoise;
|
||||||
|
|
||||||
private final GaussianRandomGenerator rng;
|
private final GaussianRandomGenerator rng;
|
||||||
|
|
||||||
public Cannonball(double timeslice, double angle, double initialVelocity, double measurementNoise, int seed) {
|
public Cannonball(double timeslice, double angle, double initialVelocity, double measurementNoise, int seed) {
|
||||||
this.timeslice = timeslice;
|
this.timeslice = timeslice;
|
||||||
|
|
||||||
final double angleInRadians = FastMath.toRadians(angle);
|
final double angleInRadians = FastMath.toRadians(angle);
|
||||||
this.velocity = new double[] {
|
this.velocity = new double[] {
|
||||||
initialVelocity * FastMath.cos(angleInRadians),
|
initialVelocity * FastMath.cos(angleInRadians),
|
||||||
initialVelocity * FastMath.sin(angleInRadians)
|
initialVelocity * FastMath.sin(angleInRadians)
|
||||||
};
|
};
|
||||||
|
|
||||||
this.location = new double[] { 0, 0 };
|
this.location = new double[] { 0, 0 };
|
||||||
|
|
||||||
this.measurementNoise = measurementNoise;
|
this.measurementNoise = measurementNoise;
|
||||||
this.rng = new GaussianRandomGenerator(RandomSource.create(RandomSource.WELL_19937_C, seed));
|
this.rng = new GaussianRandomGenerator(RandomSource.create(RandomSource.WELL_19937_C, seed));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getX() {
|
public double getX() {
|
||||||
return location[0];
|
return location[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getY() {
|
public double getY() {
|
||||||
return location[1];
|
return location[1];
|
||||||
}
|
}
|
||||||
|
@ -97,18 +97,18 @@ public class CannonballExample {
|
||||||
public double getXVelocity() {
|
public double getXVelocity() {
|
||||||
return velocity[0];
|
return velocity[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getYVelocity() {
|
public double getYVelocity() {
|
||||||
return velocity[1];
|
return velocity[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void step() {
|
public void step() {
|
||||||
// Break gravitational force into a smaller time slice.
|
// Break gravitational force into a smaller time slice.
|
||||||
double[] slicedGravity = gravity.clone();
|
double[] slicedGravity = gravity.clone();
|
||||||
for ( int i = 0; i < slicedGravity.length; i++ ) {
|
for ( int i = 0; i < slicedGravity.length; i++ ) {
|
||||||
slicedGravity[i] *= timeslice;
|
slicedGravity[i] *= timeslice;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the acceleration to velocity.
|
// Apply the acceleration to velocity.
|
||||||
double[] slicedVelocity = velocity.clone();
|
double[] slicedVelocity = velocity.clone();
|
||||||
for ( int i = 0; i < velocity.length; i++ ) {
|
for ( int i = 0; i < velocity.length; i++ ) {
|
||||||
|
@ -123,9 +123,9 @@ public class CannonballExample {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void cannonballTest(Chart chart) {
|
public static void cannonballTest(Chart chart) {
|
||||||
|
|
||||||
// time interval for each iteration
|
// time interval for each iteration
|
||||||
final double dt = 0.1;
|
final double dt = 0.1;
|
||||||
// the number of iterations to run
|
// the number of iterations to run
|
||||||
|
@ -139,7 +139,7 @@ public class CannonballExample {
|
||||||
|
|
||||||
// the cannonball itself
|
// the cannonball itself
|
||||||
final Cannonball cannonball = new Cannonball(dt, angle, initialVelocity, measurementNoise, 1000);
|
final Cannonball cannonball = new Cannonball(dt, angle, initialVelocity, measurementNoise, 1000);
|
||||||
|
|
||||||
// A = [ 1, dt, 0, 0 ] => x(n+1) = x(n) + vx(n)
|
// A = [ 1, dt, 0, 0 ] => x(n+1) = x(n) + vx(n)
|
||||||
// [ 0, 1, 0, 0 ] => vx(n+1) = vx(n)
|
// [ 0, 1, 0, 0 ] => vx(n+1) = vx(n)
|
||||||
// [ 0, 0, 1, dt ] => y(n+1) = y(n) + vy(n)
|
// [ 0, 0, 1, dt ] => y(n+1) = y(n) + vy(n)
|
||||||
|
@ -148,7 +148,7 @@ public class CannonballExample {
|
||||||
{ 1, dt, 0, 0 },
|
{ 1, dt, 0, 0 },
|
||||||
{ 0, 1, 0, 0 },
|
{ 0, 1, 0, 0 },
|
||||||
{ 0, 0, 1, dt },
|
{ 0, 0, 1, dt },
|
||||||
{ 0, 0, 0, 1 }
|
{ 0, 0, 0, 1 }
|
||||||
});
|
});
|
||||||
|
|
||||||
// The control vector, which adds acceleration to the kinematic equations.
|
// The control vector, which adds acceleration to the kinematic equations.
|
||||||
|
@ -183,7 +183,7 @@ public class CannonballExample {
|
||||||
{ 0, 0, 1, 0 },
|
{ 0, 0, 1, 0 },
|
||||||
{ 0, 0, 0, 0 }
|
{ 0, 0, 0, 0 }
|
||||||
});
|
});
|
||||||
|
|
||||||
// This is our guess of the initial state. I intentionally set the Y value
|
// This is our guess of the initial state. I intentionally set the Y value
|
||||||
// wrong to illustrate how fast the Kalman filter will pick up on that.
|
// wrong to illustrate how fast the Kalman filter will pick up on that.
|
||||||
final double speedX = cannonball.getXVelocity();
|
final double speedX = cannonball.getXVelocity();
|
||||||
|
@ -201,7 +201,7 @@ public class CannonballExample {
|
||||||
|
|
||||||
// we assume no process noise -> zero matrix
|
// we assume no process noise -> zero matrix
|
||||||
final RealMatrix Q = MatrixUtils.createRealMatrix(4, 4);
|
final RealMatrix Q = MatrixUtils.createRealMatrix(4, 4);
|
||||||
|
|
||||||
// the measurement covariance matrix
|
// the measurement covariance matrix
|
||||||
final RealMatrix R = MatrixUtils.createRealMatrix(new double[][] {
|
final RealMatrix R = MatrixUtils.createRealMatrix(new double[][] {
|
||||||
{ var, 0, 0, 0 },
|
{ var, 0, 0, 0 },
|
||||||
|
@ -220,7 +220,7 @@ public class CannonballExample {
|
||||||
final List<Number> measuredY = new ArrayList<>();
|
final List<Number> measuredY = new ArrayList<>();
|
||||||
final List<Number> kalmanX = new ArrayList<>();
|
final List<Number> kalmanX = new ArrayList<>();
|
||||||
final List<Number> kalmanY = new ArrayList<>();
|
final List<Number> kalmanY = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < iterations; i++) {
|
for (int i = 0; i < iterations; i++) {
|
||||||
|
|
||||||
// get real location
|
// get real location
|
||||||
|
@ -251,7 +251,7 @@ public class CannonballExample {
|
||||||
|
|
||||||
Series dataset = chart.addSeries("true", realX, realY);
|
Series dataset = chart.addSeries("true", realX, realY);
|
||||||
dataset.setMarker(SeriesMarker.NONE);
|
dataset.setMarker(SeriesMarker.NONE);
|
||||||
|
|
||||||
dataset = chart.addSeries("measured", measuredX, measuredY);
|
dataset = chart.addSeries("measured", measuredX, measuredY);
|
||||||
dataset.setLineStyle(SeriesLineStyle.DOT_DOT);
|
dataset.setLineStyle(SeriesLineStyle.DOT_DOT);
|
||||||
dataset.setMarker(SeriesMarker.NONE);
|
dataset.setMarker(SeriesMarker.NONE);
|
||||||
|
@ -275,10 +275,10 @@ public class CannonballExample {
|
||||||
chart.getStyleManager().setLegendPadding(6);
|
chart.getStyleManager().setLegendPadding(6);
|
||||||
chart.getStyleManager().setLegendSeriesLineLength(10);
|
chart.getStyleManager().setLegendSeriesLineLength(10);
|
||||||
chart.getStyleManager().setAxisTickLabelsFont(new Font("Arial", Font.PLAIN, 10));
|
chart.getStyleManager().setAxisTickLabelsFont(new Font("Arial", Font.PLAIN, 10));
|
||||||
|
|
||||||
chart.getStyleManager().setChartBackgroundColor(Color.white);
|
chart.getStyleManager().setChartBackgroundColor(Color.white);
|
||||||
chart.getStyleManager().setChartPadding(4);
|
chart.getStyleManager().setChartPadding(4);
|
||||||
|
|
||||||
chart.getStyleManager().setChartType(ChartType.Line);
|
chart.getStyleManager().setChartType(ChartType.Line);
|
||||||
return chart;
|
return chart;
|
||||||
}
|
}
|
||||||
|
@ -290,20 +290,20 @@ public class CannonballExample {
|
||||||
Chart chart = createChart("Cannonball", LegendPosition.InsideNE);
|
Chart chart = createChart("Cannonball", LegendPosition.InsideNE);
|
||||||
cannonballTest(chart);
|
cannonballTest(chart);
|
||||||
container.add(new XChartPanel(chart));
|
container.add(new XChartPanel(chart));
|
||||||
|
|
||||||
container.setBorder(BorderFactory.createLineBorder(Color.black, 1));
|
container.setBorder(BorderFactory.createLineBorder(Color.black, 1));
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public static class Display extends ExampleFrame {
|
public static class Display extends ExampleFrame {
|
||||||
|
|
||||||
private JComponent container;
|
private JComponent container;
|
||||||
|
|
||||||
public Display() {
|
public Display() {
|
||||||
setTitle("Commons Math: Kalman Filter - Cannonball");
|
setTitle("Commons Math: Kalman Filter - Cannonball");
|
||||||
setSize(800, 600);
|
setSize(800, 600);
|
||||||
|
|
||||||
container = new JPanel();
|
container = new JPanel();
|
||||||
JComponent comp = createComponent();
|
JComponent comp = createComponent();
|
||||||
container.add(comp);
|
container.add(comp);
|
||||||
|
|
|
@ -53,7 +53,7 @@ import com.xeiam.xchart.StyleManager.LegendPosition;
|
||||||
public class ConstantVoltageExample {
|
public class ConstantVoltageExample {
|
||||||
|
|
||||||
public static class VoltMeter {
|
public static class VoltMeter {
|
||||||
|
|
||||||
private final double initialVoltage;
|
private final double initialVoltage;
|
||||||
private final double processNoise;
|
private final double processNoise;
|
||||||
private final double measurementNoise;
|
private final double measurementNoise;
|
||||||
|
@ -68,20 +68,20 @@ public class ConstantVoltageExample {
|
||||||
this.measurementNoise = measurementNoise;
|
this.measurementNoise = measurementNoise;
|
||||||
rng = new GaussianRandomGenerator(RandomSource.create(RandomSource.WELL_19937_C, seed));
|
rng = new GaussianRandomGenerator(RandomSource.create(RandomSource.WELL_19937_C, seed));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the real voltage without any measurement noise.
|
* Returns the real voltage without any measurement noise.
|
||||||
*
|
*
|
||||||
* @return the real voltage
|
* @return the real voltage
|
||||||
*/
|
*/
|
||||||
public double getVoltage() {
|
public double getVoltage() {
|
||||||
return voltage;
|
return voltage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMeasuredVoltage() {
|
public double getMeasuredVoltage() {
|
||||||
return getVoltage() + rng.nextNormalizedDouble() * measurementNoise;
|
return getVoltage() + rng.nextNormalizedDouble() * measurementNoise;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void step() {
|
public void step() {
|
||||||
// we apply only the process noise
|
// we apply only the process noise
|
||||||
voltage = initialVoltage + rng.nextNormalizedDouble() * processNoise;
|
voltage = initialVoltage + rng.nextNormalizedDouble() * processNoise;
|
||||||
|
@ -96,7 +96,7 @@ public class ConstantVoltageExample {
|
||||||
final double processNoise = 1e-5d;
|
final double processNoise = 1e-5d;
|
||||||
|
|
||||||
final VoltMeter voltMeter = new VoltMeter(voltage, processNoise, measurementNoise, 2);
|
final VoltMeter voltMeter = new VoltMeter(voltage, processNoise, measurementNoise, 2);
|
||||||
|
|
||||||
// the state transition matrix -> constant
|
// the state transition matrix -> constant
|
||||||
final RealMatrix A = new Array2DRowRealMatrix(new double[] { 1d });
|
final RealMatrix A = new Array2DRowRealMatrix(new double[] { 1d });
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public class ConstantVoltageExample {
|
||||||
|
|
||||||
// the initial state vector -> slightly wrong
|
// the initial state vector -> slightly wrong
|
||||||
final RealVector x0 = new ArrayRealVector(new double[] { 1.45 });
|
final RealVector x0 = new ArrayRealVector(new double[] { 1.45 });
|
||||||
|
|
||||||
// the process covariance matrix
|
// the process covariance matrix
|
||||||
final RealMatrix Q = new Array2DRowRealMatrix(new double[] { processNoise * processNoise });
|
final RealMatrix Q = new Array2DRowRealMatrix(new double[] { processNoise * processNoise });
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ public class ConstantVoltageExample {
|
||||||
final List<Number> kalmanVoltageSeries = new ArrayList<>();
|
final List<Number> kalmanVoltageSeries = new ArrayList<>();
|
||||||
|
|
||||||
final List<Number> covSeries = new ArrayList<>();
|
final List<Number> covSeries = new ArrayList<>();
|
||||||
|
|
||||||
for (int i = 0; i < 300; i++) {
|
for (int i = 0; i < 300; i++) {
|
||||||
xAxis.add(i);
|
xAxis.add(i);
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public class ConstantVoltageExample {
|
||||||
|
|
||||||
Series dataset = chart1.addSeries("real", xAxis, realVoltageSeries);
|
Series dataset = chart1.addSeries("real", xAxis, realVoltageSeries);
|
||||||
dataset.setMarker(SeriesMarker.NONE);
|
dataset.setMarker(SeriesMarker.NONE);
|
||||||
|
|
||||||
dataset = chart1.addSeries("measured", xAxis, measuredVoltageSeries);
|
dataset = chart1.addSeries("measured", xAxis, measuredVoltageSeries);
|
||||||
dataset.setLineStyle(SeriesLineStyle.DOT_DOT);
|
dataset.setLineStyle(SeriesLineStyle.DOT_DOT);
|
||||||
dataset.setMarker(SeriesMarker.NONE);
|
dataset.setMarker(SeriesMarker.NONE);
|
||||||
|
@ -166,7 +166,7 @@ public class ConstantVoltageExample {
|
||||||
|
|
||||||
chart2.setYAxisTitle("(Voltage)²");
|
chart2.setYAxisTitle("(Voltage)²");
|
||||||
chart2.setXAxisTitle("Iteration");
|
chart2.setXAxisTitle("Iteration");
|
||||||
|
|
||||||
dataset = chart2.addSeries("cov", xAxis, covSeries);
|
dataset = chart2.addSeries("cov", xAxis, covSeries);
|
||||||
dataset.setLineColor(Color.black);
|
dataset.setLineColor(Color.black);
|
||||||
dataset.setLineStyle(SeriesLineStyle.SOLID);
|
dataset.setLineStyle(SeriesLineStyle.SOLID);
|
||||||
|
@ -187,10 +187,10 @@ public class ConstantVoltageExample {
|
||||||
chart.getStyleManager().setLegendPadding(6);
|
chart.getStyleManager().setLegendPadding(6);
|
||||||
chart.getStyleManager().setLegendSeriesLineLength(10);
|
chart.getStyleManager().setLegendSeriesLineLength(10);
|
||||||
chart.getStyleManager().setAxisTickLabelsFont(new Font("Arial", Font.PLAIN, 10));
|
chart.getStyleManager().setAxisTickLabelsFont(new Font("Arial", Font.PLAIN, 10));
|
||||||
|
|
||||||
chart.getStyleManager().setChartBackgroundColor(Color.white);
|
chart.getStyleManager().setChartBackgroundColor(Color.white);
|
||||||
chart.getStyleManager().setChartPadding(4);
|
chart.getStyleManager().setChartPadding(4);
|
||||||
|
|
||||||
chart.getStyleManager().setChartType(ChartType.Line);
|
chart.getStyleManager().setChartType(ChartType.Line);
|
||||||
return chart;
|
return chart;
|
||||||
}
|
}
|
||||||
|
@ -198,28 +198,28 @@ public class ConstantVoltageExample {
|
||||||
public static JComponent createComponent() {
|
public static JComponent createComponent() {
|
||||||
JComponent container = new JPanel();
|
JComponent container = new JPanel();
|
||||||
container.setLayout(new BoxLayout(container, BoxLayout.LINE_AXIS));
|
container.setLayout(new BoxLayout(container, BoxLayout.LINE_AXIS));
|
||||||
|
|
||||||
Chart chart1 = createChart("Voltage", 550, 450, LegendPosition.InsideNE, true);
|
Chart chart1 = createChart("Voltage", 550, 450, LegendPosition.InsideNE, true);
|
||||||
Chart chart2 = createChart("Error Covariance", 450, 450, LegendPosition.InsideNE, false);
|
Chart chart2 = createChart("Error Covariance", 450, 450, LegendPosition.InsideNE, false);
|
||||||
|
|
||||||
constantVoltageTest(chart1, chart2);
|
constantVoltageTest(chart1, chart2);
|
||||||
|
|
||||||
container.add(new XChartPanel(chart1));
|
container.add(new XChartPanel(chart1));
|
||||||
container.add(new XChartPanel(chart2));
|
container.add(new XChartPanel(chart2));
|
||||||
|
|
||||||
container.setBorder(BorderFactory.createLineBorder(Color.black, 1));
|
container.setBorder(BorderFactory.createLineBorder(Color.black, 1));
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public static class Display extends ExampleFrame {
|
public static class Display extends ExampleFrame {
|
||||||
|
|
||||||
private JComponent container;
|
private JComponent container;
|
||||||
|
|
||||||
public Display() {
|
public Display() {
|
||||||
setTitle("Commons-Math: Kalman Filter example");
|
setTitle("Commons-Math: Kalman Filter example");
|
||||||
setSize(1100, 700);
|
setSize(1100, 700);
|
||||||
|
|
||||||
container = new JPanel();
|
container = new JPanel();
|
||||||
|
|
||||||
JComponent comp = createComponent();
|
JComponent comp = createComponent();
|
||||||
|
|
|
@ -60,13 +60,13 @@ public class HelloWorldExample {
|
||||||
|
|
||||||
// stopping condition
|
// stopping condition
|
||||||
StoppingCondition stoppingCondition = new StoppingCondition() {
|
StoppingCondition stoppingCondition = new StoppingCondition() {
|
||||||
|
|
||||||
int generation = 0;
|
int generation = 0;
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
public boolean isSatisfied(Population population) {
|
public boolean isSatisfied(Population population) {
|
||||||
Chromosome fittestChromosome = population.getFittestChromosome();
|
Chromosome fittestChromosome = population.getFittestChromosome();
|
||||||
|
|
||||||
if (generation == 1 || generation % 10 == 0) {
|
if (generation == 1 || generation % 10 == 0) {
|
||||||
System.out.println("Generation " + generation + ": " + fittestChromosome.toString());
|
System.out.println("Generation " + generation + ": " + fittestChromosome.toString());
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ public class HelloWorldExample {
|
||||||
};
|
};
|
||||||
|
|
||||||
System.out.println("Starting evolution ...");
|
System.out.println("Starting evolution ...");
|
||||||
|
|
||||||
// run the algorithm
|
// run the algorithm
|
||||||
Population finalPopulation = ga.evolve(initial, stoppingCondition);
|
Population finalPopulation = ga.evolve(initial, stoppingCondition);
|
||||||
|
|
||||||
|
@ -94,15 +94,15 @@ public class HelloWorldExample {
|
||||||
System.out.println("Generation " + ga.getGenerationsEvolved() + ": " + best.toString());
|
System.out.println("Generation " + ga.getGenerationsEvolved() + ": " + best.toString());
|
||||||
System.out.println("Total execution time: " + (endTime - startTime) + "ms");
|
System.out.println("Total execution time: " + (endTime - startTime) + "ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Character> randomRepresentation(int length) {
|
private static List<Character> randomRepresentation(int length) {
|
||||||
return asList(RandomStringUtils.randomAscii(length));
|
return asList(RandomStringUtils.randomAscii(length));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Character> asList(String str) {
|
private static List<Character> asList(String str) {
|
||||||
return Arrays.asList(ArrayUtils.toObject(str.toCharArray()));
|
return Arrays.asList(ArrayUtils.toObject(str.toCharArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Population getInitialPopulation() {
|
private static Population getInitialPopulation() {
|
||||||
List<Chromosome> popList = new LinkedList<>();
|
List<Chromosome> popList = new LinkedList<>();
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ public class HelloWorldExample {
|
||||||
|
|
||||||
StringChromosome strChromosome = (StringChromosome) original;
|
StringChromosome strChromosome = (StringChromosome) original;
|
||||||
List<Character> characters = strChromosome.getStringRepresentation();
|
List<Character> characters = strChromosome.getStringRepresentation();
|
||||||
|
|
||||||
int mutationIndex = GeneticAlgorithm.getRandomGenerator().nextInt(characters.size());
|
int mutationIndex = GeneticAlgorithm.getRandomGenerator().nextInt(characters.size());
|
||||||
|
|
||||||
List<Character> mutatedChromosome = new ArrayList<>(characters);
|
List<Character> mutatedChromosome = new ArrayList<>(characters);
|
||||||
|
|
|
@ -49,7 +49,7 @@ import org.apache.commons.math4.userguide.ExampleUtils.ExampleFrame;
|
||||||
* with ~100 semi-transparent polygons of length 6.
|
* with ~100 semi-transparent polygons of length 6.
|
||||||
* <p>
|
* <p>
|
||||||
* The fitness function is quite simple yet expensive to compute:
|
* The fitness function is quite simple yet expensive to compute:
|
||||||
*
|
*
|
||||||
* - draw the polygons of a chromosome to an image
|
* - draw the polygons of a chromosome to an image
|
||||||
* - compare each pixel with the corresponding reference image
|
* - compare each pixel with the corresponding reference image
|
||||||
* <p>
|
* <p>
|
||||||
|
@ -62,7 +62,7 @@ import org.apache.commons.math4.userguide.ExampleUtils.ExampleFrame;
|
||||||
* - add a gallery of results after x iterations / minutes (either automatic or based on button click)
|
* - add a gallery of results after x iterations / minutes (either automatic or based on button click)
|
||||||
* - allow loading / selection of other images
|
* - allow loading / selection of other images
|
||||||
* - add logging in the user interface, e.g. number of generations, time spent, ...
|
* - add logging in the user interface, e.g. number of generations, time spent, ...
|
||||||
*
|
*
|
||||||
* @see <a href="http://www.nihilogic.dk/labs/evolving-images/">Evolving Images with JavaScript and canvas (Nihilogic)</a>
|
* @see <a href="http://www.nihilogic.dk/labs/evolving-images/">Evolving Images with JavaScript and canvas (Nihilogic)</a>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
@ -77,7 +77,7 @@ public class ImageEvolutionExample {
|
||||||
public static final int POLYGON_COUNT = 100;
|
public static final int POLYGON_COUNT = 100;
|
||||||
|
|
||||||
public static class Display extends ExampleFrame {
|
public static class Display extends ExampleFrame {
|
||||||
|
|
||||||
private GeneticAlgorithm ga;
|
private GeneticAlgorithm ga;
|
||||||
private Population currentPopulation;
|
private Population currentPopulation;
|
||||||
private Chromosome bestFit;
|
private Chromosome bestFit;
|
||||||
|
@ -86,16 +86,16 @@ public class ImageEvolutionExample {
|
||||||
private volatile boolean noStopRequested;
|
private volatile boolean noStopRequested;
|
||||||
|
|
||||||
private BufferedImage ref;
|
private BufferedImage ref;
|
||||||
|
|
||||||
private BufferedImage referenceImage;
|
private BufferedImage referenceImage;
|
||||||
private BufferedImage testImage;
|
private BufferedImage testImage;
|
||||||
|
|
||||||
private ImagePainter painter;
|
private ImagePainter painter;
|
||||||
|
|
||||||
public Display() throws Exception {
|
public Display() throws Exception {
|
||||||
setTitle("Commons-Math: Image Evolution Example");
|
setTitle("Commons-Math: Image Evolution Example");
|
||||||
setSize(600, 400);
|
setSize(600, 400);
|
||||||
|
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
|
|
||||||
Box bar = Box.createHorizontalBox();
|
Box bar = Box.createHorizontalBox();
|
||||||
|
@ -143,7 +143,7 @@ public class ImageEvolutionExample {
|
||||||
currentPopulation = getInitialPopulation();
|
currentPopulation = getInitialPopulation();
|
||||||
bestFit = currentPopulation.getFittestChromosome();
|
bestFit = currentPopulation.getFittestChromosome();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAlive() {
|
public boolean isAlive() {
|
||||||
return internalThread != null && internalThread.isAlive();
|
return internalThread != null && internalThread.isAlive();
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ public class ImageEvolutionExample {
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ImagePainter extends Component {
|
private class ImagePainter extends Component {
|
||||||
|
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class Polygon {
|
||||||
final int polygonSize = 4 + 2 * length;
|
final int polygonSize = 4 + 2 * length;
|
||||||
|
|
||||||
final UniformRandomProvider random = GeneticAlgorithm.getRandomGenerator();
|
final UniformRandomProvider random = GeneticAlgorithm.getRandomGenerator();
|
||||||
|
|
||||||
Polygon p = new Polygon();
|
Polygon p = new Polygon();
|
||||||
p.data = new float[polygonSize];
|
p.data = new float[polygonSize];
|
||||||
|
|
||||||
|
@ -61,10 +61,10 @@ public class Polygon {
|
||||||
p.data[1] = random.nextFloat(); // g
|
p.data[1] = random.nextFloat(); // g
|
||||||
p.data[2] = random.nextFloat(); // b
|
p.data[2] = random.nextFloat(); // b
|
||||||
p.data[3] = FastMath.max(0.2f, random.nextFloat() * random.nextFloat()); // a
|
p.data[3] = FastMath.max(0.2f, random.nextFloat() * random.nextFloat()); // a
|
||||||
|
|
||||||
float px = random.nextFloat();
|
float px = random.nextFloat();
|
||||||
float py = random.nextFloat();
|
float py = random.nextFloat();
|
||||||
|
|
||||||
for (int k = 0; k < length; k++) {
|
for (int k = 0; k < length; k++) {
|
||||||
p.data[4 + 2*k] = px + (random.nextFloat() - 0.5f);
|
p.data[4 + 2*k] = px + (random.nextFloat() - 0.5f);
|
||||||
p.data[5 + 2*k] = py + (random.nextFloat() - 0.5f);
|
p.data[5 + 2*k] = py + (random.nextFloat() - 0.5f);
|
||||||
|
@ -78,7 +78,7 @@ public class Polygon {
|
||||||
* Each component of the Polygon may be mutated according to the specified mutation rate.
|
* Each component of the Polygon may be mutated according to the specified mutation rate.
|
||||||
* In case a component is going to be mutated, its value will be randomly modified in the
|
* In case a component is going to be mutated, its value will be randomly modified in the
|
||||||
* uniform range of [-mutationAmount, +mutationAmount].
|
* uniform range of [-mutationAmount, +mutationAmount].
|
||||||
*
|
*
|
||||||
* @param mutationRate the mutation rate
|
* @param mutationRate the mutation rate
|
||||||
* @param mutationAmount the mutation amount
|
* @param mutationAmount the mutation amount
|
||||||
* @return a new Polygon
|
* @return a new Polygon
|
||||||
|
@ -91,7 +91,7 @@ public class Polygon {
|
||||||
float val = this.data[i];
|
float val = this.data[i];
|
||||||
if (GeneticAlgorithm.getRandomGenerator().nextFloat() < mutationRate) {
|
if (GeneticAlgorithm.getRandomGenerator().nextFloat() < mutationRate) {
|
||||||
val += GeneticAlgorithm.getRandomGenerator().nextFloat() * mutationAmount * 2 - mutationAmount;
|
val += GeneticAlgorithm.getRandomGenerator().nextFloat() * mutationAmount * 2 - mutationAmount;
|
||||||
|
|
||||||
if (val < 0f) {
|
if (val < 0f) {
|
||||||
val = 0f;
|
val = 0f;
|
||||||
} else if (val > 1f) {
|
} else if (val > 1f) {
|
||||||
|
@ -101,7 +101,7 @@ public class Polygon {
|
||||||
mutated.data[i] = val;
|
mutated.data[i] = val;
|
||||||
}
|
}
|
||||||
return mutated;
|
return mutated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the Polygon to the buffer of the given size.
|
* Draw the Polygon to the buffer of the given size.
|
||||||
|
@ -111,7 +111,7 @@ public class Polygon {
|
||||||
|
|
||||||
GeneralPath path = new GeneralPath();
|
GeneralPath path = new GeneralPath();
|
||||||
path.moveTo(data[4] * width, data[5] * height);
|
path.moveTo(data[4] * width, data[5] * height);
|
||||||
|
|
||||||
int polygonLength = (data.length - 4) / 2;
|
int polygonLength = (data.length - 4) / 2;
|
||||||
for (int j = 1; j < polygonLength; j++) {
|
for (int j = 1; j < polygonLength; j++) {
|
||||||
path.lineTo(data[4 + j * 2] * width, data[5 + j * 2] * height);
|
path.lineTo(data[4 + j * 2] * width, data[5 + j * 2] * height);
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class PolygonChromosome extends AbstractListChromosome<Polygon> {
|
||||||
public double fitness() {
|
public double fitness() {
|
||||||
|
|
||||||
Graphics2D g2 = testImage.createGraphics();
|
Graphics2D g2 = testImage.createGraphics();
|
||||||
|
|
||||||
int width = testImage.getWidth();
|
int width = testImage.getWidth();
|
||||||
int height = testImage.getHeight();
|
int height = testImage.getHeight();
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ public class PolygonChromosome extends AbstractListChromosome<Polygon> {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("(f=%s)", getFitness());
|
return String.format("(f=%s)", getFitness());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Chromosome randomChromosome(int polygonLength, int polygonCount) {
|
public static Chromosome randomChromosome(int polygonLength, int polygonCount) {
|
||||||
List<Polygon> list = new ArrayList<>(polygonCount);
|
List<Polygon> list = new ArrayList<>(polygonCount);
|
||||||
for (int j = 0; j < polygonCount; j++) {
|
for (int j = 0; j < polygonCount; j++) {
|
||||||
|
|
|
@ -23,10 +23,10 @@ import org.apache.commons.math4.genetics.Chromosome;
|
||||||
import org.apache.commons.math4.genetics.MutationPolicy;
|
import org.apache.commons.math4.genetics.MutationPolicy;
|
||||||
|
|
||||||
public class RandomPolygonMutation implements MutationPolicy {
|
public class RandomPolygonMutation implements MutationPolicy {
|
||||||
|
|
||||||
private float mutationRate;
|
private float mutationRate;
|
||||||
private float mutationAmount;
|
private float mutationAmount;
|
||||||
|
|
||||||
public RandomPolygonMutation(float mutationRate, float mutationAmount) {
|
public RandomPolygonMutation(float mutationRate, float mutationAmount) {
|
||||||
this.mutationRate = mutationRate;
|
this.mutationRate = mutationRate;
|
||||||
this.mutationAmount = mutationAmount;
|
this.mutationAmount = mutationAmount;
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-math4-examples</artifactId>
|
<artifactId>commons-math4-examples</artifactId>
|
||||||
<version>4.0-SNAPSHOT</version>
|
<version>4.0-SNAPSHOT</version>
|
||||||
<name>Commons Math User Guide</name>
|
<name>Commons Math User Guide</name>
|
||||||
<inceptionYear>2003</inceptionYear>
|
<inceptionYear>2003</inceptionYear>
|
||||||
<description>Examples</description>
|
<description>Examples</description>
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<maven.compiler.source>1.7</maven.compiler.source>
|
<maven.compiler.source>1.7</maven.compiler.source>
|
||||||
<maven.compiler.target>1.7</maven.compiler.target>
|
<maven.compiler.target>1.7</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>java</sourceDirectory>
|
<sourceDirectory>java</sourceDirectory>
|
||||||
|
@ -105,7 +105,7 @@
|
||||||
<groupId>org.piccolo2d</groupId>
|
<groupId>org.piccolo2d</groupId>
|
||||||
<artifactId>piccolo2d-extras</artifactId>
|
<artifactId>piccolo2d-extras</artifactId>
|
||||||
<version>3.0</version>
|
<version>3.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue