Skip to main content

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


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.4.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

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

actstats-0.1.0.4-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file actstats-0.1.0.4.tar.gz.

File metadata

  • Download URL: actstats-0.1.0.4.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for actstats-0.1.0.4.tar.gz
Algorithm Hash digest
SHA256 d96b6e9709590735cd17e1c31ad6a3c981e4be5a4d40b4ce15d7e978d74bef14
MD5 646e169cee723ccf9328cf7a40b31c83
BLAKE2b-256 b3d3a39daf038585aafb04a8ae5536b8022f781d2440bc082d3ba8c1b3a163aa

See more details on using hashes here.

File details

Details for the file actstats-0.1.0.4-py3-none-any.whl.

File metadata

  • Download URL: actstats-0.1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for actstats-0.1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5ddbc5ab003ca8b1f1a99bb8a2c9faffb31daed9c1b991f5da5aac3e9ef873be
MD5 9e26d0de7aacc827a015892b8c1122d9
BLAKE2b-256 e959816641a38465c931e6eef4bfb7cfd13515865654966843ff1327f44e8d14

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