SlideShare une entreprise Scribd logo
1  sur  17
Apache Commons Math
                A Java library of mathematical tools


              Thomas Neidhart                     Gilles Sadowski
                tn@apache.org                         erans@apache.org


                                 FOSDEM 2013


                           February 02, 2013




FOSDEM 2013                     Apache Commons Math                      February 02, 2013   1 / 17
Overview of the talk




   What is it?
   What does it provide?
   Some simple examples
   Who is using it?
   What to do after the presentation?




      FOSDEM 2013               Apache Commons Math   February 02, 2013   2 / 17
What is it?



   100% pure, self-contained Java library
   mathematical methods & algorithms
   covers a wide range of topics
   aims for clean, documented and object-oriented code
   well tested and maintained
   following the Apache way
   Apache 2.0 license




      FOSDEM 2013                  Apache Commons Math   February 02, 2013   3 / 17
Commons Math in Numbers


As of January 1, 2013
    57 packages
    829 classes
    77,761 lines of code
    50,512 lines of comments
    99.4% documented API
    4,537 unit tests
    87.6% of code covered
    98 open issues
    831 resolved issues
    0 dependencies




       FOSDEM 2013             Apache Commons Math   February 02, 2013   4 / 17
What topics does it cover?
   Automatic Differentiation
   Numerical Integration
   Interpolation
   Root finders
   Arbitrary precision arithmetic
   Probability distributions
   Linear Algebra
   Fitting (non-linear least-squares, curve fitting)
   Ordinary differential equations (ODE)
   Linear/Non-linear optimization
   Random number generators
   Computational Geometry
   Special functions (Beta, Gamma)
   Kalman filter
   Fast Fourier transform
   Genetic algorithms
   Statistics (correlation, regression, descriptive, inference)
      FOSDEM 2013                    Apache Commons Math          February 02, 2013   5 / 17
