Function capped_loss
fn capped_loss<R: Scalar>(pd: R, lgd: R, cap: f64, rho: R) -> RExpand description
The LHP expected capped loss E[min(L, K)], L = lgd·p(M).
p falls in the factor, so the loss is at least K exactly where the
factor is at most the kink m* = (Φ⁻¹(pd) − √(1−ρ)·Φ⁻¹(K/lgd)) / √ρ.
Below the kink the payoff is the constant K and integrates in closed
form; above it the payoff is smooth and Gauss–Legendre runs on
[m*, B], its nodes moving with m*. No branch depends on where a node
sits against the kink, so the value is continuously differentiable in
every input — a fixed grid over the kinked payoff was only piecewise so,
and a bump straddling a node crossing read another slope than AD.
The factor is truncated to [−B, B] as the fixed grid was. A loss that
never reaches K (K ≥ lgd) has no kink; at zero correlation the loss is
lgd·pd for certain.