
Paul A Bristow wrote:
This brings to mind another function that, though easily derived would be good to have to allow internal computations less subject to round-off error. This is a two parameter function that is the cumulative probability between a lower and an upper bound. Mathematically this can always be computed as "CDF(x[ub]) - CDF(x[lb])" (read the square brackets as mathematical subscript notation) but numerically with very small intervals, you can easily end up with 0 when you want something close to "PDF((x[ub]+x[lb])/2)*(x[ub]-x[lb])".
An interesting suggestion.
John Maddock has been muttering about using Boost.Interval with these functions. It's on his TODO list allegedly ;-)
Yeh, but it's a long list ;-)
Would this help with the "CDF(x[ub]) - CDF(x[lb])"?
And/or allow one to produce "PDF((x[ub]+x[lb])/2)*(x[ub]-x[lb])" using the density/mass/distribution?
No it's entirely different functionality. Returning an interval guards against rounding error, or function sensitivity, leading you towards erroneous conclusions. Calculating a probablity over an interval is the same as integrating the distribution function from x to y rather than -INF to x. Doing it properly requires for example a four argument incomplete beta: ibeta(a, b, x, y); // incomplete beta integral from x to y. and a three argument incomplete gamma: gamma_Q(a, x, y); // incomplete gamma integral from x to y. However, I don't know how to implement those: I did have a very quick look into this when I did the incomplete gamma and didn't find any useful literature, so if anyone has any leads I'm all ears. My inclination is to leave stuff like this for version 2 (or 3!) though :-) John.