Of the Actuary, By the Actuary, For the Actuary: Unifying Statistical Libraries with Actuarial Conventions
Project description
actuarial_stats
Of the Actuary, By the Actuary, For the Actuary
actstats is a Python library unifying Statistical Libraries with Actuarial Conventions
🔧 Installation
pip install actstats
🔢 ActuarialDistribution class
| Distribution | Actuarial Parameters | SciPy Equivalent |
|---|---|---|
lognormal |
(μ, σ) | lognorm(s=σ, scale=exp(μ)) |
gamma |
(α, θ) | gamma(a=α, scale=θ) |
weibull |
(α, β) | weibull_min(c=α, scale=β) |
pareto |
(α, θ) | pareto(b=α, scale=θ) |
beta |
(α, β) | beta(a=α, b=β) |
poisson |
(λ) | poisson(mu=λ) |
negative_binomial |
(r, p) | nbinom(n=r, p=p) |
normal |
(μ, σ) | norm(loc=μ, scale=σ) |
logistic |
(μ, σ) | logistic(loc=μ, scale=σ) |
exponential |
(θ) | expon(scale=θ) |
uniform |
(a, b) | uniform(loc=a, scale=b−a) |
nonhomogeneous_poisson |
(λ₀, α, ϕ, T) | custom NHPPDistribution |
📝 Sample code
######################################
##### All distribution testing########
######################################
# Test the lognormal distribution
lognormal_dist = actuarial.lognormal
lognormal_dist = actuarial.lognormal(0.5, 0.2)
lognormal_dist_sample = lognormal_dist.rvs(size=10000)
lognormal_dist_sample = lognormal_dist.np_rvs(size=10000)
lognormal_dist_sample.mean()
lognormal_dist_sample.std()
actuarial.lognormal.fit(lognormal_dist_sample)
# Test the gamma distribution
gamma_dist = actuarial.gamma
gamma_dist = actuarial.gamma(2, 1)
gamma_dist_sample = gamma_dist.rvs(size=10000)
gamma_dist_sample = gamma_dist.np_rvs(size=10000)
gamma_dist_sample.mean()
gamma_dist_sample.std()
actuarial.gamma.fit(gamma_dist_sample)
# Test the Weibull distribution
weibull_dist = actuarial.weibull
weibull_dist = actuarial.weibull(1.5, 1)
weibull_dist_sample = weibull_dist.rvs(size=10000)
weibull_dist_sample = weibull_dist.np_rvs(size=10000)
weibull_dist_sample.mean()
weibull_dist_sample.std()
actuarial.weibull.fit(weibull_dist_sample)
# Test the Pareto distribution
pareto_dist = actuarial.pareto
pareto_dist = actuarial.pareto(3, 1)
pareto_dist_sample = pareto_dist.rvs(size=10000)
pareto_dist_sample = pareto_dist.np_rvs(size=10000)
pareto_dist_sample.mean()
pareto_dist_sample.std()
actuarial.pareto.fit(pareto_dist_sample)
# Test the beta distribution
beta_dist = actuarial.beta
beta_dist = actuarial.beta(1, 2)
beta_dist_sample = beta_dist.rvs(size=10000)
beta_dist_sample = beta_dist.np_rvs(size=10000)
beta_dist_sample.mean()
beta_dist_sample.std()
actuarial.beta.fit(beta_dist_sample)
# Test the Poisson distribution
poisson_dist = actuarial.poisson
poisson_dist = actuarial.poisson(5,)
poisson_dist_sample = poisson_dist.rvs(size=10000)
poisson_dist_sample = poisson_dist.np_rvs(size=10000)
poisson_dist_sample.mean()
poisson_dist_sample.std()
actuarial.poisson.fit(poisson_dist_sample)
# Test the negative_binomial distribution
negative_binomial_dist = actuarial.negative_binomial
negative_binomial_dist = actuarial.negative_binomial(5, 0.5)
negative_binomial_dist_sample = negative_binomial_dist.rvs(size=10000)
negative_binomial_dist_sample = negative_binomial_dist.np_rvs(size=10000)
negative_binomial_dist_sample.mean()
negative_binomial_dist_sample.std()
actuarial.negative_binomial.fit(negative_binomial_dist_sample)
# Test the normal distribution
normal_dist = actuarial.normal
normal_dist = actuarial.normal(0, 1)
normal_dist_sample = normal_dist.rvs(size=10000)
normal_dist_sample = normal_dist.np_rvs(size=10000)
normal_dist_sample.mean()
normal_dist_sample.std()
actuarial.normal.fit(normal_dist_sample)
# Test the logistic distribution
logistic_dist = actuarial.logistic
logistic_dist = actuarial.logistic(0, 1)
logistic_dist_sample = logistic_dist.rvs(size=10000)
logistic_dist_sample = logistic_dist.np_rvs(size=10000)
logistic_dist_sample.mean()
logistic_dist_sample.std()
actuarial.logistic.fit(logistic_dist_sample)
# Test the exponential distribution
exponential_dist = actuarial.exponential
exponential_dist = actuarial.exponential(2)
exponential_dist_sample = exponential_dist.rvs(size=10000)
exponential_dist_sample = exponential_dist.np_rvs(size=10000)
exponential_dist_sample.mean()
exponential_dist_sample.std()
actuarial.exponential.fit(exponential_dist_sample)
# Test the uniform distribution
uniform_dist = actuarial.uniform
uniform_dist = actuarial.uniform(0, 1)
uniform_dist_sample = uniform_dist.rvs(size=10000)
uniform_dist_sample = uniform_dist.np_rvs(size=10000)
uniform_dist_sample.mean()
uniform_dist_sample.std()
actuarial.uniform.fit(uniform_dist_sample)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
actstats-0.1.0.1.tar.gz
(10.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file actstats-0.1.0.1.tar.gz.
File metadata
- Download URL: actstats-0.1.0.1.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b52f54fe97d9803a37817a03ea338f37d4e60387cfdd1718166832c809e62600
|
|
| MD5 |
d7322561dd369e815f32a7c7b88b5638
|
|
| BLAKE2b-256 |
a21be7a8597bea78d6f1bc64eae26aec05abe501e229fe695926a4de1f47a947
|
File details
Details for the file actstats-0.1.0.1-py3-none-any.whl.
File metadata
- Download URL: actstats-0.1.0.1-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
550d5447ffc2b55703021f32eabfb40ac3270951a0189aed028ebd8080b67a91
|
|
| MD5 |
1066f50730000a0cf698419c37570380
|
|
| BLAKE2b-256 |
69489880880fc3b013d184d56b6db077ab4631c6215f6d9c60d7e2f25cd334d6
|