0
votes

Suppose we have a well-defined probability distribution that is conditional upon a certan parameter: p(x|a)*p(a), like in a Bayes approach.

Now, in order to find x, I might want to integrate over all values of a. Is there a general approach to such mathematical problem using Java?

2
Can you clarify: is finding the solution you goal, or writing the code? Put another way, are you willing to use the appropriate libraries? Or are you looking to write a library?Dancrumb
Is there a general approach to such mathematical problem using Java There is, it's just a question of how much more work it will be compared to other math-centric languages.David B
I am willing to use the code, library, anything that will get me the result, approximated to a good degreeBober02
I'd edit the question: You're looking for a function of x given a prior function to multiply it by. Sounds like Bayes to me.duffymo

2 Answers

5
votes

Yes, the same approach that exists in FORTRAN, C, Perl, etc: coding up the math.

To be less blithe: Java is not the typical language choice for people doing numerics, and it wasn't written to cater to that audience, so the intrinsic language support isn't great, nor is the library support. My recommendation: pick a language explicitly for your problem - e.g., R, Octave, Matlab, Mathematica, Maple - or one that has more baked-in + ongoing community support - e.g., C/C++, FORTRAN, Perl.

That said, there are some libraries if you are committed to doing numerics in Java; NIST has best gathering I've found, but that site seems under-maintained, so it's only a starting point.

0
votes

There are lots of numerical integration schemes out there. Google for "java numerical integration" or "java quadrature".

One implementation choice is JSci.

If you read Forman Acton's "Numerical Methods That Work", chapter 4 'Quadrature', you'll see that it may not be a trivial problem depending on your integrand.

Are you doing a Bayesian analysis? Maybe a Monte Carlo Markov Chain approach would be better. Look at WinBUGS and read John Krushke's excellent book.

UPDATE: If your integrand is an analytic function, you should use a symbolic integrator to come up with a function of x. If it is not, the best you can do is WinBUGS. You'll do a Monte Carlo simulation to build up what the distro looks like after many trials.

You aren't finding an easy answer to your question because it's not an easy problem.