Performs numerical integration with progressively more conservative settings to improve robustness. Useful when standard integration may fail due to oscillatory or heavy-tailed functions.
safe_integrate(
integrand_func,
lower = 1e-08,
upper = 50,
max_attempts = 3,
...
)Numeric scalar. The estimated value of the integral, or 0 if all attempts fail.
Function to integrate. Must accept a numeric vector as input and return numeric values.
Numeric scalar. Lower bound of the integration interval (default = 1e-8 to avoid singularities at 0).
Numeric scalar. Upper bound of the integration interval (default = 50).
Integer. Maximum number of fallback attempts with modified settings if the initial integration fails.
Additional arguments passed to integrand_func.