Skip to main content

A Python package for the Four-Parameter Beta Distribution and Likelihood-Based Estimation

Project description

beta4dist

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: Generate random samples from the four-parameter Beta distribution.
  • Parameter Estimation: Perform likelihood-based estimation for fitting the distribution to observed data.
  • Robustness: Ensure that parameter estimates obey the natural restrictions of the distribution.
  • Flexible Usage: Suitable for a wide range of applications, including statistical modeling and simulation.

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 .

Running Tests

To ensure everything is working correctly, you can run the tests using pytest:

  1. Clone the repository or install the package.

  2. Install the necessary dependencies (if not already done).

  3. Run the tests:

pytest

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"

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, Pritee Sharma

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

beta4dist-0.2.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

beta4dist-0.2.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file beta4dist-0.2.0.tar.gz.

File metadata

  • Download URL: beta4dist-0.2.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for beta4dist-0.2.0.tar.gz
Algorithm Hash digest
SHA256 dcfc3c729168959ef6acdfb852910a46f074e0e03022ee11968c78050f5510a7
MD5 0e0c07f25eba1dab17ae0aed0258deb1
BLAKE2b-256 c40523070ef2a25f0271bbfc03c30c804600a9eae851a302cc21f0171980f4cb

See more details on using hashes here.

File details

Details for the file beta4dist-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: beta4dist-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for beta4dist-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 487ddbba9e9360589d67942576012579d8708526200f765b5856376987e0eee0
MD5 da19e281dcbcf1c0ed8fdf92d90083d4
BLAKE2b-256 1d7317b12e303bd267dc995b36b5230dde0db9f53a6e10c89adabd156d302990

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