FastMath




   pure Java replacement for java.lang.Math
   better performance for most of the functions
   better accuracy than Math and StrictMath
   currently not always faster :-(




      FOSDEM 2013                    Apache Commons Math   February 02, 2013   6 / 17
FastMath benchmark I
Number of calls: 109
Java 1.7.0_03 (1.7.0_03-b21) OpenJDK 64-Bit Server VM (22.0-b10)


     Function        Class     Time/call (ms)   Ratio (%)          Function      Class     Time/call (ms)    Ratio (%)
     log          StrictMath   5.22349648e-05          100         atan       StrictMath   2.38076340e-05           100
                        Math   2.04540923e-05           39                          Math   2.38346576e-05           100
                   FastMath    2.42863614e-05           47                     FastMath    2.78287849e-05           117
     log10        StrictMath   7.06720929e-05          100         atan2      StrictMath   6.14545612e-05           100
                        Math   2.05568765e-05           29                          Math   6.25871086e-05           102
                   FastMath    7.56041686e-05          107                     FastMath    6.24287698e-05           102
     log1p        StrictMath   3.72191413e-05          100         hypot      StrictMath   2.51933255e-04           100
                        Math   3.78759816e-05          101                          Math   2.51892886e-04           100
                   FastMath    7.50277567e-05          201                     FastMath    1.78561127e-05            71
     pow          StrictMath   1.73481768e-04          100         cbrt       StrictMath   7.08035203e-05           100
                        Math   1.64277768e-04           94                          Math   7.09881088e-05           100
                   FastMath    1.05758357e-04           60                     FastMath    4.12985279e-05            58
     exp          StrictMath   3.47634732e-05          100         sqrt       StrictMath   6.69162232e-06           100
                        Math   2.28322028e-05           65                          Math   6.63196797e-06            99
                   FastMath    1.72182428e-05           50                     FastMath    6.62463595e-06            99
     sin          StrictMath   2.86189157e-05          100         cosh       StrictMath   7.51256426e-05           100
                        Math   2.72834491e-05           95                          Math   7.52944441e-05           100
                   FastMath    2.13875014e-05           75                     FastMath    3.91062794e-05            52
     asin         StrictMath   3.61743365e-05          100         sinh       StrictMath   7.52920027e-05           100
                        Math   3.63858979e-05          100                          Math   7.58819054e-05           100
                   FastMath    6.65170752e-05          184                     FastMath    5.80563672e-05            77
     cos          StrictMath   3.23569717e-05          100         tanh       StrictMath   6.94914940e-05           100
                        Math   3.09660350e-05           96                          Math   7.01421819e-05           100
                   FastMath    2.37797205e-05           73                     FastMath    6.10102135e-05            88
     acos         StrictMath   3.74091467e-05          100         expm1      StrictMath   4.19029705e-05           100
                        Math   3.72805271e-05           99                          Math   4.18109329e-05           100
                   FastMath    8.99709198e-05          240                     FastMath    3.19643446e-05            76
     tan          StrictMath   4.36050840e-05          100         abs        StrictMath   5.08597800e-06           100
                        Math   3.94326807e-05           90                          Math   5.14014393e-06           101
                   FastMath    3.96236785e-05           91                     FastMath    5.37928625e-06           105

            FOSDEM 2013                            Apache Commons Math                              February 02, 2013     7 / 17
Example - Gauss Integration



 1    import   o.a.c.m.analysis.UnivariateFunction;
 2    import   o.a.c.m.analysis.function.Cos;
 3    import   o.a.c.m.analysis.integration.gauss.GaussIntegratorFactory;
 4    import   o.a.c.m.analysis.integration.gauss.GaussIntegrator;
 5
 6    // ...
 7
 8    GaussIntegratorFactory factory = new GaussIntegratorFactory();
 9    UnivariateFunction cos = new Cos();
10    // create an Gauss integrator for the interval [0, PI/2]
11    GaussIntegrator integrator = factory.legendre(7, 0, 0.5 * Math.PI);
12    double s = integrator.integrate(cos);




           FOSDEM 2013                  Apache Commons Math                 February 02, 2013   8 / 17
Example - Root finder


1     import o.a.c.m.analysis.UnivariateFunction;
2     import o.a.c.m.analysis.solvers.BrentSolver;
3     import o.a.c.m.analysis.solvers.UnivariateSolver;
4
5     // ...
6
7     UnivariateFunction f = new UnivariateFunction() {
8         public double value(double x) {
9             return FastMath.sin(x);
10        }
11    }
12    UnivariateSolver solver = new BrentSolver();
13    // we know that the root is somewhere between 3 and 4 ;-)
14    double result = solver.solve(100, f, 3, 4);




           FOSDEM 2013                Apache Commons Math         February 02, 2013   9 / 17
Example - Eigenvalue Decomposition


 1    import o.a.c.m.linear.RealMatrix;
 2    import o.a.c.m.linear.MatrixUtils;
 3    import o.a.c.m.linear.EigenDecomposition;
 4
 5    // ...
 6
 7    RealMatrix matrix =
 8        MatrixUtils.createRealMatrix(new double[][] {
 9             { 5,    10,   15 },
10             { 10,   20,   30 },
11             { 15,   30,   45 }
12    });
13
14    EigenDecomposition ed = new EigenDecomposition(matrix);
15    double[] eigValues = ed.getRealEigenvalues();




           FOSDEM 2013                Apache Commons Math       February 02, 2013   10 / 17
Example - Linear optimization: Simplex method

     Maximize 2x2 + 6x1 + 7x0
     with constraints
       x2 + 2x1 + x0 <= 2
       −x2 + x1 + x0 <= −1
       2x2 − 3x1 + x0 <= −1

 1     import o.a.c.m.optim.linear.LinearObjectiveFunction;
 2     import o.a.c.m.optim.linear.LinearConstraint;
 3     import o.a.c.m.optim.linear.SimplexSolver;
 4
 5     /// ...
 6
 7     LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 2, 6, 7 }, 0);
 8
 9     ArrayList<LinearConstraint> constraints = new ArrayList<LinearConstraint>();
