Skip to main content

Actuarial probability distributions for P&C loss modeling: severity and frequency families, MLE fitting, layer statistics, goodness-of-fit.

Project description

PyPI version Python 3.10+ License: MIT

actudist

Python library for P&C loss distributions. Severity and frequency families follow the parameterizations in Klugman, Loss Models. Every severity distribution exposes layer statistics (LEV, excess pure premium, ILF) as methods. MLE accepts right-censored and one- or two-sided truncated samples.

Installation

pip install actudist

From source:

git clone https://github.com/CosmikArt/actudist.git
cd actudist
pip install -e ".[dev]"

Quickstart

import numpy as np
from actudist import DistributionFitter, GoodnessOfFit
from actudist.severity.lognormal import Lognormal

rng = np.random.default_rng(42)
claims = Lognormal(mu=8.0, sigma=1.2).rvs(size=2000, random_state=rng)

fit = Lognormal()
fit.mle_fit(claims)
print(f"mu={fit.mu:.3f}  sigma={fit.sigma:.3f}")
print(f"AIC={fit.aic(claims):.1f}  BIC={fit.bic(claims):.1f}")
print(f"LEV(50000)={fit.limited_expected_value(50_000):.1f}")
print(f"EPP(50000)={fit.excess_pure_premium(50_000):.1f}")

fitter = DistributionFitter(["Lognormal", "Pareto", "Weibull"])
ranking = fitter.fit_and_rank(claims, criterion="aic")
for row in ranking:
    print(f"{row['name']:12s}  aic={row['aic']:.1f}")

gof = GoodnessOfFit(fit, claims)
result = gof.ks_test(n_boot=200, random_state=42)
print(f"KS stat={result['statistic']:.4f}  p={result['p_value']:.3f}")

Modules

  • actudist.severity: 13 continuous distributions (Exponential, Pareto, Lognormal, Weibull, Gamma, Burr XII, Log-Logistic, Paralogistic and its inverse, Inverse Gaussian, Transformed and Inverse Transformed Gamma, Transformed Beta).
  • actudist.frequency: Poisson, Binomial, Geometric, Negative Binomial, ZIP, ZINB.
  • actudist.fitting: registries and DistributionFitter for AIC/BIC ranking.
  • actudist.gof: KS and Anderson-Darling with parametric-bootstrap p-values, chi-squared, PP and QQ plots.
  • actudist.layers: excess pure premium, ILF, finite-layer expected loss.

profile_likelihood_ci lives on the base class; call it on any fitted instance.

References

  • Klugman, S. A., Panjer, H. H., & Willmot, G. E. Loss Models: From Data to Decisions (5th ed.). Wiley.
  • Hogg, R. V. & Klugman, S. A. Loss Distributions. Wiley.
  • Society of Actuaries. Exam STAM / FAM syllabus and study materials.

Contributing

Run pytest before sending a PR.

Author

Isaac López

MIT License. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

actudist-0.1.0.tar.gz (42.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

actudist-0.1.0-py3-none-any.whl (45.6 kB view details)

Uploaded Python 3

File details

Details for the file actudist-0.1.0.tar.gz.

File metadata

  • Download URL: actudist-0.1.0.tar.gz
  • Upload date:
  • Size: 42.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for actudist-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9cbd05de53d469a3641543186e774ebe1fe3b5cadabca60afab67e16cce0816d
MD5 45bcc499a4b57a7eb56a762ea916b91f
BLAKE2b-256 ffa5a9257d003f098e35166c063a5b010c58aa1b1b270c36c77d26633bdd6953

See more details on using hashes here.

File details

Details for the file actudist-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: actudist-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 45.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for actudist-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6af7d9ef918a25771c0c76c4ae222c17d94a89f7410ef9ea78494f6df2b87bd
MD5 3883757caa97fa63a7fcfe8cbc6c20c3
BLAKE2b-256 f54dc09af221c9f835fec6500c253fb28339a1c946a97e320dc7fd8dc7174dc6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page