Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java special math functions library

Tags:

java

math

I am looking for a Java library to calculate gamma, beta, erf, bessel special functions (and some related) for including into our own formula parser. Numeric accuracy is the main priority - it's a scientific program. And it must be open-source and free for commercial usage (like Apache and BSD licenses).

I supposed that I would quickly find come 'classical', 'reference' implementation like JAMA library is for matrix operations but I cannot find that so far. We only need special function evaluation and don't need any additional library features.

The first I found is Apache Common Math but I see a terrible accuracy for beta function: http://commons.apache.org/proper/commons-math/userguide/special.html.

Then I found Colt. It seems to be good but I'm not sure that it was properly tested by developers and users (some rarely used code may be copied from somewhere with mistakes, etc.)

Any suggestions will be appreciated.

like image 878
Alexander Avatar asked Apr 27 '13 13:04

Alexander


1 Answers

First of all: Don't be deceived by the homemade look of the web page and the old release date of the Colt library (as well as the JET and JAS libraries that build on it). It has been used in endless research projects and the code has been verified by hundreds of very talented people.

Of course, if the credibility of your own product is at stake you should not just take my word for it. Here are two ideas how you could get a feel the correctness yourself:

  • Read the source code. The JavaDoc of Colt contains references to the papers where the numerical methods were published. Search for other work that references these papers and see if problems with the used method have been discovered later.
  • Use a commercial numerical software that you trust (for example Mathematica), generate values for the functions you are interested in either systematically or randomly, and compare these with the values generated by Colt. If you let such a test run long enough, you will get a pretty good understanding of the quality of the numbers.

If you really don't want to use Colt (which I guess was your question), I suggest porting the C/C++ code from the numerical recipes book (http://www.nrbook.com) yourself. There normally isn't too much adoption necessary, but you still need to think about how you want to test it.

like image 151
Tilo Avatar answered Sep 28 '22 01:09

Tilo