0

I have a lot of datapoints and I want to compute the area under the curve for sliding windows. But It should be quite fast. I googled a bit and found a NewtonCotes implementation in Java, but I don´t know if there are faster methods.

Any Ideas?

Puckl
  • 731
  • 5
  • 19
  • We cannot answer your question without knowing your requirements as to the precision of the quadrature. Please consider reading some materials on [numerical analysis](http://www.stat.uchicago.edu/~lekheng/courses/302/wnnr/nr-alt.html) first. – Deer Hunter Oct 09 '12 at 11:07
  • It doesn´t need to be super precise, abs(E(f)) < 1 is ok. I already considered the trapezoid rule, but maybe there are methods I havent heard of which are faster. And the next thing is that I don´t know which implementation is fast. – Puckl Oct 09 '12 at 11:25
  • Define "fast". What's your requirement? – duffymo Oct 09 '12 at 11:44

1 Answers1

2

The answer depends on the function you're trying to integrate. Gauss quadrature can be very efficient indeed if applied to the right function. 5th order adaptive Runga-Kutta can do very well, too.

An adaptive method that automatically increases refinement to meet a given accuracy requirement is quite doable.

The fastest code to write is a library:

http://commons.apache.org/math/

I'd recommend a book like Numerical Recipes or another by Forman Acton.

duffymo
  • 305,152
  • 44
  • 369
  • 561