Skip to main content

beta4dist

PyPI version License: MIT

beta4dist is a Python package designed for working with the four-parameter Beta distribution and implementing likelihood-based estimation methods for its parameters. It allows for sampling, parameter fitting, and likelihood-based estimation (LBE) using a flexible four-parameter formulation of the Beta distribution.

Table of Contents

Description

The goal of beta4dist is to provide an easy-to-use and efficient interface for working with the four-parameter Beta distribution. This package supports the following features:

  • Sampling from the four-parameter Beta distribution.
  • Fitting the distribution to data using likelihood-based estimation (LBE).
  • Implementing various parameter inference techniques for reliable statistical modeling.

The four-parameter Beta distribution extends the standard Beta distribution by introducing location parameters, providing additional flexibility for modeling data confined to finite intervals with skewness and kurtosis. This makes it especially useful in fields like hydrology, environmental science, and reliability engineering.


Features

  • Sampling from the four-parameter Beta distribution
  • Parameter estimation using likelihood-based methods
  • Diagnostic summaries for goodness-of-fit
  • Fully tested with Pytest
  • Applicable in real-world settings involving environmental and reliability data

Requirements

  • Python ≥ 3.7
  • numpy
  • scipy

Installation

To install beta4dist, you can use pip from PyPI:

To install the package for the first time:

pip install beta4dist

To upgrade to the latest version:

pip install --upgrade beta4dist

2. Clone the repository from GitHub:

If you prefer to work with the latest code or contribute, you can clone the repository directly from GitHub:

git clone https://github.com/soham39039820/beta4dist.git

After cloning, navigate to the project directory and install it:

cd beta4dist
pip install .

Generate Samples from the Four-Parameter Beta Distribution

You can generate random samples from the four-parameter Beta distribution using the r4beta function:

import beta4dist
from beta4dist.distribution import r4beta

# Define parameters
theta1, theta2 = 0, 1
alpha1, alpha2 = 2.5, 3.0

# Generate 100 samples
samples = r4beta(n=100, theta1=theta1, theta2=theta2, alpha1=alpha1, alpha2=alpha2)

print(samples)

Fit the Four-Parameter Beta Distribution Using Likelihood-Based Estimation

The LBE4beta function allows you to obtain the likelihood-based estimators of the four-parameter Beta distribution to your data. The fit4beta offers an end-to-end interface to fit the distribution to real data, with automatic handling of boundary estimation, internal consistency checks, and feasibility diagnostics.

from beta4dist.beta4_model import LBE4beta, fit4beta

estimates = LBE4beta(data)
print("Estimated Parameters:", estimates)

# Fit and display model diagnostics
fit_results = fit4beta(data)
print("Model Fit Summary:", fit_results)

Example Test Cases

beta4dist includes pre-defined test cases to ensure that the model behaves as expected. You can run these tests using pytest.

Install pytest if you haven't already:

pip install pytest

Run test using:

pytest

Windows users — if pytest is not recognized, try:

"C:\Users\soham\AppData\Roaming\Python\Python310\Scripts\pytest.exe"

Version

The current version of beta4dist is 0.3.3.

To check the version in Python, use the following code:

import beta4dist
print(beta4dist.__version__)

Licensing

beta4dist is licensed under the MIT License. See the LICENSE file for more details.

References

For more information on the four-parameter Beta distribution and its applications, please refer to the following publication:

  • Paper Title: beta4dist: A Python Package for the Four-Parameter Beta Distribution and Likelihood-Based Estimation
  • Authors: Soham Ghosh, Sujay Mukhoti, Abhirup Banerjee

Metadata

Release files for beta4dist 0.3.3

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

Source distribution (sdist)

Source distribution for beta4dist 0.3.3
File Size Uploaded
beta4dist-0.3.3.tar.gz 9.2 kB Details

Built distribution (wheel)

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

Total release size: 16.4 kB

Release files / beta4dist-0.3.3.tar.gz

Download URL beta4dist-0.3.3.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
699524cdbbbd86812bbdbe69dd05de3293b898fd0907c151db9441a59f114a60
BLAKE2b-256 checksum
How to use checksums
ab6d0030b72f0abe78ba424a269a7c74a89a8ef461b6896e9dc4cfde9e69ab9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.4

Release files / beta4dist-0.3.3-py3-none-any.whl

Download URL beta4dist-0.3.3-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5181f09faf8fb8db1b36b46f4e5bf8bd6fda2ff4dbe14fb7b97d40914ad825f5
BLAKE2b-256 checksum
How to use checksums
23f40d1ff42edef9358feab570bb77d5d9c88f715d9203284516619fd08e6981
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

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