Skip to main content

Module custom

Module custom 

Source
Expand description

Custom, a user-defined loss severity given by its cdf: the “slow path” of docs/design/distributions.md, through which a Python or R function enters the native calculations.

The cdf is the only function a user must supply; a quantile function is optional and makes sampling much faster. Everything else (the mean, the variance, limited expected values, layer moments) is computed by Gauss–Legendre quadrature of the survival function on panels between the distribution’s own quantiles, so it is as accurate as the cdf is smooth. The integrals stop at the 1 - 1e-12 quantile: the probability above it is ignored, which is negligible unless the tail is so heavy that the mean barely exists.

A callback may come from a language that must not be entered from several threads at once (R must only ever be called on its main thread), so a Custom built with parallel_safe = false reports so through Distribution::is_parallel_safe, and the parallel simulations run single-threaded on the calling thread when they meet one.

Structs§

Custom
A non-negative loss severity defined by a user’s cdf (and optionally quantile) function.

Type Aliases§

Callback
A user function of one variable. An Err carries the message of the failure (a Python exception, an R error).