Skip to main content

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.

Metadata

Release files for actudist 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for actudist 0.1.0
File Size Uploaded
actudist-0.1.0.tar.gz 42.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for actudist 0.1.0
File Interpreter ABI Platform
actudist-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 87.6 kB

Release files / actudist-0.1.0.tar.gz

Download URL actudist-0.1.0.tar.gz
Size 42.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9cbd05de53d469a3641543186e774ebe1fe3b5cadabca60afab67e16cce0816d
BLAKE2b-256 checksum
How to use checksums
ffa5a9257d003f098e35166c063a5b010c58aa1b1b270c36c77d26633bdd6953
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / actudist-0.1.0-py3-none-any.whl

Download URL actudist-0.1.0-py3-none-any.whl
Size 45.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a6af7d9ef918a25771c0c76c4ae222c17d94a89f7410ef9ea78494f6df2b87bd
BLAKE2b-256 checksum
How to use checksums
f54dc09af221c9f835fec6500c253fb28339a1c946a97e320dc7fd8dc7174dc6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page