Skip to main content

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

Project description

Overlap Integral Package

PyPI version

This project focuses on calculating the overlap integral between two probability density functions (PDFs):

Overlap Integral

The overlap integral, also known as coefficient of overlap, is a measure of similarity between two PDFs (f(x) and g(x)) and is used in various fields such as statistics, data science, etc. Additionally, it corresponds to the common area under the two PDFs. The package provides efficient methods for estimating PDFs using kernel density estimation (KDE, a non-parametric way) or Gaussian distributions.

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

            overlap_integral_instance = OverlapIntegral()

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

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

            # Get PDFs
            pdf_1 = overlap_integral_instance.get_pdf(data1, pdf_type=function_type)
            pdf_2 = overlap_integral_instance.get_pdf(data2, pdf_type=function_type)

            # 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 = overlap_integral_instance.overlap_integral(pdf_1, pdf_2, lower_limit, upper_limit)

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

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

            print(f"Everything worked!")

        if __name__ == '__main__':
            main()

```

Requirements

  • python >=3.12.3

Dependencies

  • numpy
  • scipy
  • plotly
  • kaleido
  • pytest

License

This project is licensed under the MIT License.

Contribution

Feel free to submit issues or pull requests. Your contributions are welcome!

Contact

For questions or suggestions, please contact kiatakimatheus@gmail.com

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.7.tar.gz (3.7 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.7-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: overlap_integral-0.1.7.tar.gz
  • Upload date:
  • Size: 3.7 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.7.tar.gz
Algorithm Hash digest
SHA256 62a13383aa940dfae592340535f71d573ab62032fa1c646277b302c0d414f430
MD5 f6dd563b93aec44a65627d76c4fc8af6
BLAKE2b-256 18746d9b5d12d1ad295fc7617d4c1f8f4171dc9935f38546c6a17613c26a6377

See more details on using hashes here.

File details

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

File metadata

  • Download URL: overlap_integral-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 4.3 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8b85e55297992d54521e11da96f8408c83dbe90cec525a37ee835872e4687346
MD5 98cf41fbbd939a874c528028bf19c39a
BLAKE2b-256 1fdd5d5ea3cb0d8eabb57d19c9b7617d97563aec2cc51765eb06f09612a943bc

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