Apache Commons Math Library (org.apache.commons.*)

Apache Commons Math Library

Common Math is a library of lightweight, self-contained mathematics and statistics components addressing the most common problems not available in the Java programming language or Commons Lang. [1] Its supportive library for statics and mathematical calculation. According to ref [1] it can deal with real-world application, best part is independent from the complex configuration and dependencies. Current version [as on May 31, 2014] is depending on Java Version 1.5+. We can also use this library as Image processing or signal processing because it support basic of mathematics. following functionality provided by this library its divided in sixteen sub package.

Apcahe logo

functionality provided.

  • org.apache.commons.math3.stat –                   statistics, statistical tests
  • org.apache.commons.math3.analysis –           root finding, 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


import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;

public static void main(String[] args) {
int inputArray[]={1,2,3,4,5};
DescriptiveStatistics stats = new DescriptiveStatistics();
for( int i = 0; i < inputArray.length; i++)
double mean = stats.getMean();
double std = stats.getStandardDeviation();
double median = stats.getPercentile(50);
System.out.print(“Std=” + std + ” mean=” + mean + ” median=”+median );

———-out put——————————-

Std=1.5811388300841898 mean=3.0 median=3.0



  1. http://commons.apache.org/proper/commons-math/index.html


Share Post