## kernels.apply_tail()


Apply a tail to link factors.


Usage

``` python
kernels.apply_tail(
    factors,
    dev_grain_months,
    spec,
    *,
    on_error="raise",
)
```


[factors](kernels.TweedieFit.md#ibnr.kernels.TweedieFit.factors) holds one factor per link of the triangle, `(n_links,)`, or one row of them per simulation, `(n_sims, n_links)`; link `j` develops from age `(j + 1) * dev_grain_months`. The curve is fitted to each row on its own, with the closed-form least-squares line, so a bootstrap fits every simulated triangle's curve in one call.

Refused, by name (with `on_error="raise"`, the default): an `attach_lag` or a `fit_lags` end that is not a development age of the triangle, or after its last age that can carry one; a curve with fewer than two factors above `MIN_FIT_FACTOR` to fit (`not_identified`); a curve that does not decay (`tail_not_decaying`); and a tail that is not a finite positive number (`result_not_finite`), never answered as no tail. With `on_error="flag"` a row of factors whose curve fails one of the last three is not refused: its arrays hold NaN and `ok` is false for it, so a bootstrap can count those draws and handle them.
