Learn R Programming

MixStable (version 0.1.0)

safe_integrate: Safe integration wrapper with multiple fallback strategies

Description

Performs numerical integration with progressively more conservative settings to improve robustness. Useful when standard integration may fail due to oscillatory or heavy-tailed functions.

Usage

safe_integrate(
  integrand_func,
  lower = 1e-08,
  upper = 50,
  max_attempts = 3,
  ...
)

Value

Numeric scalar. The estimated value of the integral, or 0 if all attempts fail.

Arguments

integrand_func

Function to integrate. Must accept a numeric vector as input and return numeric values.

lower

Numeric scalar. Lower bound of the integration interval (default = 1e-8 to avoid singularities at 0).

upper

Numeric scalar. Upper bound of the integration interval (default = 50).

max_attempts

Integer. Maximum number of fallback attempts with modified settings if the initial integration fails.

...

Additional arguments passed to integrand_func.