I'm working with some two-dimensional probability distributions which have emerged from Bayesian inference work I'm doing. These PDFs are stored on regularly spaced Cartesian grids.
I feel like it would be quite common for one to wish to find a contour of constant probability density which encapsulates a certain fraction of the total probability - say one or two sigma worth, or perhaps 95% ect.
From what I can tell, to evaluate this contour we need to be able to calculate the integral of the PDF in the region bounded by a contour. I've written a scheme myself based on splitting the area between two closed contours into a series of triangles to evaluate such an integral, and it seems to work fine.
However - this is such a common problem I feel like there must be a more elegant way of doing this, perhaps exploiting some vector calculus?
If anyone knows something about this I'd be grateful. Feel free to assume that the Cartesian grids are dense enough that interpolation may be used to determine the value of the PDF at an arbitrary point, and that the distributions are uni-modal.