Compute multidimensional normal CDF in Java

Does anyone know a reliable and accurate library for computing multidimensional normal (MVN) CDF in Java? I am looking for something like the MATLAB function mvncdf . I need to be able to do this for sizes up to 10 or more. Most statistical / math libraries do not have this feature. The ability to calculate logarithmic probability is a plus.

From this post , it seems that for some other languages ​​there is no free implementation. While direct Java implementation is implemented, I would accept implementations in other languages ​​that do not require licenses (e.g. MATLAB or IMSL, for example) and can be easily called from Java with minimal overhead.

(This question is derived from a post in StackExchange math , where I am trying to calculate the probability of ordering ordinary random variables ... if you are "interested in trying to solve the problem directly using other mathematical methods, please check this.)

+6
source share
2 answers

After a series of additional studies, it seems that the most reasonable way is the following:

Multidimensional normal CDF is not trivial to calculate (especially for large dimensions), and several scientific papers have been written on this subject. Professor Alan Gentz ​​has a bunch of Fortran-77 routines that compute various multidimensional densities and CDFs available on his page here: http://www.math.wsu.edu/faculty/genz/software/software.html

As you can see from some of this code, this is not quite the same as recovery in another language, and probably why this was not done if someone did not pay for it. A lot of mathematical / numerical programming is done at Fortran at the research level, so where is most of the best code.

Thus, for optimal results, it would be best to immediately call the Fortran routine directly using JNI or JNA. JNA seems to be easiest to implement by following these instructions: http://www.javaforge.com/wiki/66061 . Using this and some other links, I used the Java-JNA-Fortran link to call the MVNEXP (expected value) and MVNDST (cdf) routines. You can check the code here:

You should also point out: there is native Java code for some two-dimensional distributions and other things that you will not find in ordinary mathematics; It was adapted from the source: http://www.iro.umontreal.ca/~simardr/ssj/indexe.html . This is a very good math library that I have not found so far.

+4
source

Adding OP to the solution (for example, that fortran code was the best option and nothing else was found) is one way to access a clean java library - with the f2j (fortran to java) compiler http: //icl.cs. utk.edu/f2j

I found that the code that it creates will be fully functional (for example, such a minpack library: http://www1.fpl.fs.fed.us/optimization/LmderTest_f77.html ). The only annoyance that I remember was that arrays start with "1" versus "0", but you can easily (if you're interested) deal with the trivial wrapper function.

@Andrew: if you convert it, I would be interested!

+1
source

All Articles