10     constraints.add(new LinearConstraint(new double[] { 1, 2, 1 }, Relationship.LEQ, 2));
11     constraints.add(new LinearConstraint(new double[] { -1, 1, 1 }, Relationship.LEQ, -1));
12     constraints.add(new LinearConstraint(new double[] { 2, -3, 1 }, Relationship.LEQ, -1));
13
14     SimplexSolver solver = new SimplexSolver();
15     PointValuePair solution = solver.optimize(new MaxIter(100), f, new LinearConstraintSet(constraints),
16                                               GoalType.MAXIMIZE, new NonNegativeConstraint(false));




                 FOSDEM 2013                              Apache Commons Math                                 February 02, 2013   11 / 17
Who is using Commons Math?
Responses from our community:

         Field                                             Topic                                                     Link
  Space                Orekit - open-source space dynamics library                                    http://www.orekit.org
  Astronomy            Gaia Project: data processing of astrometric, photometric, and spectroscopic   http://www.rssd.esa.int/index.
                       data from 1 billion stars                                                      php?project=GAIA&page=DPAC_
                                                                                                      Introduction
  Material Science     Simulate the mechanical behaviour of composite materials                       http://navier.enpc.fr/
                                                                                                      BRISARD- Sebastien
  Biotech              Nuclear Magnetic Resonance (NMR) data analysis package for molecular           http://www.onemoonscientific.com
                       structure refinement
  Medical Technology   Image processing of 3D human MRI and CT scans                                  http://www.stjude.org
  Finance              Risk managment and analysis                                                    http://www.osloclearing.no/




A maven dependency search:
      Apache Hama - parallel computing framework
      Myrrix - A real-time recommender system
      Apache Mahout - scalable machine learning
      Redberry - Symbolic Tensor Algebra System
      Facebook jcommon-stats - well you know it
      ...
            FOSDEM 2013                                   Apache Commons Math                                    February 02, 2013   12 / 17
How to use it yourself?



Maven:
 <dependency>
 <groupId>org.apache.commons</groupId>
 <artifactId>commons-math3</artifactId>
 <version>3.1.1</version>
 </dependency>
Download:
http://commons.apache.org/math/download_math.cgi




         FOSDEM 2013         Apache Commons Math   February 02, 2013   13 / 17
Links




   Project homepage: http://commons.apache.org/math/
   Issue tracker: https://issues.apache.org/jira/browse/MATH
   Mailinglists: dev@commons.apache.org & user@commons.apache.org
   e-mail subject: [math]
   Wiki: http://wiki.apache.org/commons/MathWishList




        FOSDEM 2013           Apache Commons Math          February 02, 2013   14 / 17
How to contribute?



   Check out the user guide
   http://commons.apache.org/math/userguide/index.html
   Ask questions on the user mailinglist
   Participate in discussions on the dev mailinglist
   Create bug reports / feature requests / improvements in JIRA
   Send patches (code, documentation, examples)
   Provide feedback - most welcome!




      FOSDEM 2013                 Apache Commons Math             February 02, 2013   15 / 17
Hot Topics



   refactoring Linear Algebra package
   refactoring Optimization package
   Exception handling - checked vs. unchecked
   Add more computational geometry algorithms
   Upgrade to more recent Java versions (fork/join framework)
   (real) FastMath vs. AccurateMath (integration of jodk)
   improve user guide / examples
   lots of new feature requests . . .




      FOSDEM 2013                  Apache Commons Math          February 02, 2013   16 / 17
The End!




   Questions?




      FOSDEM 2013   Apache Commons Math   February 02, 2013   17 / 17

Contenu connexe

Similaire à Apache Commons Math @ FOSDEM 2013

Implementing the Split-Apply-Combine model in Clojure and Incanter
Implementing the Split-Apply-Combine model in Clojure and Incanter Implementing the Split-Apply-Combine model in Clojure and Incanter
Implementing the Split-Apply-Combine model in Clojure and Incanter Tom Faulhaber
 
Everyday Math And Algorithms Ppt July 06
Everyday Math And Algorithms Ppt July 06Everyday Math And Algorithms Ppt July 06
Everyday Math And Algorithms Ppt July 06lcirulli
 
