Skip to main content

This package aims to compute the overlap integral between two probability density functions.

Project description

Overlap Integral Project

This project focuses on calculating the overlap integral between two probability density functions (PDFs). The overlap integral is a measure of similarity between two distributions and is used in various fields such as statistics, data science, etc. The code and data files in this project are designed to perform these calculations efficiently and accurately.

Project Structure

  • src/overlap_integral/: Contains the core Python code for calculating the overlap integral.
  • tests/: Includes the test scripts to validate the functionality of the code.
  • README.md: Provides an overview and instructions for the project.
  • pyproject.toml: Configuration file for the project dependencies and metadata.

Installation

To install the package using pip, run the following command:

pip install overlap-integral

Importing the Class: Import the OverlapIntegral class in your Python script.

```python
from overlap_integral.overlap_integral import OverlapIntegral
```

Usage Example: Provide a simple example to demonstrate how to use the OverlapIntegral class.

```python

        import numpy as np
        from overlap_integral.overlap_integral import OverlapIntegral

        import plotly.io as pio
        pio.kaleido.scope.default_format = "png"


        def main():
            np.random.seed(3)  # Set random seed for reproducibility

            metrics = OverlapIntegral()

            # Generate or load data
            data1 = np.random.normal(loc=30, scale=1, size=1000)
            data2 = np.random.normal(loc=30, scale=1.2, size=1000)

            # Choose PDF method: 'kde' or 'gaussian'
            pdf_method = 'gaussian'

            # Get PDFs
            pdf_1 = metrics.get_pdf(data1, method=pdf_method)
            pdf_2 = metrics.get_pdf(data2, method=pdf_method)

            # Calculate overlap integral
            lower_limit = min(np.min(data1), np.min(data2)) - 12 * max(np.std(data1), np.std(data2))
            upper_limit = max(np.max(data1), np.max(data2)) + 12 * max(np.std(data1), np.std(data2))
            integral, error = metrics.overlap_integral(pdf_1, pdf_2, lower_limit, upper_limit)

            print(f"Overlap integral: {integral}")
            print(f"Estimated error: {error}")

            # Plot distributions
            fig = metrics.plot_distributions(pdf_1, pdf_2, integral, error, x_range=(lower_limit, upper_limit))
            fig.write_image("overlap_plot.png")
            ##fig.show()

        if __name__ == '__main__':
            main()
```

Requirements

  • Python 3.11 or higher
  • NumPy
  • SciPy
  • Plotly
  • Kaleido

License

This project is licensed under the MIT License.

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

overlap_integral-0.1.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

overlap_integral-0.1.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file overlap_integral-0.1.2.tar.gz.

File metadata

  • Download URL: overlap_integral-0.1.2.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for overlap_integral-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c2f24c73139afc0c5d13e61707551bf70056c05cd14a8e2f6e7019312a0a191b
MD5 06f55d6b4f611e3e1c41c063043a9032
BLAKE2b-256 08c39a7e6bbca7aa6f89445f295377ecd863cbd0713e17c7375384917722044e

See more details on using hashes here.

File details

Details for the file overlap_integral-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: overlap_integral-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.3 Linux/5.15.167.4-microsoft-standard-WSL2

File hashes

Hashes for overlap_integral-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 aa3459026fe8bb41efef2506522c2f6ad1a4912b423572dcea27bda636d89a75
MD5 9dafdec7b547ffc8f50e0061d85d3623
BLAKE2b-256 7bb2301b0e20659205ce1a4abaa2b52dbba88e4eced92d0768d11ffa7fe426e1

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