bayes-splicing Python package for Bayesian inference of splicing distributions
This package implements an efficient Sequential Monte Carlo Sampling (SMC) algorithm. Splicing models, also called composite models, are fitted to the data and compared using Bayesian statistics tools
This package is the result of my paper "Sequential Monte Carlo Sampler to fit and compare insurance loss models". To install simply run pip install bayes-splicing.
For example, imagine we have a sample of insurance losses and we would like to fit a composite model based on the exponential and Pareto distributions.
import bayes_splicing as bs
import pandas as pd
import numpy as np
# Definition of the exponential-Pareto composite model
f1, f2 = bs.loss_model("Exp", ["lambda"]), bs.loss_model("Pareto-Tail", ["alpha"])
# Type of composite models include "disjoint", "simple" and "continuous"
model_type = "continuous"
f = bs.spliced_loss_model(f1, f2, model_type, thresh_name="gamma")
# We will fit the above model to the famous danish fire insurance data set
# danish = pd.read_csv("data/danish.csv").x
# X = danish.values
parms_true = np.array([1 / 3, 2, 1])
X = f.sample(parms_true, 1000)
# Prior distributions over the model parameters
lambda_prior = bs.prior_model('gamma','lambda', 1, 1)
alpha_prior = bs.prior_model('gamma','alpha',1, 1)
gamma_prior = bs.prior_model('uniform','gamma',min(X), max(X))
prior_spliced_model = bs.independent_priors([lambda_prior,alpha_prior, gamma_prior])
# The smc function deliver the trace, the log marginal likelihood along with some information criteria
popSize = 2000
trace, log_marg, DIC, WAIC = bs.smc(X, f, popSize, prior_spliced_model)
# The posterior distributions
bs.posterior_plots(f, trace)
# The trace plot
bs.trace_plots(f, trace)
# The quantile-quantile plot
f.set_ppf()
bs.qq_plot(X, f, trace.mean().values)
Metadata
Release files for bayes-splicing 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| bayes-splicing-0.0.5.tar.gz | 17.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bayes_splicing-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.6 kB
Release files / bayes-splicing-0.0.5.tar.gz
| Download URL | bayes-splicing-0.0.5.tar.gz |
|---|---|
| Size | 17.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3c243ab4f006aec078e706eb1a834721eab48ff480311e7a8c1c118304eab39
|
|
BLAKE2b-256 checksum How to use checksums |
bcfc028885b7f6d6dea6e523e1998ebb0bcc1452221473760009b4bd2bb295e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.1.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
|
Release files / bayes_splicing-0.0.5-py3-none-any.whl
| Download URL | bayes_splicing-0.0.5-py3-none-any.whl |
|---|---|
| Size | 19.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4fbc4ebaff153c08771aa161bed906bb0a2bbea471c363f3f084587fc0764eb2
|
|
BLAKE2b-256 checksum How to use checksums |
8a5310bd94e976475faa04d36592f553cbc9a0393332c5831c0989a5b57fc74c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.1.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
|
Security for bayes-splicing 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.