Function vector_invert_enclosed_sum (o2scl)¶
-
template<class vec_t, class vec2_t>
int o2scl::vector_invert_enclosed_sum(double sum, size_t n, vec_t &x, vec2_t &y, double &lev, int boundaries = 0, int verbose = 0, bool err_on_fail = true)¶ Compute the endpoints which enclose the regions whose integral is equal to
sum
.Defining a new function, \( g(y_0) \) which takes as input any y-value, \( y_0 \) from the function \( y(x) \) (specified with the parameters
x
andy
) and outputs the integral of the function \( y(x) \) over all regions where \( y(x) > y_0 \). This function inverts \( g(y) \), taking the value of an integral as input, and returns the corresponding y-value in the variablelev
.This function is particularly useful, for example, in computing the region which defines 68% around a peak of data, thus providing \( 1~\sigma \) confidence limits.
By default, this function does not allow any enclosed regions to go beyond the x region specified by the data. In some cases, it is useful to fix the boundaries to zero to ensure the integral is well-defined. If
boundaries
is set to 1, then the LHS boundary is set to zero, ifboundaries
is set to 2, then the RHS boundary is set to zero, and ifboundaries
is set to 3, then both boundaries are set to zero.Even if the boundaries are set to zero, the region enclosing a particular integral may not be well-defined, and this function can fail to find a region given a specified value of
sum
. Linear interpolation is used to describe the function \( g \), and the precision of this function is limited by this assumption. This function may also sometimes fail ifsum
is very close to the minimum or maximum value of the function \( g \).