Gradient Steepest method application on Griewank Function
Gradient Steepest method application  on Griewank Function Gradient Steepest method application  on Griewank Function
Gradient Steepest method application on Griewank Function Imane Haf
 
Chapter 1 -About Matlab
Chapter 1 -About MatlabChapter 1 -About Matlab
Chapter 1 -About MatlabSiva Gopal
 
Problem Based Learning Presentation NACA
Problem Based Learning Presentation NACAProblem Based Learning Presentation NACA
Problem Based Learning Presentation NACAWahid Dino Samo
 
Solution manual for Contemporary Business Mathematics with Canadian Applicati...
Solution manual for Contemporary Business Mathematics with Canadian Applicati...Solution manual for Contemporary Business Mathematics with Canadian Applicati...
Solution manual for Contemporary Business Mathematics with Canadian Applicati...ssuserf63bd7
 
EKON22 Introduction to Machinelearning
EKON22 Introduction to MachinelearningEKON22 Introduction to Machinelearning
EKON22 Introduction to MachinelearningMax Kleiner
 
Optimization based Chassis Design
Optimization based Chassis DesignOptimization based Chassis Design
Optimization based Chassis DesignAltair
 
Applied Machine Learning for Chemistry II (HSI2020)
Applied Machine Learning for Chemistry II (HSI2020)Applied Machine Learning for Chemistry II (HSI2020)
Applied Machine Learning for Chemistry II (HSI2020)Ichigaku Takigawa
 
Chapter 3 -Built-in Matlab Functions
Chapter 3 -Built-in Matlab FunctionsChapter 3 -Built-in Matlab Functions
Chapter 3 -Built-in Matlab FunctionsSiva Gopal
 
Heuristic design of experiments w meta gradient search
Heuristic design of experiments w meta gradient searchHeuristic design of experiments w meta gradient search
Heuristic design of experiments w meta gradient searchGreg Makowski
 
House Sale Price Prediction
House Sale Price PredictionHouse Sale Price Prediction
House Sale Price Predictionsriram30691
 
Sequential estimation of_discrete_choice_models__copy_-4
Sequential estimation of_discrete_choice_models__copy_-4Sequential estimation of_discrete_choice_models__copy_-4
Sequential estimation of_discrete_choice_models__copy_-4YoussefKitane
 

Similaire à Apache Commons Math @ FOSDEM 2013 (20)

Implementing the Split-Apply-Combine model in Clojure and Incanter
Implementing the Split-Apply-Combine model in Clojure and Incanter Implementing the Split-Apply-Combine model in Clojure and Incanter
Implementing the Split-Apply-Combine model in Clojure and Incanter
 
Everyday Math And Algorithms Ppt July 06
Everyday Math And Algorithms Ppt July 06Everyday Math And Algorithms Ppt July 06
Everyday Math And Algorithms Ppt July 06
 
Tree building 2
Tree building 2Tree building 2
Tree building 2
 
Gradient Steepest method application on Griewank Function
Gradient Steepest method application  on Griewank Function Gradient Steepest method application  on Griewank Function
Gradient Steepest method application on Griewank Function
 
Chapter 1 -About Matlab
Chapter 1 -About MatlabChapter 1 -About Matlab
Chapter 1 -About Matlab
 
Problem Based Learning Presentation NACA
Problem Based Learning Presentation NACAProblem Based Learning Presentation NACA
Problem Based Learning Presentation NACA
 
Converted ansys f
Converted ansys fConverted ansys f
Converted ansys f
 
Solution manual for Contemporary Business Mathematics with Canadian Applicati...
Solution manual for Contemporary Business Mathematics with Canadian Applicati...Solution manual for Contemporary Business Mathematics with Canadian Applicati...
Solution manual for Contemporary Business Mathematics with Canadian Applicati...
 
EKON22 Introduction to Machinelearning
EKON22 Introduction to MachinelearningEKON22 Introduction to Machinelearning
EKON22 Introduction to Machinelearning
 
Optimization based Chassis Design
Optimization based Chassis DesignOptimization based Chassis Design
Optimization based Chassis Design
 
