Skip to main content

equibin

CI PyPI

2D equal-probability binning for statistical data analysis.

Partitions a 2D dataset into bins that each contain approximately the same number of points. At each step the dimension with the highest variance is split at its median, recursively, until the target number of bins is reached. The resulting bins are axis-aligned rectangles that adapt to the local density of the data.

This implements the multivariate probability binning algorithm described in:

Roederer, M., Moore, W., Treister, A., Hardy, R. R. & Herzenberg, L. A. (2001). Probability binning comparison: a metric for quantitating multivariate distribution differences. Cytometry 45(1):47–55. https://doi.org/10.1002/1097-0320(20010901)45:1<47::AID-CYTO1143>3.0.CO;2-A

Installation

pip install equibin

Usage

import numpy as np
from equibin import bin_2d, plot_bins, save_bins

rng = np.random.default_rng(0)
x = rng.uniform(0, 10, 5000)
y = rng.uniform(0, 10, 5000)

result = bin_2d(x, y, n_bins=128)

print(len(result))          # 128
print(result.counts.sum())  # 5000
print(result.bins[0])       # (xmin, xmax, ymin, ymax)

Restrict binning to a region of interest:

result = bin_2d(x, y, n_bins=256, xmin=2.5, xmax=20, ymin=0.25, ymax=10)

Plot the bins overlaid on the data:

plot_bins(result, x, y, title="Equal-probability bins", xlim=(0, 10), ylim=(0, 10))

Save bin boundaries to a text file (one line per bin: xlo xhi ylo yhi label):

save_bins(result, "bins.txt", label_prefix="run_")

Authors

License

GPL-2.0-only

Metadata

Release files for equibin 0.1.4

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

Source distribution (sdist)

Source distribution for equibin 0.1.4
File Size Uploaded Provenance Actions
equibin-0.1.4.tar.gz 209.7 kB Without provenance Details for equibin-0.1.4.tar.gz

Built distribution (wheel)

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

Total release size: 214.7 kB

Release files / equibin-0.1.4.tar.gz

Download URL equibin-0.1.4.tar.gz
Size 209.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ed92929cce8dbee20b291684c5cc88e6d86695d4dc4efbd44f97dfb0ec22f586
BLAKE2b-256 checksum
How to use checksums
2f5ddef583c53d39040349dc16ef383c114d267e76a2081fae4ad9a0116fe3d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.5

Release files / equibin-0.1.4-py3-none-any.whl

Download URL equibin-0.1.4-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6ca778ac05faeb88c249a39bc2d04d9a1ea02d6f0144bd5b8b429643478446db
BLAKE2b-256 checksum
How to use checksums
0297f25d2d02381f8613f3f255c104849d75a7b1a703566bb416a380cd1d5cb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.5

Security for equibin 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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