warn_once_negative_default_intensity: Wrap a default intensity function so it warns at most once...

View source: R/checkinputs.R

warn_once_negative_default_intensityR Documentation

Wrap a default intensity function so it warns at most once about negatives

Description

The default intensity (hazard rate) must be nonnegative. A solver such as integrate_pde calls the intensity function many times, on various stock-price grids and at various times, so a naive check would emit a flood of redundant warnings. This routine returns a function that behaves exactly like default_intensity_fcn but latches a flag in its enclosing environment so that, across all of its invocations, at most one warning about negative intensities is emitted in the usual futile.logger manner.

Usage

warn_once_negative_default_intensity(default_intensity_fcn)

Arguments

default_intensity_fcn

A function for computing default intensity, with arguments t, S

Details

Create a fresh wrapper for each top-level pricing call so that the "already warned" state is scoped to that call and resets on the next.

Value

A function with the same interface as default_intensity_fcn that warns at most once about negative default intensities

See Also

Other Input Checking: check_discount_factor_fcn(), check_survival_probability_fcn(), check_variance_cumulation_fcn()


ragtop documentation built on June 20, 2026, 5:06 p.m.