Iterative methods
Iterative methodsIterative methods
Iterative methods
 
Iterative methods
Iterative methodsIterative methods
Iterative methods
 
Applied Machine Learning for Chemistry II (HSI2020)
Applied Machine Learning for Chemistry II (HSI2020)Applied Machine Learning for Chemistry II (HSI2020)
Applied Machine Learning for Chemistry II (HSI2020)
 
Chapter 3 -Built-in Matlab Functions
Chapter 3 -Built-in Matlab FunctionsChapter 3 -Built-in Matlab Functions
Chapter 3 -Built-in Matlab Functions
 
Heuristic design of experiments w meta gradient search
Heuristic design of experiments w meta gradient searchHeuristic design of experiments w meta gradient search
Heuristic design of experiments w meta gradient search
 
Data Analysis Assignment Help
Data Analysis Assignment HelpData Analysis Assignment Help
Data Analysis Assignment Help
 
House Sale Price Prediction
House Sale Price PredictionHouse Sale Price Prediction
House Sale Price Prediction
 
Sequential estimation of_discrete_choice_models__copy_-4
Sequential estimation of_discrete_choice_models__copy_-4Sequential estimation of_discrete_choice_models__copy_-4
Sequential estimation of_discrete_choice_models__copy_-4
 
Performance
PerformancePerformance
Performance
 
Yuwu chen
Yuwu chenYuwu chen
Yuwu chen
 

