# API Reference


## Distributions


Parametric, discretized and sampled representations.


[distributions.Lognormal](distributions.Lognormal.md#prospicio.distributions.Lognormal)  
Lognormal distribution: `ln X ~ Normal(meanlog, sdlog**2)`.

[distributions.Gamma](distributions.Gamma.md#prospicio.distributions.Gamma)  
Gamma distribution with shape `alpha` and scale `theta`: mean

[distributions.Tweedie](distributions.Tweedie.md#prospicio.distributions.Tweedie)  
Tweedie distribution with mean `mu`, dispersion `phi` and power

[distributions.Weibull](distributions.Weibull.md#prospicio.distributions.Weibull)  
Weibull distribution with shape `k` and scale `lam`:

[distributions.Loglogistic](distributions.Loglogistic.md#prospicio.distributions.Loglogistic)  
Loglogistic (Fisk) distribution with shape `alpha` and scale

[distributions.Mixture](distributions.Mixture.md#prospicio.distributions.Mixture)  
A finite mixture of severities: component `i` with probability

[distributions.Custom](distributions.Custom.md#prospicio.distributions.Custom)  
A loss severity defined by your own distribution function: the slow

[distributions.to_json()](distributions.to_json.md#prospicio.distributions.to_json)  
A distribution as a JSON document: the family and the parameters its

[distributions.from_json()](distributions.from_json.md#prospicio.distributions.from_json)  
A distribution from a document written by `to_json`, as the class of

[distributions.Grid](distributions.Grid.md#prospicio.distributions.Grid)  
A distribution on the points `0, step, 2*step, ...`: the discretized

[distributions.DiscretizationReport](distributions.DiscretizationReport.md#prospicio.distributions.DiscretizationReport)  
How a distribution was discretized, and the error that introduced.

[distributions.Sampled](distributions.Sampled.md#prospicio.distributions.Sampled)  
A distribution known only through equally weighted draws.


## Large-loss severities


The Pareto family for layer and treaty pricing, with maximum likelihood fits.


[distributions.Pareto](distributions.Pareto.md#prospicio.distributions.Pareto)  
Single-parameter Pareto: `P(X > x) = (t / x) ** alpha` for `x >= t`,

[distributions.PiecewisePareto](distributions.PiecewisePareto.md#prospicio.distributions.PiecewisePareto)  
Piecewise Pareto: alpha `alpha[k]` above threshold `t[k]`, the

[distributions.LogAffinePareto](distributions.LogAffinePareto.md#prospicio.distributions.LogAffinePareto)  
Log-affine local Pareto: the local alpha

[distributions.GeneralizedPareto](distributions.GeneralizedPareto.md#prospicio.distributions.GeneralizedPareto)  
Generalized Pareto severity with a location (Riegel's parameterization

[distributions.local_pareto_to_piecewise()](distributions.local_pareto_to_piecewise.md#prospicio.distributions.local_pareto_to_piecewise)  
Converts the local Pareto distribution with local alpha `alpha(x)`


## Claim counts


Frequency distributions for frequency-severity aggregation.


[distributions.Poisson](distributions.Poisson.md#prospicio.distributions.Poisson)  
Poisson claim counts with mean `lam`.

[distributions.NegativeBinomial](distributions.NegativeBinomial.md#prospicio.distributions.NegativeBinomial)  
Negative binomial claim counts: mean `r * beta`, variance

[distributions.Binomial](distributions.Binomial.md#prospicio.distributions.Binomial)  
Binomial claim counts: `n` risks, each claiming with probability

[distributions.claim_count()](distributions.claim_count.md#prospicio.distributions.claim_count)  
The claim count with this mean and dispersion `Var[N] / E[N]`:


## Predictive distributions


The joint result every model returns.


[distributions.PredictiveDistribution](distributions.PredictiveDistribution.md#prospicio.distributions.PredictiveDistribution)  
The joint result every model returns: draws for each simulation (row)


## Aggregate loss


Compound distributions on a grid, and simulated years of losses.


[aggregate.panjer()](aggregate.panjer.md#prospicio.aggregate.panjer)  
Aggregate loss `S = X_1 + ... + X_N` by Panjer's recursion.

[aggregate.fft()](aggregate.fft.md#prospicio.aggregate.fft)  
Aggregate loss `S = X_1 + ... + X_N` by fast Fourier transform.

[aggregate.CompoundReport](aggregate.CompoundReport.md#prospicio.aggregate.CompoundReport)  
What a compound calculation produced and the error it introduced.

[aggregate.simulate_events()](aggregate.simulate_events.md#prospicio.aggregate.simulate_events)  
Simulates `n_sims` years of claims: a count from `frequency`, then that

[aggregate.EventSet](aggregate.EventSet.md#prospicio.aggregate.EventSet)  
Simulated years of individual losses, for applying per-loss terms such


## Reinsurance


Excess-of-loss layers and towers, applied to simulated losses or exactly on the grid.


[reinsurance.Layer](reinsurance.Layer.md#prospicio.reinsurance.Layer)  
A per-occurrence excess-of-loss layer: `limit` xs `attachment` on each

[reinsurance.Tower](reinsurance.Tower.md#prospicio.reinsurance.Tower)  
A reinsurance programme: layers in inuring stages.

[reinsurance.TowerGrids](reinsurance.TowerGrids.md#prospicio.reinsurance.TowerGrids)  
A tower's annual distributions on the grid, from `Tower.on_grid`.


## Models


Terms and design matrices, GLMs and GAMs, metrics, resampling and MCMC diagnostics.


[models.Terms](models.Terms.md#prospicio.models.Terms)  
The terms of a model: an intercept, numeric columns and factors.

[models.Coding](models.Coding.md#prospicio.models.Coding)  
Terms with factor levels learned from training data, from

[models.Design](models.Design.md#prospicio.models.Design)  
A design matrix with an offset and prior weights.

[models.Glm](models.Glm.md#prospicio.models.Glm)  
A generalized linear model, fitted by IRLS.

[models.GlmFit](models.GlmFit.md#prospicio.models.GlmFit)  
A fitted GLM, from `Glm.fit`.

[models.BayesGlm](models.BayesGlm.md#prospicio.models.BayesGlm)  
A Bayesian GLM sampled with NUTS (nuts-rs, the Rust core of nutpie).

[models.BayesGlmFit](models.BayesGlmFit.md#prospicio.models.BayesGlmFit)  
A sampled Bayesian GLM, from `BayesGlm.fit`.

[models.ElasticNet](models.ElasticNet.md#prospicio.models.ElasticNet)  
An elastic-net GLM: the lasso (`alpha=1`), ridge (`alpha=0`) and

[models.ElasticNetFit](models.ElasticNetFit.md#prospicio.models.ElasticNetFit)  
A fitted elastic net, from `ElasticNet.fit` or `ElasticNet.path`.

[models.CvPath](models.CvPath.md#prospicio.models.CvPath)  
Cross-validated scores along an elastic-net path, from

[models.Gam](models.Gam.md#prospicio.models.Gam)  
A generalized additive model: a `Glm` plus P-spline smooths of

[models.GamFit](models.GamFit.md#prospicio.models.GamFit)  
A fitted GAM, from `Gam.fit`.

[models.deviance()](models.deviance.md#prospicio.models.deviance)  
Deviance `sum w d(y, mu)` of a family.

[models.gini()](models.gini.md#prospicio.models.gini)  
Gini index of the ordered Lorenz curve.

[models.lift()](models.lift.md#prospicio.models.lift)  
Lift table: rows sorted by predicted rate, cut into bands of about

[models.crps()](models.crps.md#prospicio.models.crps)  
Continuous ranked probability score of equally likely draws for an

[models.log_score()](models.log_score.md#prospicio.models.log_score)  
Mean log score `-(1/n) sum log f(y_i)` of the outcomes under the

[models.pit()](models.pit.md#prospicio.models.pit)  
Probability integral transform of each outcome under the family's

[models.pit_from_draws()](models.pit_from_draws.md#prospicio.models.pit_from_draws)  
The PIT of `y` under the empirical distribution of `draws`,

[models.pit_histogram()](models.pit_histogram.md#prospicio.models.pit_histogram)  
Counts of PIT values in `bins` equal-width bins of `[0, 1]`.

[models.ks_uniform()](models.ks_uniform.md#prospicio.models.ks_uniform)  
Kolmogorov-Smirnov distance from the uniform on `[0, 1]`; about

[models.k_fold()](models.k_fold.md#prospicio.models.k_fold)  
`k`-fold splits of `n` rows, shuffled with `seed`.

[models.group_k_fold()](models.group_k_fold.md#prospicio.models.group_k_fold)  
Grouped `k`-fold splits: each group's rows stay in one fold.

[models.time_ordered()](models.time_ordered.md#prospicio.models.time_ordered)  
Time-ordered splits: for each of the last `n_test` periods, train on

[models.mcmc_diagnostics()](models.mcmc_diagnostics.md#prospicio.models.mcmc_diagnostics)  
MCMC diagnostics of chains of draws (Vehtari et al. 2021, as R's

[models.elpd_loo()](models.elpd_loo.md#prospicio.models.elpd_loo)  
Leave-one-out cross-validation by Pareto-smoothed importance sampling

[models.stacking_weights()](models.stacking_weights.md#prospicio.models.stacking_weights)  
Stacking weights from pointwise held-out log predictive densities

[models.pseudo_bma_weights()](models.pseudo_bma_weights.md#prospicio.models.pseudo_bma_weights)  
Pseudo-BMA weights, `w_k` proportional to `exp(elpd_k)`; with

[models.BayesStacking](models.BayesStacking.md#prospicio.models.BayesStacking)  
Bayesian stacking: a posterior for the stacking weights, with a

[models.HierarchicalStacking](models.HierarchicalStacking.md#prospicio.models.HierarchicalStacking)  
Hierarchical stacking (Yao, Pirš, Vehtari and Gelman, 2022): model

[models.StackingFit](models.StackingFit.md#prospicio.models.StackingFit)  
Posterior stacking weights, from `BayesStacking.fit` or

[models.elpd_waic()](models.elpd_waic.md#prospicio.models.elpd_waic)  
WAIC from pointwise log-likelihood draws: `lppd` less the variance of

[models.lppd()](models.lppd.md#prospicio.models.lppd)  
In-sample log pointwise predictive density,

[models.Elpd](models.Elpd.md#prospicio.models.Elpd)  
An ELPD estimate from `elpd_loo` or `elpd_waic`.

[models.deviance_score()](models.deviance_score.md#prospicio.models.deviance_score)  
A score for `cross_validate`: the family's mean deviance on the

[models.cross_validate()](models.cross_validate.md#prospicio.models.cross_validate)  
Fits `model` on each split's training rows and scores it on the

[models.grid_search()](models.grid_search.md#prospicio.models.grid_search)  
Scores every candidate by `cross_validate` on the same splits and

[models.random_search()](models.random_search.md#prospicio.models.random_search)  
Draws `n` candidates with `draw(rng)` from `random.Random(seed)`

[models.log_uniform()](models.log_uniform.md#prospicio.models.log_uniform)  
A draw log-uniform between `low` and `high`, for learning rates

[models.SearchResult](models.SearchResult.md#prospicio.models.SearchResult)  
The result of `grid_search` or `random_search`.

[models.compare()](models.compare.md#prospicio.models.compare)  
Fits every model on each split's training rows and scores its test

[models.Comparison](models.Comparison.md#prospicio.models.Comparison)  
The result of `compare`: every model's score on every metric and

[models.actual_vs_expected()](models.actual_vs_expected.md#prospicio.models.actual_vs_expected)  
Actual against expected by period for a stored model's predictions on

[models.simulate_from_means()](models.simulate_from_means.md#prospicio.models.simulate_from_means)  
Joint predictive draws from fitted means, for engines that give only


## Gradient boosting


LightGBM and XGBoost behind the model protocol, with joint predictive draws.


[boosting.Booster](boosting.Booster.md#prospicio.boosting.Booster)  
Gradient-boosted trees for a response family, through LightGBM or

[boosting.BoosterFit](boosting.BoosterFit.md#prospicio.boosting.BoosterFit)  
A fitted `Booster`: means and joint predictive draws.


## Pricing


The collective model, layer rating, reinsurance tower matching, and risk-loaded prices from simulated losses.


[pricing.CollectiveModel](pricing.CollectiveModel.md#prospicio.pricing.CollectiveModel)  
The collective risk model: a claim count and a severity, with layer

[pricing.ilf()](pricing.ilf.md#prospicio.pricing.ilf)  
Increased limit factor `LEV(limit) / LEV(basic_limit)`.

[pricing.loss_elimination_ratio()](pricing.loss_elimination_ratio.md#prospicio.pricing.loss_elimination_ratio)  
Loss elimination ratio of a deductible, `LEV(deductible) / E[X]`.

[pricing.pareto_extrapolation()](pricing.pareto_extrapolation.md#prospicio.pricing.pareto_extrapolation)  
Expected loss of layer `to` per unit of expected loss of layer

[pricing.alpha_between_layers()](pricing.alpha_between_layers.md#prospicio.pricing.alpha_between_layers)  
The Pareto alpha at which two layers have the given expected losses.

[pricing.alpha_between_frequency_and_layer()](pricing.alpha_between_frequency_and_layer.md#prospicio.pricing.alpha_between_frequency_and_layer)  
The Pareto alpha at which `frequency` losses a year above

[pricing.alpha_between_frequencies()](pricing.alpha_between_frequencies.md#prospicio.pricing.alpha_between_frequencies)  
The Pareto alpha between two excess frequencies.

[pricing.match_tower()](pricing.match_tower.md#prospicio.pricing.match_tower)  
Matches a tower of contiguous layers, the last unlimited, with one

[pricing.fit_pml_curve()](pricing.fit_pml_curve.md#prospicio.pricing.fit_pml_curve)  
The model through the points of a PML curve: `amounts[j]` is

[pricing.fit_references()](pricing.fit_references.md#prospicio.pricing.fit_references)  
A model that reproduces every reference: expected layer losses (which

[pricing.TowerModel](pricing.TowerModel.md#prospicio.pricing.TowerModel)  
A frequency and a piecewise Pareto severity that reproduce a tower,

[pricing.price()](pricing.price.md#prospicio.pricing.price)  
Risk-loaded price of a cover from its simulated losses.

[pricing.price_portfolio()](pricing.price_portfolio.md#prospicio.pricing.price_portfolio)  
Prices a portfolio and allocates the price to its components.

[pricing.Price](pricing.Price.md#prospicio.pricing.Price)  
The risk-loaded price of a cover, or of one component's share of a

[pricing.PortfolioPrice](pricing.PortfolioPrice.md#prospicio.pricing.PortfolioPrice)  
Prices of a portfolio's components and of the portfolio as a whole.

[pricing.Mbbefd](pricing.Mbbefd.md#prospicio.pricing.Mbbefd)  
The MBBEFD exposure curve and destruction-rate distribution (Bernegger,

[pricing.TabulatedCurve](pricing.TabulatedCurve.md#prospicio.pricing.TabulatedCurve)  
A tabulated exposure curve: points `(x, G(x))` from `(0, 0)` to

[pricing.RiskProfile](pricing.RiskProfile.md#prospicio.pricing.RiskProfile)  
A risk profile for property per-risk business: bands of sum insured,

[pricing.severity_exposure_curve()](pricing.severity_exposure_curve.md#prospicio.pricing.severity_exposure_curve)  
The exposure curve of a severity capped at the maximum possible loss


## Reserving


Loss triangles, the chain ladder with tail factors, Mack's model with its one-year view, the expected-loss methods, the ODP bootstrap and Clark's growth curves.


[reserving.Triangle](reserving.Triangle.md#prospicio.reserving.Triangle)  
A loss triangle with four axes: index (segment), column (measure), origin

[reserving.ChainLadder](reserving.ChainLadder.md#prospicio.reserving.ChainLadder)  
The chain-ladder method: each origin's latest value projected to

[reserving.ChainLadderFit](reserving.ChainLadderFit.md#prospicio.reserving.ChainLadderFit)  
A fitted chain-ladder projection of every segment of a triangle column.

[reserving.TailConstant](reserving.TailConstant.md#prospicio.reserving.TailConstant)  
A given tail factor, as chainladder-python's `TailConstant`.

[reserving.TailCurve](reserving.TailCurve.md#prospicio.reserving.TailCurve)  
A curve fitted to the estimated factors and extrapolated, as

[reserving.TailBondy](reserving.TailBondy.md#prospicio.reserving.TailBondy)  
The Bondy tail, as chainladder-python's `TailBondy`.

[reserving.TailLogLinear](reserving.TailLogLinear.md#prospicio.reserving.TailLogLinear)  
R ChainLadder's `tail = TRUE` rule (its `tailfactor` function).

[reserving.Mack](reserving.Mack.md#prospicio.reserving.Mack)  
Mack's distribution-free chain ladder: the chain-ladder projection plus

[reserving.MackFit](reserving.MackFit.md#prospicio.reserving.MackFit)  
A fitted Mack model of every segment: the chain-ladder fields, plus

[reserving.ClaimsDevelopmentResult](reserving.ClaimsDevelopmentResult.md#prospicio.reserving.ClaimsDevelopmentResult)  
Merz and Wüthrich's (2008) one-year view of a Mack fit: standard errors

[reserving.ExpectedLoss](reserving.ExpectedLoss.md#prospicio.reserving.ExpectedLoss)  
The expected loss ratio method: each origin's ultimate is `apriori`

[reserving.BornhuetterFerguson](reserving.BornhuetterFerguson.md#prospicio.reserving.BornhuetterFerguson)  
The Bornhuetter-Ferguson method: each origin's latest value plus the

[reserving.Benktander](reserving.Benktander.md#prospicio.reserving.Benktander)  
The Benktander (iterated Bornhuetter-Ferguson) method: starting from

[reserving.CapeCod](reserving.CapeCod.md#prospicio.reserving.CapeCod)  
The Cape Cod (Stanard-Bühlmann) method: Bornhuetter-Ferguson with each

[reserving.ExpectedLossFit](reserving.ExpectedLossFit.md#prospicio.reserving.ExpectedLossFit)  
A fitted expected-loss method (`ExpectedLoss`,

[reserving.CapeCodFit](reserving.CapeCodFit.md#prospicio.reserving.CapeCodFit)  
A fitted Cape Cod of every segment of a triangle column: the fields of

[reserving.OdpBootstrap](reserving.OdpBootstrap.md#prospicio.reserving.OdpBootstrap)  
Over-dispersed Poisson bootstrap of the chain ladder (England and

[reserving.OdpBootstrapFit](reserving.OdpBootstrapFit.md#prospicio.reserving.OdpBootstrapFit)  
A fitted ODP bootstrap of every segment.

[reserving.MackBootstrap](reserving.MackBootstrap.md#prospicio.reserving.MackBootstrap)  
Mack's bootstrap for the lifetime and one-year views (England, Verrall

[reserving.MackBootstrapFit](reserving.MackBootstrapFit.md#prospicio.reserving.MackBootstrapFit)  
A fitted bootstrap of Mack's model, the lifetime view, of every

[reserving.OneYearFit](reserving.OneYearFit.md#prospicio.reserving.OneYearFit)  
The simulated one-year view of every segment, from

[reserving.ClarkLdf](reserving.ClarkLdf.md#prospicio.reserving.ClarkLdf)  
Clark's LDF method (Clark 2003), as R ChainLadder's `ClarkLDF`: each

[reserving.ClarkCapeCod](reserving.ClarkCapeCod.md#prospicio.reserving.ClarkCapeCod)  
Clark's Cape Cod method (Clark 2003), as R ChainLadder's

[reserving.ClarkFit](reserving.ClarkFit.md#prospicio.reserving.ClarkFit)  
A fitted Clark LDF or Cape Cod model of every segment of a triangle


## Risk measures


Distortion risk measures, and capital allocation to components.


[risk.Distortion](risk.Distortion.md#prospicio.risk.Distortion)  
A distortion risk measure: `rho(X) = integral of g(S(x)) dx` for a

[risk.allocate()](risk.allocate.md#prospicio.risk.allocate)  
Allocates a distortion risk measure of the total to the components.

[risk.capital()](risk.capital.md#prospicio.risk.capital)  
Allocates the distortion risk measure of a portfolio's total to its

[risk.entropic()](risk.entropic.md#prospicio.risk.entropic)  
Entropic risk measure `(1 / theta) log E[exp(theta X)]`: the certainty

[risk.esscher()](risk.esscher.md#prospicio.risk.esscher)  
Esscher premium `E[X exp(h X)] / E[exp(h X)]`: the mean after tilting

[risk.marginal_expected_shortfall()](risk.marginal_expected_shortfall.md#prospicio.risk.marginal_expected_shortfall)  
Marginal expected shortfall of each component at level `p`: its mean

[risk.covar()](risk.covar.md#prospicio.risk.covar)  
CoVaR of a component: the total's VaR at level `q` over the

[risk.esscher_allocation()](risk.esscher_allocation.md#prospicio.risk.esscher_allocation)  
Esscher allocation: each component's mean under the Esscher transform

[risk.Allocation](risk.Allocation.md#prospicio.risk.Allocation)  
Capital allocation of a distortion risk measure, from `capital`.


## Dependence


Copulas, and reordering existing draws to a target correlation.


[risk.GaussianCopula](risk.GaussianCopula.md#prospicio.risk.GaussianCopula)  
The Gaussian copula with correlation matrix `correlation`.

[risk.StudentTCopula](risk.StudentTCopula.md#prospicio.risk.StudentTCopula)  
The Student t copula with correlation matrix `correlation` and `nu`

[risk.ArchimedeanCopula](risk.ArchimedeanCopula.md#prospicio.risk.ArchimedeanCopula)  
An exchangeable Archimedean copula: Clayton, Gumbel, Frank or Joe.

[risk.simulate()](risk.simulate.md#prospicio.risk.simulate)  
Simulates marginals joined by a copula.

[risk.iman_conover()](risk.iman_conover.md#prospicio.risk.iman_conover)  
Reorders each component's draws to a target correlation (Iman-Conover).


## Extreme value tails


Generalized Pareto tails over a threshold, beyond the draws.


[risk.Gpd](risk.Gpd.md#prospicio.risk.Gpd)  
The generalized Pareto distribution, as SciPy's

[risk.PotTail](risk.PotTail.md#prospicio.risk.PotTail)  
A peaks-over-threshold tail: draws above a threshold modelled by a

[risk.mean_excess()](risk.mean_excess.md#prospicio.risk.mean_excess)  
The empirical mean-excess function `e(u) = E[X - u | X > u]` at each

[risk.hill()](risk.hill.md#prospicio.risk.hill)  
Hill estimates of the tail index `xi` (`1 / alpha`) from the `k`
