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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void generateSineData(double[] xval, double[] yval, double xnoise, double ynoise) {
|
||||
double dx = 2 * JdkMath.PI / xval.length;
|
||||
double x = 0;
|
||||
|
|
|
@ -109,7 +109,7 @@ public final class MullerSolverTest {
|
|||
UnivariateFunction f = new Expm1();
|
||||
UnivariateSolver solver = new MullerSolver();
|
||||
double min;
|
||||
double max;
|
||||
double max;
|
||||
double expected;
|
||||
double result;
|
||||
double tolerance;
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.junit.Assert;
|
|||
public class SimplePointCheckerTest {
|
||||
@Test(expected=NotStrictlyPositiveException.class)
|
||||
public void testIterationCheckPrecondition() {
|
||||
new SimplePointChecker<PointValuePair>(1e-1, 1e-2, 0);
|
||||
new SimplePointChecker<>(1e-1, 1e-2, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -83,7 +83,7 @@ public class MultivariateFunctionPenaltyAdapterTest {
|
|||
biQuadratic.getUpper(),
|
||||
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
|
||||
= optimizer.optimize(new MaxEval(600),
|
||||
|
@ -133,7 +133,7 @@ public class MultivariateFunctionPenaltyAdapterTest {
|
|||
biQuadratic.getUpper(),
|
||||
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
|
||||
= 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("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");
|
||||
|
@ -260,10 +260,10 @@ public final class FrequencyTest {
|
|||
Assert.assertEquals(1, f.getCount(ONE_LONG));
|
||||
Assert.assertEquals(0, f.getCount(TWO_LONG));
|
||||
|
||||
Frequency<Long> g = new Frequency<>();
|
||||
Frequency<Long> g = new Frequency<Long>();
|
||||
g.addValue(TWO_LONG);
|
||||
|
||||
Frequency<Long> h = new Frequency<>();
|
||||
Frequency<Long> h = new Frequency<Long>();
|
||||
h.addValue(THREE_LONG);
|
||||
|
||||
List<Frequency<Long>> coll = new ArrayList<>();
|
||||
|
|
|
@ -387,7 +387,7 @@ public class PSquarePercentileTest extends
|
|||
|
||||
@Test(expected = MathIllegalArgumentException.class)
|
||||
public void testInitial() {
|
||||
PSquarePercentile.newMarkers(new ArrayList<Double>(), 0.5);
|
||||
PSquarePercentile.newMarkers(new ArrayList<>(), 0.5);
|
||||
Assert.fail();
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ public class Network
|
|||
}
|
||||
|
||||
neuronMap.put(id, new Neuron(id, features.clone()));
|
||||
linkMap.put(id, new HashSet<Long>());
|
||||
linkMap.put(id, new HashSet<>());
|
||||
|
||||
if (id > nextId.get()) {
|
||||
nextId.set(id);
|
||||
|
|
|
@ -36,7 +36,7 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
-->
|
||||
|
||||
<!-- 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.
|
||||
|
||||
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">
|
||||
Added logDensity(double) to RealDistribution and logProbability(int)
|
||||
to IntegerDistribution interface. The implementations have already been
|
||||
updated in release 3.3.
|
||||
updated in release 3.3.
|
||||
</action>
|
||||
<action dev="tn" type="update" issue="MATH-1155">
|
||||
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
|
||||
case polynomials are generated from multiple threads. Furthermore, the
|
||||
synchronization is now performed on the coefficient list instead of the class.
|
||||
</action>
|
||||
</action>
|
||||
<action dev="psteitz" type="update" issue="MATH-1246">
|
||||
Added bootstrap method to KolmogorovSmirnov test.
|
||||
</action>
|
||||
|
@ -599,7 +599,7 @@ Users are encouraged to upgrade to this version as this release not
|
|||
</action>
|
||||
<action dev="tn" type="fix" issue="MATH-1283" due-to="Jean Noel Delavalade">
|
||||
Fixed "Gamma#gamma(double)" for negative values smaller than -20.
|
||||
</action>
|
||||
</action>
|
||||
<action dev="tn" type="fix" issue="MATH-1237" due-to="Ken Williams">
|
||||
Fixed javadoc of methods {floorDiv,floorMod} in class "FastMath".
|
||||
</action>
|
||||
|
@ -697,7 +697,7 @@ Users are encouraged to upgrade to this version as this release not
|
|||
</action>
|
||||
<action dev="psteitz" type="fix" issue="MATH-1245">
|
||||
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).
|
||||
</action>
|
||||
<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">
|
||||
Improved performance to calculate the two-sample Kolmogorov-Smirnov test
|
||||
via monte carlo simulation ("KolmogorovSmirnovTets#monteCarloP(...)").
|
||||
</action>
|
||||
</action>
|
||||
<action dev="tn" type="fix" issue="MATH-1241" due-to="Aleksei Dievskii">
|
||||
A "StackOverflowException" was thrown when passing Double.NaN or infinity
|
||||
to "Gamma#digamma(double)" or "Gamma#trigamma(double)". Now the input value
|
||||
is propagated to the output if it is not a real number.
|
||||
</action>
|
||||
</action>
|
||||
<action dev="tn" type="fix" issue="MATH-1232" due-to="Otmar Ertl">
|
||||
Improved performance of calculating the two-sample Kolmogorov-Smirnov
|
||||
test statistic.
|
||||
</action>
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-1232">
|
||||
Fixed error message for unknown parameter name in ODE.
|
||||
</action>
|
||||
|
@ -738,7 +738,7 @@ Users are encouraged to upgrade to this version as this release not
|
|||
<action dev="tn" type="fix">
|
||||
Fix potential branching errors in "FastMath#pow(double, double)" when
|
||||
passing special values, i.e. infinity, due to erroneous JIT optimization.
|
||||
</action>
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-1118" >
|
||||
Fixed equals/hashcode contract failure for Dfp.
|
||||
</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">
|
||||
Computation of 2-sample Kolmogorov-Smirnov statistic in case of ties
|
||||
was not correct.
|
||||
</action>
|
||||
</action>
|
||||
</release>
|
||||
|
||||
<release version="3.5" date="2015-04-17" description="
|
||||
This is a minor release: It combines bug fixes and new features.
|
||||
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.
|
||||
|
||||
|
||||
Most notable among the new features are:
|
||||
getQuadraticMean method added to DescriptiveStatistics SummaryStatistics
|
||||
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
|
||||
numerous bug fixes. See below for a full list.
|
||||
|
||||
|
||||
The minimum version of the Java platform required to compile and use
|
||||
Apache Commons Math is Java 5.
|
||||
|
||||
|
||||
Users are encouraged to upgrade to this version as this release not
|
||||
only includes bug fixes but also deprecates numerous classes and
|
||||
methods that will be deleted from the next major release (4.0).
|
||||
|
||||
|
||||
Caveat:
|
||||
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
||||
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">
|
||||
Moved FastMathTestPerformance out of the main test tree, as is is
|
||||
a benchmark rather than a test.
|
||||
</action>
|
||||
</action>
|
||||
<action dev="luc" type="add">
|
||||
Added a way to build polyhedrons sets from a list of vertices and
|
||||
facets specified using vertices indices.
|
||||
</action>
|
||||
</action>
|
||||
<action dev="psteitz" type="update" issue="MATH-1213">
|
||||
Added Laguerre complex solve methods taking maxEval parameters.
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-1191">
|
||||
Fixed ignored method parameters in QRDecomposition protected methods.
|
||||
</action>
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-1211" due-to="Mike Zimmerman">
|
||||
Fixed wrong selection of line/polyhedron intersection point.
|
||||
</action>
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-1162">
|
||||
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">
|
||||
Fixed link to algorithm description in "PoissonDistribution#sample()".
|
||||
</action>
|
||||
</action>
|
||||
<action dev="psteitz" type="fix" issue="MATH-1208">
|
||||
EmpiricalDistribution cumulativeProbability can return NaN when evaluated within a constant bin.
|
||||
</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.
|
||||
Changes to existing features were made in a backwards-compatible
|
||||
way such as to allow drop-in replacement of the v3.3 JAR file.
|
||||
|
||||
|
||||
Most notable among the new features are:
|
||||
new distributions (Gumbel, Laplace, Logistic, Nakagami), and
|
||||
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
|
||||
several improvements on performances or robustness. See below
|
||||
for a full list.
|
||||
|
||||
|
||||
The minimum version of the Java platform required to compile and use
|
||||
Apache Commons Math is Java 5.
|
||||
|
||||
|
||||
Users are encouraged to upgrade to this version as this release not
|
||||
only includes bug fixes but also deprecates numerous classes and
|
||||
methods that will be deleted from the next major release (4.0).
|
||||
|
||||
|
||||
Caveat:
|
||||
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
||||
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 dev="psteitz" type="fix" issue="MATH-1181">
|
||||
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.
|
||||
</action>
|
||||
<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 dev="luc" type="update" >
|
||||
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 dev="luc" type="fix" issue="MATH-1174" >
|
||||
Fixed a problem with too thin polygons considered to have infinite size.
|
||||
</action>
|
||||
<action dev="luc" type="add" >
|
||||
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 dev="luc" type="fix" issue="MATH-1162" >
|
||||
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")
|
||||
to avoid evaluating the model when the optimization algorithm does not actually
|
||||
require it.
|
||||
</action>
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-1127">
|
||||
Fixed overflow in Precision.equals with ulps (both double and float versions).
|
||||
</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.
|
||||
Changes to existing features were made in a backwards-compatible
|
||||
way such as to allow drop-in replacement of the v3.x JAR file.
|
||||
|
||||
|
||||
Most notable among the new features are:
|
||||
Framework for creating artificial neural nets, self organizing feature maps,
|
||||
computational geometry algorithms (convex hull, enclosing ball), performance
|
||||
improvements of the linear simplex solver, refactoring of curve fitters,
|
||||
low-discrepancy random generators (sobol, halton), least-squares fitting.
|
||||
|
||||
|
||||
The minimum version of the Java platform required to compile and use
|
||||
Commons Math is Java 5.
|
||||
|
||||
|
||||
Users are encouraged to upgrade to this version as this release not
|
||||
only includes bug fixes but also deprecates numerous classes and
|
||||
methods that will be deleted from the next major release (4.0).
|
||||
|
||||
|
||||
Caveat:
|
||||
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
||||
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
|
||||
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
|
||||
used for other purposes.
|
||||
used for other purposes.
|
||||
">
|
||||
<action dev="tn" type="add" issue="MATH-1110" due-to="Edward Segall">
|
||||
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").
|
||||
</action>
|
||||
<action dev="erans" type="update" issue="MATH-995">
|
||||
Documented limitation of "IterativeLegendreGaussIntegrator" (added
|
||||
Documented limitation of "IterativeLegendreGaussIntegrator" (added
|
||||
warning about potential wrong usage).
|
||||
</action>
|
||||
<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.
|
||||
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.
|
||||
|
||||
|
||||
Most notable among the new features are: Framework for automatic
|
||||
differentiation, Lévy distribution, prime numbers, enumerated
|
||||
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
|
||||
coordinates with gradients and Hessians, reorganized clustering
|
||||
package with different distance implementations.
|
||||
|
||||
|
||||
The minimum version of the Java platform required to compile and use
|
||||
Commons Math is Java 5.
|
||||
|
||||
|
||||
Users are encouraged to upgrade to this version as this release not
|
||||
only includes bug fixes but also deprecates numerous classes and
|
||||
methods that will be deleted from the next major release (4.0).
|
||||
|
||||
|
||||
Caveat:
|
||||
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
||||
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 dev="luc" type="add" >
|
||||
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 dev="luc" type="add" >
|
||||
Added partial derivatives computation for 3D vectors and rotations.
|
||||
Added partial derivatives computation for 3D vectors and rotations.
|
||||
</action>
|
||||
<action dev="luc" type="fix" issue="MATH-935" >
|
||||
Fixed DerivativeStructure.atan2 for special cases when both arguments are +/-0.
|
||||
</action>
|
||||
<action dev="luc" type="add" >
|
||||
Added accurate linear combination of DerivativeStructure instances,
|
||||
avoiding cancellation.
|
||||
avoiding cancellation.
|
||||
</action>
|
||||
<action dev="erans" type="update" issue="MATH-933">
|
||||
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".
|
||||
</action>
|
||||
<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
|
||||
values in class "SimplexSolver".
|
||||
</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.
|
||||
Changes to existing features were made in a backwards-compatible
|
||||
way such as to allow drop-in replacement of the v3.0 JAR file.
|
||||
|
||||
|
||||
Most notable among the new features are: Framework for automatic
|
||||
differentiation, multivariate mixture model distribution, quaternions,
|
||||
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
|
||||
the implementation of the Gamma and Beta special functions, optimizers
|
||||
API, deprecation of the sparse vector implementation.
|
||||
|
||||
|
||||
The minimal version of the Java platform required to compile and use
|
||||
Commons Math is Java 5.
|
||||
Users are encouraged to upgrade to this version as this release not
|
||||
only includes bug fixes but also deprecates numerous classes and
|
||||
methods that will be deleted from the next major release (4.0).
|
||||
|
||||
|
||||
Caveat:
|
||||
1. The implementation of the BOBYQA optimization algorithm is in alpha
|
||||
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
|
||||
and to extend the unit tests suite.
|
||||
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">
|
||||
Added statistical hypothesis tests "MannWhitneyUTest" and
|
||||
|
|
|
@ -160,7 +160,7 @@
|
|||
<module name="EmptyStatement" />
|
||||
<module name="EqualsHashCode" />
|
||||
<!-- Method parameters and local variables should not hide fields, except in constructors and setters -->
|
||||
<!--
|
||||
<!--
|
||||
<module name="HiddenField">
|
||||
<property name="ignoreConstructorParameter" value="true" />
|
||||
<property name="ignoreSetter" value="true" />
|
||||
|
|
|
@ -50,9 +50,9 @@
|
|||
<item name="Javadoc (2.2 release)"
|
||||
href="http://commons.apache.org/math/javadocs/api-2.2/index.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"/>
|
||||
<item name="Wiki"
|
||||
<item name="Wiki"
|
||||
href="http://wiki.apache.org/commons/Math"/>
|
||||
<item name="Developers Guide" href="/developers.html"/>
|
||||
<item name="Proposal" href="/proposal.html"/>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<document>
|
||||
<properties>
|
||||
<title>Developers Guide</title>
|
||||
|
@ -43,7 +43,7 @@
|
|||
<p>
|
||||
<ol>
|
||||
<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.
|
||||
</li>
|
||||
<li>Download the Commons Math source code. Follow the instructions
|
||||
|
@ -57,8 +57,8 @@
|
|||
read-write access.
|
||||
</li>
|
||||
<li>Like most commons components, Commons Math uses Apache Maven as our
|
||||
build tool. The sources can also be built using Ant (a working
|
||||
Ant build.xml is included in the top level project directory).
|
||||
build tool. The sources can also be built using Ant (a working
|
||||
Ant build.xml is included in the top level project directory).
|
||||
To build Commons Math using Maven, you can follow the instructions for
|
||||
<a href="http://maven.apache.org/run-maven/index.html">Building a
|
||||
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">
|
||||
Math Wish List Wiki Page.</a>
|
||||
</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">
|
||||
email lists</a> and use them appropriately (make sure the string
|
||||
"[math]" starts the Subject line of all your postings).
|
||||
|
@ -81,15 +81,15 @@
|
|||
<li>
|
||||
<a href="https://issues.apache.org/jira/secure/Signup!default.jspa">
|
||||
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">
|
||||
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>
|
||||
See the <a href="http://commons.apache.org/math/issue-tracking.html">
|
||||
Commons Math Issue Tracking Page</a> for more information on how to
|
||||
search for or submit bugs or enhancement requests.
|
||||
</p>
|
||||
</p>
|
||||
<li>
|
||||
Generating patches: The requested format for generating patches is
|
||||
the Unified Diff format, which can be easily generated using the git
|
||||
|
@ -105,7 +105,7 @@
|
|||
<p>
|
||||
Follow the steps below when making suggestions for additions or
|
||||
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!
|
||||
<ol>
|
||||
<li>Start with a post to the commons-dev mailing list, with [math] at
|
||||
|
@ -122,7 +122,7 @@
|
|||
useful</li>
|
||||
</ul></li>
|
||||
<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
|
||||
List</a> corresponding to the idea. Include a reference to the
|
||||
discussion thread. </li>
|
||||
|
@ -139,7 +139,7 @@
|
|||
ticket if a patch goes more than a few days with no comment or commit.
|
||||
</li>
|
||||
</ol>
|
||||
</p>
|
||||
</p>
|
||||
</subsection>
|
||||
<subsection name='Coding Style'>
|
||||
<p>
|
||||
|
@ -191,7 +191,7 @@
|
|||
formulas and escape special characters.</li>
|
||||
<li>
|
||||
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>
|
||||
<li>
|
||||
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.
|
||||
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
|
||||
advertised preconditions</i> it is not appropriate to throw
|
||||
advertised preconditions</i> it is not appropriate to throw
|
||||
MathIllegalArgumentException.</li>
|
||||
<li>
|
||||
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>
|
||||
</ul>
|
||||
</subsection>
|
||||
|
@ -259,7 +259,7 @@
|
|||
All new source file submissions <i>must</i> include the Apache Software
|
||||
License in a comment that begins the file </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
|
||||
Agreement (CLA)</a></li>
|
||||
<li>
|
||||
|
@ -271,7 +271,7 @@
|
|||
<li>
|
||||
References to source materials covered by restrictive proprietary
|
||||
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>.
|
||||
Any questions about copyright or patent issues should be raised on
|
||||
the commons-dev mailing list before contributing or committing code.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<document>
|
||||
|
||||
<properties>
|
||||
|
@ -65,7 +65,7 @@
|
|||
<section name="Download Math">
|
||||
<subsection name="Releases">
|
||||
<p>
|
||||
Download the
|
||||
Download the
|
||||
<a href="http://commons.apache.org/math/download_math.cgi">
|
||||
Latest Release</a> of Commons Math.
|
||||
</p>
|
||||
|
|
|
@ -48,7 +48,7 @@ limitations under the License.
|
|||
|
||||
<section name="Overview">
|
||||
<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>.
|
||||
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,
|
||||
|
@ -68,8 +68,8 @@ limitations under the License.
|
|||
</p>
|
||||
<p>
|
||||
<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.
|
||||
Otherwise, please upload the file to a public server and include the URL in the mail.
|
||||
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.
|
||||
</p>
|
||||
</section>
|
||||
|
||||
|
@ -185,10 +185,10 @@ limitations under the License.
|
|||
General announcements of Apache project releases.
|
||||
<br /><br />
|
||||
</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-subscribe@apache.org">Subscribe</a></td>
|
||||
<td><a class="externalLink" href="mailto:announce-unsubscribe@apache.org">Unsubscribe</a></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 />
|
||||
<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 />
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<document>
|
||||
|
||||
<properties>
|
||||
|
@ -29,40 +29,40 @@
|
|||
<section name='Proposal for math Package'>
|
||||
|
||||
<subsection name='(0) Rationale'>
|
||||
<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
|
||||
basic statistics or solving a system of linear equations require components not available in java
|
||||
<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
|
||||
basic statistics or solving a system of linear equations require components not available in java
|
||||
or commons-lang.</p>
|
||||
|
||||
<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
|
||||
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
|
||||
<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
|
||||
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
|
||||
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>
|
||||
|
||||
</subsection>
|
||||
|
||||
<subsection name='(1) Scope of the Package'>
|
||||
|
||||
<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
|
||||
<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
|
||||
the Java programming language or commons-lang. The guiding principles for commons-math will be:
|
||||
|
||||
<ol>
|
||||
<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>
|
||||
<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>
|
||||
<li>Limited dependencies. No external dependencies beyond Commons components and the JDK</li>
|
||||
</ol>
|
||||
</p>
|
||||
</subsection>
|
||||
|
||||
|
||||
<subsection name='(1.5) Interaction With Other Packages'>
|
||||
|
||||
<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 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:
|
||||
<ul>
|
||||
<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
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="analysis.html">
|
||||
<properties>
|
||||
|
@ -215,7 +215,7 @@
|
|||
This may again result in roots way off the true value, without
|
||||
indication. There is not much a generic algorithm can do if
|
||||
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
|
||||
requires knowledge of the analytical properties of the function under
|
||||
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
|
||||
much larger in absolute value than 100, the default absolute
|
||||
accuracy may never be reached because the given relative
|
||||
accuracy is reached first.
|
||||
accuracy is reached first.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
@ -375,7 +375,7 @@ double c = UnivariateSolverUtils.forceSide(100, function,
|
|||
<p>
|
||||
A <a href="../apidocs/org/apache/commons/math4/analysis/interpolation/UnivariateInterpolator.html">
|
||||
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>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
|
||||
|
@ -387,7 +387,7 @@ double c = UnivariateSolverUtils.forceSide(100, function,
|
|||
interpolation algorithm is more determined by the kind of the interpolated function
|
||||
rather than the set of points to interpolate.
|
||||
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>Typical usage:</p>
|
||||
<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
|
||||
derivative is continuous but not smooth. The x values passed to the
|
||||
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>.
|
||||
</p>
|
||||
<p>
|
||||
|
@ -525,7 +525,7 @@ System.out.println("interpolation polynomial: " + interpolator.getPolynomials()[
|
|||
trapezoid method</a></li>
|
||||
<li><a href="../apidocs/org/apache/commons/math4/analysis/integration/LegendreGaussIntegrator.html">
|
||||
Legendre-Gauss method</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
</p>
|
||||
</subsection>
|
||||
<subsection name="4.6 Polynomials" href="polynomials">
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="stat.html">
|
||||
<properties>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="exceptions.html">
|
||||
<properties>
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="filter.html">
|
||||
<properties>
|
||||
|
@ -34,11 +34,11 @@
|
|||
<a href="../apidocs/org/apache/commons/math4/filter/KalmanFilter.html">
|
||||
KalmanFilter</a> provides a discrete-time filter to estimate
|
||||
a stochastic linear process.</p>
|
||||
|
||||
|
||||
<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">
|
||||
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
|
||||
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
|
||||
in the mathematical literature:
|
||||
<ul>
|
||||
<li>A - state transition matrix</li>
|
||||
|
@ -52,7 +52,7 @@
|
|||
<p>
|
||||
<dl>
|
||||
<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
|
||||
process and measurement noises, simply implement your own models.
|
||||
<source>
|
||||
|
@ -74,7 +74,7 @@ KalmanFilter filter = new KalmanFilter(pm, mm);
|
|||
</source>
|
||||
</dd>
|
||||
<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>
|
||||
for (;;) {
|
||||
// predict the state estimate one time-step ahead
|
||||
|
@ -86,15 +86,15 @@ for (;;) {
|
|||
|
||||
// correct the state estimate with the latest measurement
|
||||
filter.correct(z);
|
||||
|
||||
|
||||
double[] stateEstimate = filter.getStateEstimation();
|
||||
// do something with it
|
||||
}
|
||||
</source>
|
||||
</dd>
|
||||
<dt>Constant Voltage Example</dt>
|
||||
<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
|
||||
<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
|
||||
imposed measurement noise of 0.1V and assume an internal process noise of 1e-5V.
|
||||
<source>
|
||||
double constantVoltage = 10d;
|
||||
|
@ -118,7 +118,7 @@ RealMatrix R = new Array2DRowRealMatrix(new double[] { measurementNoise });
|
|||
|
||||
ProcessModel pm = new DefaultProcessModel(A, B, Q, x, P0);
|
||||
MeasurementModel mm = new DefaultMeasurementModel(H, R);
|
||||
KalmanFilter filter = new KalmanFilter(pm, mm);
|
||||
KalmanFilter filter = new KalmanFilter(pm, mm);
|
||||
|
||||
// process and measurement noise vectors
|
||||
RealVector pNoise = new ArrayRealVector(1);
|
||||
|
@ -148,7 +148,7 @@ for (int i = 0; i < 60; i++) {
|
|||
</source>
|
||||
</dd>
|
||||
<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
|
||||
state is modeled as (position, velocity) and we only observe the position. A 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];
|
||||
}
|
||||
</source>
|
||||
</dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</p>
|
||||
</p>
|
||||
</subsection>
|
||||
</section>
|
||||
</body>
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="fraction.html">
|
||||
<properties>
|
||||
|
|
|
@ -7,16 +7,16 @@
|
|||
The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
(the "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="genetics.html">
|
||||
<properties>
|
||||
|
@ -26,17 +26,17 @@
|
|||
<section name="16 Genetic Algorithms">
|
||||
<subsection name="16.1 Overview" href="overview">
|
||||
<p>
|
||||
The genetics package provides a framework and implementations for
|
||||
The genetics package provides a framework and implementations for
|
||||
genetic algorithms.
|
||||
</p>
|
||||
</subsection>
|
||||
<subsection name="16.2 GA Framework">
|
||||
<p>
|
||||
<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">
|
||||
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">
|
||||
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">
|
||||
|
@ -62,10 +62,10 @@
|
|||
<li>Loop until new generation is filled:</li>
|
||||
<ul><li>Apply configured <code>SelectionPolicy</code> to select a pair of parents
|
||||
from <code>current</code></li>
|
||||
<li>With probability =
|
||||
<li>With probability =
|
||||
<a href="../apidocs/org/apache/commons/math4/genetics/GeneticAlgorithm.html#getCrossoverRate()">
|
||||
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()">
|
||||
getMutationRate()</a>,
|
||||
apply configured <code>MutationPolicy</code> to each of the offspring</li>
|
||||
|
@ -73,7 +73,7 @@
|
|||
space permitting</li>
|
||||
</ul>
|
||||
<li>Return nextGeneration</li>
|
||||
</ol>
|
||||
</ol>
|
||||
</p>
|
||||
</subsection>
|
||||
<subsection name="16.3 Implementation">
|
||||
|
@ -88,16 +88,16 @@ GeneticAlgorithm ga = new GeneticAlgorithm(
|
|||
0.10,
|
||||
new TournamentSelection(TOURNAMENT_ARITY)
|
||||
);
|
||||
|
||||
|
||||
// initial population
|
||||
Population initial = getInitialPopulation();
|
||||
|
||||
|
||||
// stopping condition
|
||||
StoppingCondition stopCond = new FixedGenerationCount(NUM_GENERATIONS);
|
||||
|
||||
|
||||
// run the algorithm
|
||||
Population finalPopulation = ga.evolve(initial, stopCond);
|
||||
|
||||
|
||||
// best chromosome from the final population
|
||||
Chromosome bestFinal = finalPopulation.getFittestChromosome();
|
||||
</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
|
||||
n random chromosomes without replacement from the population, and then selecting the fittest chromosome among them.</td></tr>
|
||||
</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>
|
||||
is reached. In the example above, 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
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="geometry.html">
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="index.html">
|
||||
<properties>
|
||||
|
@ -58,24 +58,24 @@
|
|||
<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.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.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>
|
||||
<ul>
|
||||
<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.3_Root-finding">4.3 Root-finding</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.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.6_Polynomials">4.6 Polynomials</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>
|
||||
<ul>
|
||||
<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>
|
||||
<ul>
|
||||
<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.6_fast_math">6.6 Fast mathematical functions</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>
|
||||
<ul>
|
||||
<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>
|
||||
<ul>
|
||||
<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>
|
||||
</ul></li>
|
||||
</ul></li>
|
||||
<li><a href="fraction.html">9. Fractions</a>
|
||||
<ul>
|
||||
<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="geometry.html">11. Geometry</a>
|
||||
<ul>
|
||||
<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>
|
||||
<ul>
|
||||
<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.4_Direct_Methods">12.4 Direct Methods</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>
|
||||
<ul>
|
||||
<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.5_Derivatives">15.5 Derivatives</a></li>
|
||||
</ul></li>
|
||||
<li><a href="genetics.html">16. Genetic Algorithms</a>
|
||||
<li><a href="genetics.html">16. Genetic Algorithms</a>
|
||||
<ul>
|
||||
<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.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>
|
||||
<li><a href="filter.html">17. Filters</a>
|
||||
<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#implementation">18.3 Implementation</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</li>
|
||||
<li><a href="exceptions.html">19. Exceptions</a>
|
||||
<ul>
|
||||
<li><a href="exceptions.html#a19.1_Overview">19.1 Overview</a></li>
|
||||
|
@ -168,7 +168,7 @@
|
|||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
</document>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="linear.html">
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
|||
<subsection name="3.2 Real matrices" href="real_matrices">
|
||||
<p>
|
||||
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:
|
||||
<ul>
|
||||
<li>Matrix addition, subtraction, multiplication</li>
|
||||
|
@ -45,7 +45,7 @@
|
|||
<li>transpose</li>
|
||||
<li>Norm and Trace</li>
|
||||
<li>Operation on a vector</li>
|
||||
</ul>
|
||||
</ul>
|
||||
</p>
|
||||
<p>
|
||||
Example:
|
||||
|
@ -85,7 +85,7 @@ RealMatrix pInverse = new LUDecomposition(p).getSolver().getInverse();
|
|||
<subsection name="3.3 Real vectors" href="real_vectors">
|
||||
<p>
|
||||
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:
|
||||
<ul>
|
||||
<li>Vector addition, subtraction</li>
|
||||
|
@ -136,7 +136,7 @@ RealVector constants = new ArrayRealVector(new double[] { 1, -2, 1 }, false);
|
|||
RealVector solution = solver.solve(constants);
|
||||
</source>
|
||||
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.
|
||||
</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.
|
||||
</p>
|
||||
<p>
|
||||
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
|
||||
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
|
||||
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.
|
||||
</p>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="ml.html">
|
||||
|
||||
|
@ -39,10 +39,10 @@
|
|||
The following algorithms are available:
|
||||
<ul>
|
||||
<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
|
||||
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
|
||||
into k clusters in such that each point belongs to the cluster with the nearest center.
|
||||
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
|
||||
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.
|
||||
</li>
|
||||
<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
|
||||
|
@ -52,7 +52,7 @@
|
|||
slower than the original kMeans algorithm.
|
||||
</li>
|
||||
<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
|
||||
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.
|
||||
|
@ -114,18 +114,18 @@ public static class LocationWrapper implements Clusterable {
|
|||
}
|
||||
}
|
||||
</source>
|
||||
Now we will create a list of these wrapper objects (one for each location),
|
||||
which serves as input to our clustering algorithm.
|
||||
Now we will create a list of these wrapper objects (one for each location),
|
||||
which serves as input to our clustering algorithm.
|
||||
<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<LocationWrapper> clusterInput = new ArrayList<LocationWrapper>(locations.size());
|
||||
for (Location location : locations)
|
||||
clusterInput.add(new LocationWrapper(location));
|
||||
</source>
|
||||
Finally, we can apply our clustering algorithm and output the found clusters.
|
||||
<source>
|
||||
// initialize a new clustering algorithm.
|
||||
<source>
|
||||
// initialize a new clustering algorithm.
|
||||
// we use KMeans++ with 10 clusters and 10000 iterations maximum.
|
||||
// we did not specify a distance measure; the default (euclidean distance) is used.
|
||||
KMeansPlusPlusClusterer<LocationWrapper> clusterer = new KMeansPlusPlusClusterer<LocationWrapper>(10, 10000);
|
||||
|
@ -143,4 +143,4 @@ for (int i=0; i<clusterResults.size(); i++) {
|
|||
</subsection>
|
||||
</section>
|
||||
</body>
|
||||
</document>
|
||||
</document>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<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() {
|
||||
public void init(double t0, double[] y0, double t) {
|
||||
}
|
||||
|
||||
|
||||
public void handleStep(StepInterpolator interpolator, boolean isLast) {
|
||||
double t = interpolator.getCurrentTime();
|
||||
double[] y = interpolator.getInterpolatedState();
|
||||
|
|
|
@ -261,7 +261,7 @@
|
|||
|
||||
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>.
|
||||
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.
|
||||
|
||||
<table cellspacing="0" cellpadding="3">
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document>
|
||||
<properties>
|
||||
<title>User Guide - Overview</title>
|
||||
</properties>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<section name="Overview">
|
||||
|
@ -32,22 +32,22 @@
|
|||
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,
|
||||
providing a little more explanation of the mathematical objects and functions included
|
||||
in the package.
|
||||
in the package.
|
||||
</p>
|
||||
</subsection>
|
||||
|
||||
<subsection name="0.2 What's in commons-math" href="summary">
|
||||
<p>
|
||||
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,
|
||||
it's just meant to give a feel for the kinds of things that Commons Math provides.
|
||||
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,
|
||||
it's just meant to give a feel for the kinds of things that Commons Math provides.
|
||||
<ul>
|
||||
<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 curve to a set of data points</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>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 Ordinary Differential Equations</li>
|
||||
<li>Minimizing multi-dimensional functions</li>
|
||||
|
@ -57,13 +57,13 @@
|
|||
<li>Performing statistical significance tests</li>
|
||||
<li>Miscellaneous mathematical functions such as factorials, binomial
|
||||
coefficients and "special functions" (e.g. gamma, beta functions)</li>
|
||||
</ul></p>
|
||||
</ul></p>
|
||||
<p>
|
||||
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,
|
||||
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,
|
||||
self-contained math/stat components useful for solving common programming problems.
|
||||
Suggestions for new components or enhancements to existing functionality are always welcome!
|
||||
All feedback/suggestions for improvement should be sent to the
|
||||
Suggestions for new components or enhancements to existing functionality are always welcome!
|
||||
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
|
||||
[math] at the beginning of the subject line.
|
||||
</p>
|
||||
|
@ -96,15 +96,15 @@
|
|||
|
||||
<subsection name="0.4 How interface contracts are specified in commons-math javadoc" href="contracts">
|
||||
<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
|
||||
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
|
||||
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
|
||||
values/objects or state changes.</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
|
||||
<a href="../apidocs/org/apache/commons/math4/exception/MathIllegalArgumentException.html">
|
||||
MathIllegalArgumentException</a> or
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<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.
|
||||
// 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);
|
||||
|
||||
// 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 "License"); you may not use this file except in compliance with
|
||||
the License. You may obtain a copy of the License at
|
||||
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="fraction.html">
|
||||
<properties>
|
||||
|
|
|
@ -118,7 +118,7 @@
|
|||
</table>
|
||||
</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">
|
||||
AggregateSummaryStatistics.</a> This class can be used to concurrently
|
||||
gather statistics for multiple datasets as well as for a combined sample
|
||||
|
@ -135,11 +135,11 @@
|
|||
is thread-safe.
|
||||
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/SynchronizedDescriptiveStatistics.html">
|
||||
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
|
||||
versions for applications that require concurrent access to statistical
|
||||
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
|
||||
<code>MultivariateSummaryStatistics.</code>
|
||||
</p>
|
||||
|
@ -239,14 +239,14 @@ DescriptiveStatistics stats = new SynchronizedDescriptiveStatistics();
|
|||
</dd>
|
||||
<dt>Compute statistics for multiple samples and overall statistics concurrently</dt>
|
||||
<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
|
||||
to accumulate overall statistics contributed by <code>SummaryStatistics</code>
|
||||
instances created using
|
||||
<a href="../apidocs/org/apache/commons/math4/stat/descriptive/AggregateSummaryStatistics.html#createContributingStatistics()">
|
||||
AggregateSummaryStatistics.createContributingStatistics()</a>:
|
||||
<source>
|
||||
// Create a AggregateSummaryStatistics instance to accumulate the overall statistics
|
||||
// Create a AggregateSummaryStatistics instance to accumulate the overall statistics
|
||||
// and AggregatingSummaryStatistics for the subsamples
|
||||
AggregateSummaryStatistics aggregate = new AggregateSummaryStatistics();
|
||||
SummaryStatistics setOneStats = aggregate.createContributingStatistics();
|
||||
|
@ -501,7 +501,7 @@ System.out.println(regression.getSlopeStdErr());
|
|||
System.out.println(regression.getInterceptStdErr() );
|
||||
// will return Double.NaN, since we constrained the parameter to zero
|
||||
</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.
|
||||
</dd>
|
||||
|
||||
|
@ -520,12 +520,12 @@ System.out.println(regression.getInterceptStdErr() );
|
|||
</p>
|
||||
<p>
|
||||
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>.
|
||||
</p>
|
||||
<p>
|
||||
<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">
|
||||
GLSMultipleLinearRegression</a> implements Generalized Least Squares. See the javadoc for these
|
||||
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
|
||||
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)">
|
||||
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[][])">
|
||||
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[][])">
|
||||
GLSMultipleLinearRegression#newSampleData(double[],double[][],double[][])</a> for details.
|
||||
</p>
|
||||
|
@ -545,7 +545,7 @@ System.out.println(regression.getInterceptStdErr() );
|
|||
<strong>Usage Notes</strong>: <ul>
|
||||
<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
|
||||
or do not contain sufficient data to estimate the model.
|
||||
or do not contain sufficient data to estimate the model.
|
||||
</li>
|
||||
<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
|
||||
|
@ -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[3] = new double[]{0, 0, 4.0, 0, 0};
|
||||
x[4] = new double[]{0, 0, 0, 5.0, 0};
|
||||
x[5] = new double[]{0, 0, 0, 0, 6.0};
|
||||
x[5] = new double[]{0, 0, 0, 0, 6.0};
|
||||
regression.newSampleData(y, x);
|
||||
</source>
|
||||
</dd>
|
||||
<dd>Get regression parameters and diagnostics:
|
||||
<source>
|
||||
double[] beta = regression.estimateRegressionParameters();
|
||||
double[] beta = regression.estimateRegressionParameters();
|
||||
|
||||
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[3] = new double[]{0, 0, 4.0, 0, 0};
|
||||
x[4] = new double[]{0, 0, 0, 5.0, 0};
|
||||
x[5] = new double[]{0, 0, 0, 0, 6.0};
|
||||
x[5] = new double[]{0, 0, 0, 0, 6.0};
|
||||
double[][] omega = new double[6][];
|
||||
omega[0] = new double[]{1.1, 0, 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[4] = new double[]{0, 0, 0, 0, 5.5, 0};
|
||||
omega[5] = new double[]{0, 0, 0, 0, 0, 6.6};
|
||||
regression.newSampleData(y, x, omega);
|
||||
regression.newSampleData(y, x, omega);
|
||||
</source>
|
||||
</dd>
|
||||
</dl>
|
||||
</p>
|
||||
</subsection>
|
||||
</subsection>
|
||||
<subsection name="1.6 Rank transformations">
|
||||
<p>
|
||||
Some statistical algorithms require that input data be replaced by ranks.
|
||||
The <a href="../apidocs/org/apache/commons/math4/stat/ranking/package-summary.html">
|
||||
org.apache.commons.math4.stat.ranking</a> package provides rank transformation.
|
||||
<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">
|
||||
NaturalRanking</a> provides an implementation that has two configuration options.
|
||||
<ul>
|
||||
|
@ -640,7 +640,7 @@ double[] ranks = ranking.rank(exampleData);
|
|||
</source>
|
||||
results in <code>ranks</code> containing <code>{6, 5, 7, 8, 5, 9, 2, 2, 5}.</code>
|
||||
<source>
|
||||
new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData);
|
||||
new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData);
|
||||
</source>
|
||||
returns <code>{5, 2, 6, 7, 3, 8, 1, 4}.</code>
|
||||
</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>
|
||||
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
|
||||
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">
|
||||
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>
|
||||
for details on these configuration options.
|
||||
</p>
|
||||
</subsection>
|
||||
</subsection>
|
||||
<subsection name="1.7 Covariance and correlation">
|
||||
<p>
|
||||
The <a href="../apidocs/org/apache/commons/math4/stat/correlation/package-summary.html">
|
||||
org.apache.commons.math4.stat.correlation</a> package computes covariances
|
||||
and correlations for pairs of arrays or columns of a matrix.
|
||||
<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">
|
||||
PearsonsCorrelation</a> provides Pearson's Product-Moment correlation coefficients,
|
||||
<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/>
|
||||
<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>
|
||||
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
|
||||
bias-corrected is determined by the optional parameter, "biasCorrected," which
|
||||
defaults to <code>true.</code>
|
||||
defaults to <code>true.</code>
|
||||
</li>
|
||||
<li>
|
||||
<a href="../apidocs/org/apache/commons/math4/stat/correlation/PearsonsCorrelation.html">
|
||||
|
@ -691,7 +691,7 @@ new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData
|
|||
<li>
|
||||
<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
|
||||
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">
|
||||
NaturalRanking</a> with default strategies for handling ties and NaN values is used.
|
||||
</li>
|
||||
|
@ -699,7 +699,7 @@ new NaturalRanking(NaNStrategy.REMOVED,TiesStrategy.SEQUENTIAL).rank(exampleData
|
|||
<a href="../apidocs/org/apache/commons/math4/stat/correlation/KendallsCorrelation.html">
|
||||
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.
|
||||
</li>
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>
|
||||
|
@ -727,7 +727,7 @@ new Covariance().computeCovarianceMatrix(data)
|
|||
</source>
|
||||
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,
|
||||
use
|
||||
use
|
||||
<source>
|
||||
computeCovarianceMatrix(data, false)
|
||||
</source>
|
||||
|
@ -750,7 +750,7 @@ new PearsonsCorrelation().correlation(x, y)
|
|||
new PearsonsCorrelation().computeCorrelationMatrix(data)
|
||||
</source>
|
||||
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>
|
||||
<br/>
|
||||
<dt><strong>Pearson's correlation significance and standard errors</strong></dt>
|
||||
|
@ -768,7 +768,7 @@ correlation.getCorrelationStandardErrors();
|
|||
</source>
|
||||
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/>
|
||||
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/>
|
||||
<strong>p-values</strong> for the (2-sided) null hypotheses that elements of
|
||||
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/>
|
||||
<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
|
||||
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/>
|
||||
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>
|
||||
new PearsonsCorrelation(data).getCorrelationPValues().getEntry(0,1)
|
||||
</source>
|
||||
|
@ -798,13 +798,13 @@ new PearsonsCorrelation(data).getCorrelationPValues().getEntry(0,1)
|
|||
<source>
|
||||
new SpearmansCorrelation().correlation(x, y)
|
||||
</source>
|
||||
This is equivalent to
|
||||
This is equivalent to
|
||||
<source>
|
||||
RankingAlgorithm ranking = new NaturalRanking();
|
||||
new PearsonsCorrelation().correlation(ranking.rank(x), ranking.rank(y))
|
||||
</source>
|
||||
</dd>
|
||||
<br/>
|
||||
<br/>
|
||||
<dt><strong>Kendalls's tau rank correlation coefficient</strong></dt>
|
||||
<br/>
|
||||
<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">
|
||||
Student's t</a>,
|
||||
<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://www.itl.nist.gov/div898/handbook/prc/section4/prc43.htm">
|
||||
One-Way ANOVA</a>,
|
||||
|
@ -853,7 +853,7 @@ new KendallsCorrelation().correlation(x, y)
|
|||
<a href="../apidocs/org/apache/commons/math4/stat/inference/BinomialTest.html">
|
||||
BinomialTest</a> and
|
||||
<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">
|
||||
TestUtils</a> class provides static methods to get test instances or
|
||||
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:
|
||||
<code>gTest(expected, observed)</code>, which is the tail probability beyond
|
||||
<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
|
||||
probability computed using a ChiSquare distribution with one less degeree
|
||||
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
|
||||
one-sample tests against a <code>RealDistribution</code> and two-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
|
||||
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
|
||||
<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
|
||||
|
@ -1163,7 +1163,7 @@ System.out.println(TestUtils.gTestDataSetsComparison(obs1, obs2)); // p-value
|
|||
<source>
|
||||
new GTest().rootLogLikelihoodRatio(5, 1995, 0, 100000);
|
||||
</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.
|
||||
</dd>
|
||||
<br/>
|
||||
|
@ -1219,7 +1219,7 @@ TestUtils.kolmogorovSmirnovStatistic(unitNormal, sample)
|
|||
<source>
|
||||
TestUtils.kolmogorovSmirnovStatistic(x, y)
|
||||
</source>
|
||||
to compute the D-statistic and
|
||||
to compute the D-statistic and
|
||||
<source>
|
||||
TestUtils.kolmogorovSmirnovTest(x, y)
|
||||
</source>
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="transform.html">
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
|
||||
<?xml-stylesheet type="text/xsl" href="./xdoc.xsl"?>
|
||||
<document url="utilities.html">
|
||||
|
||||
|
@ -39,14 +39,14 @@
|
|||
|
||||
<subsection name="6.2 Double array utilities" href="arrays">
|
||||
<p>
|
||||
To maintain statistics based on a "rolling" window of values, a resizable
|
||||
array implementation was developed and is provided for reuse in the
|
||||
To maintain statistics based on a "rolling" window of values, a resizable
|
||||
array implementation was developed and is provided for reuse in the
|
||||
<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">
|
||||
DoubleArray</a>. This interface adds one method,
|
||||
<code>addElementRolling(double)</code> to basic list accessors.
|
||||
The <code>addElementRolling</code> method adds an element
|
||||
<code>addElementRolling(double)</code> to basic list accessors.
|
||||
The <code>addElementRolling</code> method adds an element
|
||||
(the actual parameter) to the end of the list and removes the first element
|
||||
in the list.
|
||||
</p>
|
||||
|
@ -64,10 +64,10 @@
|
|||
the end needs to be created. Both of these operations are handled
|
||||
automatically, with frequency / effect driven by the configuration
|
||||
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">
|
||||
ResizableDoubleArray</a>
|
||||
for details.
|
||||
for details.
|
||||
</p>
|
||||
</subsection>
|
||||
|
||||
|
@ -103,7 +103,7 @@
|
|||
default: return 6.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public double getB(int n, double x) {
|
||||
double y = (2.0 * n) - 1.0;
|
||||
return y * y;
|
||||
|
@ -129,7 +129,7 @@
|
|||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public double getB(int n, double x) {
|
||||
if (n % 2 == 0) {
|
||||
return -x;
|
||||
|
@ -151,17 +151,17 @@
|
|||
<a href="../apidocs/org/apache/commons/math4/util/ArithmeticUtils.html">ArithmeticUtils</a>
|
||||
utility class. ArithmeticUtils currently includes methods to compute the following: <ul>
|
||||
<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>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>
|
||||
<li>
|
||||
Stirling numbers of the second kind -- S(n,k) as an exact long value
|
||||
<code>stirlingS2(int, int)</code> for small n, k.</li>
|
||||
<li>
|
||||
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>
|
||||
<li>
|
||||
Least common multiple and greatest common denominator functions.
|
||||
|
@ -186,7 +186,7 @@
|
|||
<p>
|
||||
FastMath speed is achieved by relying heavily on optimizing compilers to
|
||||
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
|
||||
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
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ClusterAlgorithmComparison {
|
|||
if (factor < 0 || factor > 1) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
|
||||
ContinuousDistribution.Sampler dist = new NormalDistribution(0.0, noise).createSampler(rng);
|
||||
|
||||
List<Vector2D> points = new ArrayList<>();
|
||||
|
@ -77,11 +77,11 @@ public class ClusterAlgorithmComparison {
|
|||
for (double angle = 0; angle < range; angle += step) {
|
||||
Vector2D outerCircle = Vector2D.of(FastMath.cos(angle), FastMath.sin(angle));
|
||||
Vector2D innerCircle = outerCircle.multiply(factor);
|
||||
|
||||
|
||||
points.add(outerCircle.add(generateNoiseVector(dist)));
|
||||
points.add(innerCircle.add(generateNoiseVector(dist)));
|
||||
}
|
||||
|
||||
|
||||
if (shuffle) {
|
||||
ListSampler.shuffle(rng, points);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class ClusterAlgorithmComparison {
|
|||
|
||||
int nSamplesOut = samples / 2;
|
||||
int nSamplesIn = samples - nSamplesOut;
|
||||
|
||||
|
||||
List<Vector2D> points = new ArrayList<>();
|
||||
double range = FastMath.PI;
|
||||
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);
|
||||
points.add(innerCircle.add(generateNoiseVector(dist)));
|
||||
}
|
||||
|
||||
|
||||
if (shuffle) {
|
||||
ListSampler.shuffle(rng, points);
|
||||
}
|
||||
|
@ -133,29 +133,29 @@ public class ClusterAlgorithmComparison {
|
|||
for (int i = 0; i < centers; i++) {
|
||||
centerPoints[i] = Vector2D.of(uniform.sample(), uniform.sample());
|
||||
}
|
||||
|
||||
|
||||
int[] nSamplesPerCenter = new int[centers];
|
||||
int count = samples / centers;
|
||||
Arrays.fill(nSamplesPerCenter, count);
|
||||
|
||||
|
||||
for (int i = 0; i < samples % centers; i++) {
|
||||
nSamplesPerCenter[i]++;
|
||||
}
|
||||
|
||||
|
||||
List<Vector2D> points = new ArrayList<>();
|
||||
for (int i = 0; i < centers; i++) {
|
||||
for (int j = 0; j < nSamplesPerCenter[i]; j++) {
|
||||
points.add(centerPoints[i].add(generateNoiseVector(gauss)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (shuffle) {
|
||||
ListSampler.shuffle(rng, points);
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
|
||||
public static List<Vector2D> makeRandom(int samples) {
|
||||
SobolSequenceGenerator generator = new SobolSequenceGenerator(2);
|
||||
generator.skipTo(999999);
|
||||
|
@ -167,14 +167,14 @@ public class ClusterAlgorithmComparison {
|
|||
Vector2D point = Vector2D.of(vector);
|
||||
points.add(point);
|
||||
}
|
||||
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
public static Vector2D generateNoiseVector(ContinuousDistribution.Sampler distribution) {
|
||||
return Vector2D.of(distribution.sample(), distribution.sample());
|
||||
}
|
||||
|
||||
|
||||
public static List<DoublePoint> normalize(final List<Vector2D> input,
|
||||
double minX,
|
||||
double maxX,
|
||||
|
@ -191,16 +191,16 @@ public class ClusterAlgorithmComparison {
|
|||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class Display extends ExampleFrame {
|
||||
|
||||
|
||||
public Display() {
|
||||
setTitle("Commons-Math: Cluster algorithm comparison");
|
||||
setSize(800, 800);
|
||||
|
||||
|
||||
setLayout(new GridBagLayout());
|
||||
|
||||
|
||||
int nSamples = 1500;
|
||||
|
||||
final long seed = RandomSource.createLong(); // Random seed.
|
||||
|
@ -213,7 +213,7 @@ public class ClusterAlgorithmComparison {
|
|||
datasets.add(normalize(makeRandom(nSamples), -1, 1, -1, 1));
|
||||
|
||||
List<Pair<String, Clusterer<DoublePoint>>> algorithms = new ArrayList<>();
|
||||
|
||||
|
||||
algorithms.add(new Pair<String, Clusterer<DoublePoint>>("KMeans\n(k=2)",
|
||||
new KMeansPlusPlusClusterer<>(2)));
|
||||
algorithms.add(new Pair<String, Clusterer<DoublePoint>>("KMeans\n(k=3)",
|
||||
|
@ -224,7 +224,7 @@ public class ClusterAlgorithmComparison {
|
|||
new FuzzyKMeansClusterer<>(3, 10)));
|
||||
algorithms.add(new Pair<String, Clusterer<DoublePoint>>("DBSCAN\n(eps=.1, min=3)",
|
||||
new DBSCANClusterer<>(0.1, 3)));
|
||||
|
||||
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.VERTICAL;
|
||||
c.gridx = 0;
|
||||
|
@ -248,7 +248,7 @@ public class ClusterAlgorithmComparison {
|
|||
c.gridx++;
|
||||
}
|
||||
c.gridy++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ public class ClusterAlgorithmComparison {
|
|||
this.clusters = clusters;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
@ -276,10 +276,10 @@ public class ClusterAlgorithmComparison {
|
|||
int h = getHeight();
|
||||
|
||||
g2.clearRect(0, 0, w, h);
|
||||
|
||||
|
||||
g2.setPaint(Color.black);
|
||||
g2.drawRect(0, 0, w - 1, h - 1);
|
||||
|
||||
|
||||
int index = 0;
|
||||
Color[] colors = new Color[] { Color.red, Color.blue, Color.green.darker() };
|
||||
for (Cluster<DoublePoint> cluster : clusters) {
|
||||
|
@ -289,7 +289,7 @@ public class ClusterAlgorithmComparison {
|
|||
double[] arr = p.getPoint();
|
||||
g2.fill(new Ellipse2D.Double(arr[0] - 1, arr[1] - 1, 3, 3));
|
||||
}
|
||||
|
||||
|
||||
Clusterable p = transform(cluster.centroid(), w, h);
|
||||
double[] arr = p.getPoint();
|
||||
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.draw(s);
|
||||
}
|
||||
|
||||
|
||||
g2.setPaint(Color.black);
|
||||
g2.drawString(String.format("%.2f s", duration / 1e3), w - 40, h - 5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(150, 150);
|
||||
|
|
|
@ -39,12 +39,12 @@ public class ExampleUtils {
|
|||
|
||||
@SuppressWarnings("serial")
|
||||
public static class ExampleFrame extends JFrame {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the main panel which should be printed by the screenshot action.
|
||||
* <p>
|
||||
* 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
|
||||
*/
|
||||
|
@ -73,14 +73,14 @@ public class ExampleUtils {
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
JMenuItem exit = new JMenuItem("Exit");
|
||||
exit.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
System.exit(0);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
JMenu menu = new JMenu("File");
|
||||
menu.add(screenshot);
|
||||
menu.add(exit);
|
||||
|
@ -102,7 +102,7 @@ public class ExampleUtils {
|
|||
component.paint(image.getGraphics());
|
||||
return image;
|
||||
}
|
||||
|
||||
|
||||
public static BufferedImage resizeImage(BufferedImage originalImage, int width, int height, int type) throws IOException {
|
||||
BufferedImage resizedImage = new BufferedImage(width, height, type);
|
||||
Graphics2D g = resizedImage.createGraphics();
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.apache.commons.math4.util.FastMath;
|
|||
|
||||
/**
|
||||
* Performance benchmark for FastMath.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class FastMathTestPerformance {
|
||||
private static final int RUNS = Integer.parseInt(System.getProperty("testRuns","10000000"));
|
||||
|
@ -288,7 +288,7 @@ public class FastMathTestPerformance {
|
|||
report("cos",strictTime,fastTime,mathTime);
|
||||
assertTrue(!Double.isNaN(x));
|
||||
}
|
||||
|
||||
|
||||
private static void testAcos() {
|
||||
double x = 0;
|
||||
long time = System.nanoTime();
|
||||
|
@ -594,7 +594,7 @@ public class FastMathTestPerformance {
|
|||
report("tanh",strictTime,fastTime,mathTime);
|
||||
assertTrue(!Double.isNaN(x));
|
||||
}
|
||||
|
||||
|
||||
private static void testExpm1() {
|
||||
double x = 0;
|
||||
long time = System.nanoTime();
|
||||
|
|
|
@ -60,7 +60,7 @@ public class LowDiscrepancyGeneratorComparison {
|
|||
|
||||
// normalize points first
|
||||
points = normalize(points);
|
||||
|
||||
|
||||
// now test if the sample is within the unit circle
|
||||
List<Vector2D> circlePoints = new ArrayList<>();
|
||||
for (Vector2D p : points) {
|
||||
|
@ -80,7 +80,7 @@ public class LowDiscrepancyGeneratorComparison {
|
|||
Vector2D point = Vector2D.of(vector);
|
||||
points.add(point);
|
||||
}
|
||||
|
||||
|
||||
return normalize(points);
|
||||
}
|
||||
|
||||
|
@ -92,16 +92,16 @@ public class LowDiscrepancyGeneratorComparison {
|
|||
minX = FastMath.min(minX, p.getX());
|
||||
maxX = FastMath.max(maxX, p.getX());
|
||||
}
|
||||
|
||||
|
||||
double minY, maxY;
|
||||
|
||||
|
||||
// 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) {
|
||||
minX = minY = 0.0;
|
||||
maxX = maxY = 1.0;
|
||||
} else {
|
||||
minX = minY = -FastMath.sqrt(3);
|
||||
maxX = maxY = FastMath.sqrt(3);
|
||||
maxX = maxY = FastMath.sqrt(3);
|
||||
}
|
||||
|
||||
double rangeX = maxX - minX;
|
||||
|
@ -116,16 +116,16 @@ public class LowDiscrepancyGeneratorComparison {
|
|||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class Display extends ExampleFrame {
|
||||
|
||||
|
||||
public Display() {
|
||||
setTitle("Commons-Math: Pseudo/Quasi-random examples");
|
||||
setSize(800, 800);
|
||||
|
||||
|
||||
setLayout(new GridBagLayout());
|
||||
|
||||
|
||||
int[] datasets = new int[] { 256, 1000, 2500, 1000 };
|
||||
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, 987654321)
|
||||
};
|
||||
|
||||
|
||||
public double[] nextVector() {
|
||||
final double[] vector = new double[2];
|
||||
vector[0] = rngs[0].nextDouble();
|
||||
vector[1] = rngs[1].nextDouble();
|
||||
return vector;
|
||||
}
|
||||
|
||||
}));
|
||||
generators.add(new Pair<>("HaltonSequence", new HaltonSequenceGenerator(2)));
|
||||
generators.add(new Pair<>("SobolSequence", new SobolSequenceGenerator(2)));
|
||||
|
||||
|
||||
}));
|
||||
generators.add(new Pair<>("HaltonSequence", new HaltonSequenceGenerator(2)));
|
||||
generators.add(new Pair<>("SobolSequence", new SobolSequenceGenerator(2)));
|
||||
|
||||
GridBagConstraints c = new GridBagConstraints();
|
||||
c.fill = GridBagConstraints.VERTICAL;
|
||||
c.gridx = 1;
|
||||
|
@ -163,7 +163,7 @@ public class LowDiscrepancyGeneratorComparison {
|
|||
c.gridx++;
|
||||
}
|
||||
int saveY = ++c.gridy;
|
||||
|
||||
|
||||
c.gridx = 0;
|
||||
for (int type = 0; type < 4; type++) {
|
||||
JLabel text = new JLabel("n=" + String.valueOf(datasets[type]));
|
||||
|
@ -198,7 +198,7 @@ public class LowDiscrepancyGeneratorComparison {
|
|||
}
|
||||
|
||||
c.gridy++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ public class LowDiscrepancyGeneratorComparison {
|
|||
public Plot(final List<Vector2D> points) {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g) {
|
||||
super.paintComponent(g);
|
||||
|
@ -224,17 +224,17 @@ public class LowDiscrepancyGeneratorComparison {
|
|||
int h = getHeight();
|
||||
|
||||
g2.clearRect(0, 0, w, h);
|
||||
|
||||
|
||||
g2.setPaint(Color.black);
|
||||
g2.drawRect(0, 0, w - 1, h - 1);
|
||||
|
||||
|
||||
for (Vector2D point : points) {
|
||||
Vector2D p = transform(point, w, h);
|
||||
double[] arr = p.toArray();
|
||||
g2.draw(new Rectangle2D.Double(arr[0] - 1, arr[1] - 1, 2, 2));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(140, 140);
|
||||
|
|
|
@ -53,35 +53,35 @@ import com.xeiam.xchart.StyleManager.LegendPosition;
|
|||
public class CannonballExample {
|
||||
|
||||
public static class Cannonball {
|
||||
|
||||
|
||||
private final double[] gravity = { 0, -9.81 };
|
||||
private final double[] velocity;
|
||||
private final double[] location;
|
||||
|
||||
|
||||
private final double timeslice;
|
||||
private final double measurementNoise;
|
||||
|
||||
|
||||
private final GaussianRandomGenerator rng;
|
||||
|
||||
|
||||
public Cannonball(double timeslice, double angle, double initialVelocity, double measurementNoise, int seed) {
|
||||
this.timeslice = timeslice;
|
||||
|
||||
|
||||
final double angleInRadians = FastMath.toRadians(angle);
|
||||
this.velocity = new double[] {
|
||||
initialVelocity * FastMath.cos(angleInRadians),
|
||||
initialVelocity * FastMath.sin(angleInRadians)
|
||||
};
|
||||
|
||||
|
||||
this.location = new double[] { 0, 0 };
|
||||
|
||||
|
||||
this.measurementNoise = measurementNoise;
|
||||
this.rng = new GaussianRandomGenerator(RandomSource.create(RandomSource.WELL_19937_C, seed));
|
||||
}
|
||||
|
||||
|
||||
public double getX() {
|
||||
return location[0];
|
||||
}
|
||||
|
||||
|
||||
public double getY() {
|
||||
return location[1];
|
||||
}
|
||||
|
@ -97,18 +97,18 @@ public class CannonballExample {
|
|||
public double getXVelocity() {
|
||||
return velocity[0];
|
||||
}
|
||||
|
||||
|
||||
public double getYVelocity() {
|
||||
return velocity[1];
|
||||
}
|
||||
|
||||
|
||||
public void step() {
|
||||
// Break gravitational force into a smaller time slice.
|
||||
double[] slicedGravity = gravity.clone();
|
||||
for ( int i = 0; i < slicedGravity.length; i++ ) {
|
||||
slicedGravity[i] *= timeslice;
|
||||
}
|
||||
|
||||
|
||||
// Apply the acceleration to velocity.
|
||||
double[] slicedVelocity = velocity.clone();
|
||||
for ( int i = 0; i < velocity.length; i++ ) {
|
||||
|
@ -123,9 +123,9 @@ public class CannonballExample {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void cannonballTest(Chart chart) {
|
||||
|
||||
|
||||
// time interval for each iteration
|
||||
final double dt = 0.1;
|
||||
// the number of iterations to run
|
||||
|
@ -139,7 +139,7 @@ public class CannonballExample {
|
|||
|
||||
// the cannonball itself
|
||||
final Cannonball cannonball = new Cannonball(dt, angle, initialVelocity, measurementNoise, 1000);
|
||||
|
||||
|
||||
// A = [ 1, dt, 0, 0 ] => x(n+1) = x(n) + vx(n)
|
||||
// [ 0, 1, 0, 0 ] => vx(n+1) = vx(n)
|
||||
// [ 0, 0, 1, dt ] => y(n+1) = y(n) + vy(n)
|
||||
|
@ -148,7 +148,7 @@ public class CannonballExample {
|
|||
{ 1, dt, 0, 0 },
|
||||
{ 0, 1, 0, 0 },
|
||||
{ 0, 0, 1, dt },
|
||||
{ 0, 0, 0, 1 }
|
||||
{ 0, 0, 0, 1 }
|
||||
});
|
||||
|
||||
// The control vector, which adds acceleration to the kinematic equations.
|
||||
|
@ -183,7 +183,7 @@ public class CannonballExample {
|
|||
{ 0, 0, 1, 0 },
|
||||
{ 0, 0, 0, 0 }
|
||||
});
|
||||
|
||||
|
||||
// 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.
|
||||
final double speedX = cannonball.getXVelocity();
|
||||
|
@ -201,7 +201,7 @@ public class CannonballExample {
|
|||
|
||||
// we assume no process noise -> zero matrix
|
||||
final RealMatrix Q = MatrixUtils.createRealMatrix(4, 4);
|
||||
|
||||
|
||||
// the measurement covariance matrix
|
||||
final RealMatrix R = MatrixUtils.createRealMatrix(new double[][] {
|
||||
{ var, 0, 0, 0 },
|
||||
|
@ -220,7 +220,7 @@ public class CannonballExample {
|
|||
final List<Number> measuredY = new ArrayList<>();
|
||||
final List<Number> kalmanX = new ArrayList<>();
|
||||
final List<Number> kalmanY = new ArrayList<>();
|
||||
|
||||
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
|
||||
// get real location
|
||||
|
@ -251,7 +251,7 @@ public class CannonballExample {
|
|||
|
||||
Series dataset = chart.addSeries("true", realX, realY);
|
||||
dataset.setMarker(SeriesMarker.NONE);
|
||||
|
||||
|
||||
dataset = chart.addSeries("measured", measuredX, measuredY);
|
||||
dataset.setLineStyle(SeriesLineStyle.DOT_DOT);
|
||||
dataset.setMarker(SeriesMarker.NONE);
|
||||
|
@ -275,10 +275,10 @@ public class CannonballExample {
|
|||
chart.getStyleManager().setLegendPadding(6);
|
||||
chart.getStyleManager().setLegendSeriesLineLength(10);
|
||||
chart.getStyleManager().setAxisTickLabelsFont(new Font("Arial", Font.PLAIN, 10));
|
||||
|
||||
|
||||
chart.getStyleManager().setChartBackgroundColor(Color.white);
|
||||
chart.getStyleManager().setChartPadding(4);
|
||||
|
||||
|
||||
chart.getStyleManager().setChartType(ChartType.Line);
|
||||
return chart;
|
||||
}
|
||||
|
@ -290,20 +290,20 @@ public class CannonballExample {
|
|||
Chart chart = createChart("Cannonball", LegendPosition.InsideNE);
|
||||
cannonballTest(chart);
|
||||
container.add(new XChartPanel(chart));
|
||||
|
||||
|
||||
container.setBorder(BorderFactory.createLineBorder(Color.black, 1));
|
||||
return container;
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class Display extends ExampleFrame {
|
||||
|
||||
|
||||
private JComponent container;
|
||||
|
||||
public Display() {
|
||||
setTitle("Commons Math: Kalman Filter - Cannonball");
|
||||
setSize(800, 600);
|
||||
|
||||
|
||||
container = new JPanel();
|
||||
JComponent comp = createComponent();
|
||||
container.add(comp);
|
||||
|
|
|
@ -53,7 +53,7 @@ import com.xeiam.xchart.StyleManager.LegendPosition;
|
|||
public class ConstantVoltageExample {
|
||||
|
||||
public static class VoltMeter {
|
||||
|
||||
|
||||
private final double initialVoltage;
|
||||
private final double processNoise;
|
||||
private final double measurementNoise;
|
||||
|
@ -68,20 +68,20 @@ public class ConstantVoltageExample {
|
|||
this.measurementNoise = measurementNoise;
|
||||
rng = new GaussianRandomGenerator(RandomSource.create(RandomSource.WELL_19937_C, seed));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the real voltage without any measurement noise.
|
||||
*
|
||||
*
|
||||
* @return the real voltage
|
||||
*/
|
||||
public double getVoltage() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
|
||||
public double getMeasuredVoltage() {
|
||||
return getVoltage() + rng.nextNormalizedDouble() * measurementNoise;
|
||||
return getVoltage() + rng.nextNormalizedDouble() * measurementNoise;
|
||||
}
|
||||
|
||||
|
||||
public void step() {
|
||||
// we apply only the process noise
|
||||
voltage = initialVoltage + rng.nextNormalizedDouble() * processNoise;
|
||||
|
@ -96,7 +96,7 @@ public class ConstantVoltageExample {
|
|||
final double processNoise = 1e-5d;
|
||||
|
||||
final VoltMeter voltMeter = new VoltMeter(voltage, processNoise, measurementNoise, 2);
|
||||
|
||||
|
||||
// the state transition matrix -> constant
|
||||
final RealMatrix A = new Array2DRowRealMatrix(new double[] { 1d });
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class ConstantVoltageExample {
|
|||
|
||||
// the initial state vector -> slightly wrong
|
||||
final RealVector x0 = new ArrayRealVector(new double[] { 1.45 });
|
||||
|
||||
|
||||
// the process covariance matrix
|
||||
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> covSeries = new ArrayList<>();
|
||||
|
||||
|
||||
for (int i = 0; i < 300; i++) {
|
||||
xAxis.add(i);
|
||||
|
||||
|
@ -152,7 +152,7 @@ public class ConstantVoltageExample {
|
|||
|
||||
Series dataset = chart1.addSeries("real", xAxis, realVoltageSeries);
|
||||
dataset.setMarker(SeriesMarker.NONE);
|
||||
|
||||
|
||||
dataset = chart1.addSeries("measured", xAxis, measuredVoltageSeries);
|
||||
dataset.setLineStyle(SeriesLineStyle.DOT_DOT);
|
||||
dataset.setMarker(SeriesMarker.NONE);
|
||||
|
@ -166,7 +166,7 @@ public class ConstantVoltageExample {
|
|||
|
||||
chart2.setYAxisTitle("(Voltage)²");
|
||||
chart2.setXAxisTitle("Iteration");
|
||||
|
||||
|
||||
dataset = chart2.addSeries("cov", xAxis, covSeries);
|
||||
dataset.setLineColor(Color.black);
|
||||
dataset.setLineStyle(SeriesLineStyle.SOLID);
|
||||
|
@ -187,10 +187,10 @@ public class ConstantVoltageExample {
|
|||
chart.getStyleManager().setLegendPadding(6);
|
||||
chart.getStyleManager().setLegendSeriesLineLength(10);
|
||||
chart.getStyleManager().setAxisTickLabelsFont(new Font("Arial", Font.PLAIN, 10));
|
||||
|
||||
|
||||
chart.getStyleManager().setChartBackgroundColor(Color.white);
|
||||
chart.getStyleManager().setChartPadding(4);
|
||||
|
||||
|
||||
chart.getStyleManager().setChartType(ChartType.Line);
|
||||
return chart;
|
||||
}
|
||||
|
@ -198,28 +198,28 @@ public class ConstantVoltageExample {
|
|||
public static JComponent createComponent() {
|
||||
JComponent container = new JPanel();
|
||||
container.setLayout(new BoxLayout(container, BoxLayout.LINE_AXIS));
|
||||
|
||||
|
||||
Chart chart1 = createChart("Voltage", 550, 450, LegendPosition.InsideNE, true);
|
||||
Chart chart2 = createChart("Error Covariance", 450, 450, LegendPosition.InsideNE, false);
|
||||
|
||||
|
||||
constantVoltageTest(chart1, chart2);
|
||||
|
||||
container.add(new XChartPanel(chart1));
|
||||
container.add(new XChartPanel(chart2));
|
||||
|
||||
|
||||
container.setBorder(BorderFactory.createLineBorder(Color.black, 1));
|
||||
return container;
|
||||
}
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public static class Display extends ExampleFrame {
|
||||
|
||||
|
||||
private JComponent container;
|
||||
|
||||
public Display() {
|
||||
setTitle("Commons-Math: Kalman Filter example");
|
||||
setSize(1100, 700);
|
||||
|
||||
|
||||
container = new JPanel();
|
||||
|
||||
JComponent comp = createComponent();
|
||||
|
|
|
@ -60,13 +60,13 @@ public class HelloWorldExample {
|
|||
|
||||
// stopping condition
|
||||
StoppingCondition stoppingCondition = new StoppingCondition() {
|
||||
|
||||
|
||||
int generation = 0;
|
||||
|
||||
|
||||
// @Override
|
||||
public boolean isSatisfied(Population population) {
|
||||
Chromosome fittestChromosome = population.getFittestChromosome();
|
||||
|
||||
|
||||
if (generation == 1 || generation % 10 == 0) {
|
||||
System.out.println("Generation " + generation + ": " + fittestChromosome.toString());
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ public class HelloWorldExample {
|
|||
};
|
||||
|
||||
System.out.println("Starting evolution ...");
|
||||
|
||||
|
||||
// run the algorithm
|
||||
Population finalPopulation = ga.evolve(initial, stoppingCondition);
|
||||
|
||||
|
@ -94,15 +94,15 @@ public class HelloWorldExample {
|
|||
System.out.println("Generation " + ga.getGenerationsEvolved() + ": " + best.toString());
|
||||
System.out.println("Total execution time: " + (endTime - startTime) + "ms");
|
||||
}
|
||||
|
||||
|
||||
private static List<Character> randomRepresentation(int length) {
|
||||
return asList(RandomStringUtils.randomAscii(length));
|
||||
}
|
||||
|
||||
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() {
|
||||
List<Chromosome> popList = new LinkedList<>();
|
||||
|
||||
|
@ -173,7 +173,7 @@ public class HelloWorldExample {
|
|||
|
||||
StringChromosome strChromosome = (StringChromosome) original;
|
||||
List<Character> characters = strChromosome.getStringRepresentation();
|
||||
|
||||
|
||||
int mutationIndex = GeneticAlgorithm.getRandomGenerator().nextInt(characters.size());
|
||||
|
||||
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.
|
||||
* <p>
|
||||
* The fitness function is quite simple yet expensive to compute:
|
||||
*
|
||||
*
|
||||
* - draw the polygons of a chromosome to an image
|
||||
* - compare each pixel with the corresponding reference image
|
||||
* <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)
|
||||
* - allow loading / selection of other images
|
||||
* - 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>
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
|
@ -77,7 +77,7 @@ public class ImageEvolutionExample {
|
|||
public static final int POLYGON_COUNT = 100;
|
||||
|
||||
public static class Display extends ExampleFrame {
|
||||
|
||||
|
||||
private GeneticAlgorithm ga;
|
||||
private Population currentPopulation;
|
||||
private Chromosome bestFit;
|
||||
|
@ -86,16 +86,16 @@ public class ImageEvolutionExample {
|
|||
private volatile boolean noStopRequested;
|
||||
|
||||
private BufferedImage ref;
|
||||
|
||||
|
||||
private BufferedImage referenceImage;
|
||||
private BufferedImage testImage;
|
||||
|
||||
|
||||
private ImagePainter painter;
|
||||
|
||||
public Display() throws Exception {
|
||||
setTitle("Commons-Math: Image Evolution Example");
|
||||
setSize(600, 400);
|
||||
|
||||
|
||||
setLayout(new FlowLayout());
|
||||
|
||||
Box bar = Box.createHorizontalBox();
|
||||
|
@ -143,7 +143,7 @@ public class ImageEvolutionExample {
|
|||
currentPopulation = getInitialPopulation();
|
||||
bestFit = currentPopulation.getFittestChromosome();
|
||||
}
|
||||
|
||||
|
||||
public boolean isAlive() {
|
||||
return internalThread != null && internalThread.isAlive();
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class ImageEvolutionExample {
|
|||
}
|
||||
|
||||
private class ImagePainter extends Component {
|
||||
|
||||
|
||||
private int width;
|
||||
private int height;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class Polygon {
|
|||
final int polygonSize = 4 + 2 * length;
|
||||
|
||||
final UniformRandomProvider random = GeneticAlgorithm.getRandomGenerator();
|
||||
|
||||
|
||||
Polygon p = new Polygon();
|
||||
p.data = new float[polygonSize];
|
||||
|
||||
|
@ -61,10 +61,10 @@ public class Polygon {
|
|||
p.data[1] = random.nextFloat(); // g
|
||||
p.data[2] = random.nextFloat(); // b
|
||||
p.data[3] = FastMath.max(0.2f, random.nextFloat() * random.nextFloat()); // a
|
||||
|
||||
|
||||
float px = random.nextFloat();
|
||||
float py = random.nextFloat();
|
||||
|
||||
|
||||
for (int k = 0; k < length; k++) {
|
||||
p.data[4 + 2*k] = px + (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.
|
||||
* In case a component is going to be mutated, its value will be randomly modified in the
|
||||
* uniform range of [-mutationAmount, +mutationAmount].
|
||||
*
|
||||
*
|
||||
* @param mutationRate the mutation rate
|
||||
* @param mutationAmount the mutation amount
|
||||
* @return a new Polygon
|
||||
|
@ -91,7 +91,7 @@ public class Polygon {
|
|||
float val = this.data[i];
|
||||
if (GeneticAlgorithm.getRandomGenerator().nextFloat() < mutationRate) {
|
||||
val += GeneticAlgorithm.getRandomGenerator().nextFloat() * mutationAmount * 2 - mutationAmount;
|
||||
|
||||
|
||||
if (val < 0f) {
|
||||
val = 0f;
|
||||
} else if (val > 1f) {
|
||||
|
@ -101,7 +101,7 @@ public class Polygon {
|
|||
mutated.data[i] = val;
|
||||
}
|
||||
return mutated;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the Polygon to the buffer of the given size.
|
||||
|
@ -111,7 +111,7 @@ public class Polygon {
|
|||
|
||||
GeneralPath path = new GeneralPath();
|
||||
path.moveTo(data[4] * width, data[5] * height);
|
||||
|
||||
|
||||
int polygonLength = (data.length - 4) / 2;
|
||||
for (int j = 1; j < polygonLength; j++) {
|
||||
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() {
|
||||
|
||||
Graphics2D g2 = testImage.createGraphics();
|
||||
|
||||
|
||||
int width = testImage.getWidth();
|
||||
int height = testImage.getHeight();
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class PolygonChromosome extends AbstractListChromosome<Polygon> {
|
|||
public String toString() {
|
||||
return String.format("(f=%s)", getFitness());
|
||||
}
|
||||
|
||||
|
||||
public static Chromosome randomChromosome(int polygonLength, int polygonCount) {
|
||||
List<Polygon> list = new ArrayList<>(polygonCount);
|
||||
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;
|
||||
|
||||
public class RandomPolygonMutation implements MutationPolicy {
|
||||
|
||||
|
||||
private float mutationRate;
|
||||
private float mutationAmount;
|
||||
|
||||
|
||||
public RandomPolygonMutation(float mutationRate, float mutationAmount) {
|
||||
this.mutationRate = mutationRate;
|
||||
this.mutationAmount = mutationAmount;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-math4-examples</artifactId>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<version>4.0-SNAPSHOT</version>
|
||||
<name>Commons Math User Guide</name>
|
||||
<inceptionYear>2003</inceptionYear>
|
||||
<description>Examples</description>
|
||||
|
@ -41,7 +41,7 @@
|
|||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>java</sourceDirectory>
|
||||
|
@ -105,7 +105,7 @@
|
|||
<groupId>org.piccolo2d</groupId>
|
||||
<artifactId>piccolo2d-extras</artifactId>
|
||||
<version>3.0</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
|
|
Loading…
Reference in New Issue