Dernier

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Dernier (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Apache Commons Math @ FOSDEM 2013

  • 1. Apache Commons Math A Java library of mathematical tools Thomas Neidhart Gilles Sadowski tn@apache.org erans@apache.org FOSDEM 2013 February 02, 2013 FOSDEM 2013 Apache Commons Math February 02, 2013 1 / 17
  • 2. Overview of the talk What is it? What does it provide? Some simple examples Who is using it? What to do after the presentation? FOSDEM 2013 Apache Commons Math February 02, 2013 2 / 17
  • 3. What is it? 100% pure, self-contained Java library mathematical methods & algorithms covers a wide range of topics aims for clean, documented and object-oriented code well tested and maintained following the Apache way Apache 2.0 license FOSDEM 2013 Apache Commons Math February 02, 2013 3 / 17
  • 4. Commons Math in Numbers As of January 1, 2013 57 packages 829 classes 77,761 lines of code 50,512 lines of comments 99.4% documented API 4,537 unit tests 87.6% of code covered 98 open issues 831 resolved issues 0 dependencies FOSDEM 2013 Apache Commons Math February 02, 2013 4 / 17
  • 5. What topics does it cover? Automatic Differentiation Numerical Integration Interpolation Root finders Arbitrary precision arithmetic Probability distributions Linear Algebra Fitting (non-linear least-squares, curve fitting) Ordinary differential equations (ODE) Linear/Non-linear optimization Random number generators Computational Geometry Special functions (Beta, Gamma) Kalman filter Fast Fourier transform Genetic algorithms Statistics (correlation, regression, descriptive, inference) FOSDEM 2013 Apache Commons Math February 02, 2013 5 / 17
  • 6. FastMath pure Java replacement for java.lang.Math better performance for most of the functions better accuracy than Math and StrictMath currently not always faster :-( FOSDEM 2013 Apache Commons Math February 02, 2013 6 / 17
  • 7. FastMath benchmark I Number of calls: 109 Java 1.7.0_03 (1.7.0_03-b21) OpenJDK 64-Bit Server VM (22.0-b10) Function Class Time/call (ms) Ratio (%) Function Class Time/call (ms) Ratio (%) log StrictMath 5.22349648e-05 100 atan StrictMath 2.38076340e-05 100 Math 2.04540923e-05 39 Math 2.38346576e-05 100 FastMath 2.42863614e-05 47 FastMath 2.78287849e-05 117 log10 StrictMath 7.06720929e-05 100 atan2 StrictMath 6.14545612e-05 100 Math 2.05568765e-05 29 Math 6.25871086e-05 102 FastMath 7.56041686e-05 107 FastMath 6.24287698e-05 102 log1p StrictMath 3.72191413e-05 100 hypot StrictMath 2.51933255e-04 100 Math 3.78759816e-05 101 Math 2.51892886e-04 100 FastMath 7.50277567e-05 201 FastMath 1.78561127e-05 71 pow StrictMath 1.73481768e-04 100 cbrt StrictMath 7.08035203e-05 100 Math 1.64277768e-04 94 Math 7.09881088e-05 100 FastMath 1.05758357e-04 60 FastMath 4.12985279e-05 58 exp StrictMath 3.47634732e-05 100 sqrt StrictMath 6.69162232e-06 100 Math 2.28322028e-05 65 Math 6.63196797e-06 99 FastMath 1.72182428e-05 50 FastMath 6.62463595e-06 99 sin StrictMath 2.86189157e-05 100 cosh StrictMath 7.51256426e-05 100 Math 2.72834491e-05 95 Math 7.52944441e-05 100 FastMath 2.13875014e-05 75 FastMath 3.91062794e-05 52 asin StrictMath 3.61743365e-05 100 sinh StrictMath 7.52920027e-05 100 Math 3.63858979e-05 100 Math 7.58819054e-05 100 FastMath 6.65170752e-05 184 FastMath 5.80563672e-05 77 cos StrictMath 3.23569717e-05 100 tanh StrictMath 6.94914940e-05 100 Math 3.09660350e-05 96 Math 7.01421819e-05 100 FastMath 2.37797205e-05 73 FastMath 6.10102135e-05 88 acos StrictMath 3.74091467e-05 100 expm1 StrictMath 4.19029705e-05 100 Math 3.72805271e-05 99 Math 4.18109329e-05 100 FastMath 8.99709198e-05 240 FastMath 3.19643446e-05 76 tan StrictMath 4.36050840e-05 100 abs StrictMath 5.08597800e-06 100 Math 3.94326807e-05 90 Math 5.14014393e-06 101 FastMath 3.96236785e-05 91 FastMath 5.37928625e-06 105 FOSDEM 2013 Apache Commons Math February 02, 2013 7 / 17
  • 8. Example - Gauss Integration 1 import o.a.c.m.analysis.UnivariateFunction; 2 import o.a.c.m.analysis.function.Cos; 3 import o.a.c.m.analysis.integration.gauss.GaussIntegratorFactory; 4 import o.a.c.m.analysis.integration.gauss.GaussIntegrator; 5 6 // ... 7 8 GaussIntegratorFactory factory = new GaussIntegratorFactory(); 9 UnivariateFunction cos = new Cos(); 10 // create an Gauss integrator for the interval [0, PI/2] 11 GaussIntegrator integrator = factory.legendre(7, 0, 0.5 * Math.PI); 12 double s = integrator.integrate(cos); FOSDEM 2013 Apache Commons Math February 02, 2013 8 / 17
  • 9. Example - Root finder 1 import o.a.c.m.analysis.UnivariateFunction; 2 import o.a.c.m.analysis.solvers.BrentSolver; 3 import o.a.c.m.analysis.solvers.UnivariateSolver; 4 5 // ... 6 7 UnivariateFunction f = new UnivariateFunction() { 8 public double value(double x) { 9 return FastMath.sin(x); 10 } 11 } 12 UnivariateSolver solver = new BrentSolver(); 13 // we know that the root is somewhere between 3 and 4 ;-) 14 double result = solver.solve(100, f, 3, 4); FOSDEM 2013 Apache Commons Math February 02, 2013 9 / 17
  • 10. Example - Eigenvalue Decomposition 1 import o.a.c.m.linear.RealMatrix; 2 import o.a.c.m.linear.MatrixUtils; 3 import o.a.c.m.linear.EigenDecomposition; 4 5 // ... 6 7 RealMatrix matrix = 8 MatrixUtils.createRealMatrix(new double[][] { 9 { 5, 10, 15 }, 10 { 10, 20, 30 }, 11 { 15, 30, 45 } 12 }); 13 14 EigenDecomposition ed = new EigenDecomposition(matrix); 15 double[] eigValues = ed.getRealEigenvalues(); FOSDEM 2013 Apache Commons Math February 02, 2013 10 / 17
  • 11. Example - Linear optimization: Simplex method Maximize 2x2 + 6x1 + 7x0 with constraints x2 + 2x1 + x0 <= 2 −x2 + x1 + x0 <= −1 2x2 − 3x1 + x0 <= −1 1 import o.a.c.m.optim.linear.LinearObjectiveFunction; 2 import o.a.c.m.optim.linear.LinearConstraint; 3 import o.a.c.m.optim.linear.SimplexSolver; 4 5 /// ... 6 7 LinearObjectiveFunction f = new LinearObjectiveFunction(new double[] { 2, 6, 7 }, 0); 8 9 ArrayList<LinearConstraint> constraints = new ArrayList<LinearConstraint>(); 10 constraints.add(new LinearConstraint(new double[] { 1, 2, 1 }, Relationship.LEQ, 2)); 11 constraints.add(new LinearConstraint(new double[] { -1, 1, 1 }, Relationship.LEQ, -1)); 12 constraints.add(new LinearConstraint(new double[] { 2, -3, 1 }, Relationship.LEQ, -1)); 13 14 SimplexSolver solver = new SimplexSolver(); 15 PointValuePair solution = solver.optimize(new MaxIter(100), f, new LinearConstraintSet(constraints), 16 GoalType.MAXIMIZE, new NonNegativeConstraint(false)); FOSDEM 2013 Apache Commons Math February 02, 2013 11 / 17
  • 12. Who is using Commons Math? Responses from our community: Field Topic Link Space Orekit - open-source space dynamics library http://www.orekit.org Astronomy Gaia Project: data processing of astrometric, photometric, and spectroscopic http://www.rssd.esa.int/index. data from 1 billion stars php?project=GAIA&page=DPAC_ Introduction Material Science Simulate the mechanical behaviour of composite materials http://navier.enpc.fr/ BRISARD- Sebastien Biotech Nuclear Magnetic Resonance (NMR) data analysis package for molecular http://www.onemoonscientific.com structure refinement Medical Technology Image processing of 3D human MRI and CT scans http://www.stjude.org Finance Risk managment and analysis http://www.osloclearing.no/ A maven dependency search: Apache Hama - parallel computing framework Myrrix - A real-time recommender system Apache Mahout - scalable machine learning Redberry - Symbolic Tensor Algebra System Facebook jcommon-stats - well you know it ... FOSDEM 2013 Apache Commons Math February 02, 2013 12 / 17
  • 13. How to use it yourself? Maven: <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-math3</artifactId> <version>3.1.1</version> </dependency> Download: http://commons.apache.org/math/download_math.cgi FOSDEM 2013 Apache Commons Math February 02, 2013 13 / 17
  • 14. Links Project homepage: http://commons.apache.org/math/ Issue tracker: https://issues.apache.org/jira/browse/MATH Mailinglists: dev@commons.apache.org & user@commons.apache.org e-mail subject: [math] Wiki: http://wiki.apache.org/commons/MathWishList FOSDEM 2013 Apache Commons Math February 02, 2013 14 / 17
  • 15. How to contribute? Check out the user guide http://commons.apache.org/math/userguide/index.html Ask questions on the user mailinglist Participate in discussions on the dev mailinglist Create bug reports / feature requests / improvements in JIRA Send patches (code, documentation, examples) Provide feedback - most welcome! FOSDEM 2013 Apache Commons Math February 02, 2013 15 / 17
  • 16. Hot Topics refactoring Linear Algebra package refactoring Optimization package Exception handling - checked vs. unchecked Add more computational geometry algorithms Upgrade to more recent Java versions (fork/join framework) (real) FastMath vs. AccurateMath (integration of jodk) improve user guide / examples lots of new feature requests . . . FOSDEM 2013 Apache Commons Math February 02, 2013 16 / 17
  • 17. The End! Questions? FOSDEM 2013 Apache Commons Math February 02, 2013 17 / 17