Hello(adsbygoogle = window.adsbygoogle || []).push({});

I have a function which is very similar in shape to a Gaussian, except it is not a distribution and it is not analytic, so I can at best calculate a single point on the curve at a time. (In general it is a convolution of different distributions but this is not important).

I need to find the area under this curve accurately, using the least amount of calculations (I need to find the area under ~1,000 curves and right now it is taking about 5 seconds per curve to get within about 1% accuracy, ideally the code needs to perform this in real time! ).

My first try was to use a regular grid, eg. -10:0.01:10 for 2001 points, then the area (under)approximated by the sum of the values/100, the resolution. Varying the range and resolution of integration get me close to the "true" value but it takes too long, and I think I am wasting high resolution on the tail.

My next idea for optimisation is to have a grid which has more resolution at the areas of highest slope (does this make mathematical sense? I think...). I am having trouble justifying this and do not really know where to begin to implement it.

If anyone could point me to the right direction, I am sure this has been done before.

Regards,

Mike

**Physics Forums - The Fusion of Science and Community**

# Numerical integration - optimisation of code

Know someone interested in this topic? Share a link to this question via email,
Google+,
Twitter, or
Facebook

Have something to add?

- Similar discussions for: Numerical integration - optimisation of code

Loading...

**Physics Forums - The Fusion of Science and Community**