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.

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.

- Computing means, variances and other summary statistics for a list of numbers
- Fitting a line to a set of data points using linear regression
- Fitting a curve to a set of data points
- Finding a smooth curve that passes through a collection of points (interpolation)
- Fitting a parametric model to a set of measurements using least-squares methods
- Solving equations involving real-valued functions (i.e. root-finding)
- Solving systems of linear equations
- Solving Ordinary Differential Equations
- Minimizing multi-dimensional functions
- Generating random numbers with more restrictions (e.g distribution, range) than what is possible using the JDK
- Generating random samples and/or datasets that are "like" the data in an input file
- Performing statistical significance tests
- Miscellaneous mathematical functions such as factorials, binomial coefficients and "special functions" (e.g. gamma, beta functions)

We are actively seeking ideas for additional components that fit into the Commons Math vision 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 commons-dev mailing list with [math] at the beginning of the subject line.

Commons Math is divided into sixteen subpackages, based on functionality provided.

- org.apache.commons.math3.stat - statistics, statistical tests
- org.apache.commons.math3.analysis - rootfinding, integration, interpolation, polynomials
- org.apache.commons.math3.random - random numbers, strings and data generation
- org.apache.commons.math3.special - special functions (Gamma, Beta)
- org.apache.commons.math3.linear - matrices, solving linear systems
- org.apache.commons.math3.util - common math/stat functions extending java.lang.Math
- org.apache.commons.math3.complex - complex numbers
- org.apache.commons.math3.distribution - probability distributions
- org.apache.commons.math3.fraction - rational numbers
- org.apache.commons.math3.transform - transform methods (Fast Fourier)
- org.apache.commons.math3.geometry - geometry (Euclidean spaces and Binary Space Partitioning)
- org.apache.commons.math3.optim - function maximization or minimization
- org.apache.commons.math3.ode - Ordinary Differential Equations integration
- org.apache.commons.math3.genetics - Genetic Algorithms
- org.apache.commons.math3.fitting - Curve Fitting
- org.apache.commons.math3.ml - Machine Learning

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) or exceptions that may be thrown if the preconditions are not met, and definitions for returned values/objects or state changes.

When the actual parameters provided to a method or the internal state of an object
make a computation meaningless, a
IllegalArgumentException or
MathIllegalStateException may be thrown. Exact conditions under which runtime
exceptions (and any other exceptions) are thrown are specified in the javadoc method
comments.
In some cases, to be consistent with the
IEEE 754 standard for floating point arithmetic and with java.lang.Math, Commons Math
methods return `Double.NaN` values. Conditions under which `Double.NaN`
or other special values are returned are fully specified in the javadoc method comments.

As of version 2.2, the policy for dealing with null references is as
follows: When an argument is unexpectedly null, a
NullArgumentException is raised for signalling the illegal argument. Note that this
class does not inherit from the standard `NullPointerException` but is a subclass
of `MathIllegalArgumentException`.
No `NullPointerException` should be propagated from within Commons Math.

Commons Math is distributed under the terms of the Apache License, Version 2.0: .

This product includes software developed by the University of Chicago, as Operator of Argonne National Laboratory. This corresponds to software translated from the lmder, lmpar and qrsolv Fortran routines from the Minpack package and distributed under the following disclaimer: .

This product includes software translated from the odex Fortran routine developed by E. Hairer and G. Wanner and distributed under the following license: .

This product includes software translated from some LAPACK Fortran routines and distributed under the following license: .