Skip to main content

Cython-accelerated MDL histogram density estimation with dynamic programming, implementing Kontkanen & Myllymaki's algorithm (JMLR 2007).

Project description

Upload Python Package Python application test Python application bad runner for macos-latest Python application bad runner for windows-11-arm

MDL Optimal Histogram Density Estimation

This package provides a Cython-accelerated implementation of the Minimum Description Length (MDL) optimal histogram density estimation algorithm from Kontkanen & Myllymaki (2007). It uses information-theoretic principles to automatically determine optimal variable-width bins for density estimation.

Freedman-Diaconis vs. MDL-Optimization

Features

  • MDL Principle: Uses stochastic complexity for model selection
  • Dynamic Programming: Efficient O(E²·K_max) optimization (cache parametric complexity computation, speed up)
  • Score of each Kth bin: The score of each bin is returned to understand the performance of different properties of the same dataset.
  • Variable-Width Bins: Adapts to data density variations
  • Automatic Bin Count: No manual parameter tuning required (except maximum bin count to consider $K_{max}$ and data resolution $\epsilon$)
  • Cython Acceleration: Critical operations compiled to C

Installation

You can install the package using pip:

pip install MDL-Density-Histogram

Alternatively, you can install it from source by cloning the repository and running:

# From project root directory
pip install .

Requires:

  • Python 3.11+
  • NumPy
  • Cython
  • C compiler (GCC/Clang/MSVC)

Usage Example

import numpy as np
from mdl_density_hist import mdl_optimal_histogram

# Generate sample data
data = np.random.normal(0, 1, 1000)

# Compute optimal histogram
cut_points, K_scores = mdl_optimal_histogram(data, epsilon=0.1)

# Print score of each bin
print(f"K_scores: {K_scores}")

# Visualize result
import matplotlib.pyplot as plt
plt.hist(data, bins=cut_points, density=True)
plt.title('MDL Optimal Histogram')
plt.show()

Parameters

  • data: Input array (1D numpy array)
  • epsilon: Quantization precision (default: 0.1)
  • K_max: Maximum number of bins (default: 10)

Algorithm Highlights

  • Uses Ramanujan's factorial approximation for efficient parametric complexity
  • Cache parameteric complexity to speed up computation

Paper Citation

Kontkanen, P., & Myllymäki, P. (2007).
MDL Histogram Density Estimation
Journal of Machine Learning Research 8 (2007) PDF

License

Apache 2.0 License - See LICENSE file

Project Structure

src/
├── mdl_density_hist/
│   ├── __init__.py
│   └── mdl_hist.pyx  # Core Cython implementation
└── pyproject.toml

Performance Notes

  • Precomputed parametric complexity using dynamic programming
  • Memory-optimized array operations via NumPy
  • Candidate cut point pruning for reduced search space

For implementation details, see the paper and inline code comments.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

mdl_density_histogram-1.1.1-cp313-cp313-win_amd64.whl (85.9 kB view details)

Uploaded CPython 3.13Windows x86-64

mdl_density_histogram-1.1.1-cp313-cp313-musllinux_1_2_x86_64.whl (151.3 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

mdl_density_histogram-1.1.1-cp313-cp313-musllinux_1_2_aarch64.whl (157.6 kB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ ARM64

mdl_density_histogram-1.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (150.4 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

mdl_density_histogram-1.1.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (155.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

mdl_density_histogram-1.1.1-cp313-cp313-macosx_10_13_x86_64.whl (95.0 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

mdl_density_histogram-1.1.1-cp312-cp312-win_amd64.whl (86.1 kB view details)

Uploaded CPython 3.12Windows x86-64

mdl_density_histogram-1.1.1-cp312-cp312-musllinux_1_2_x86_64.whl (151.9 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

mdl_density_histogram-1.1.1-cp312-cp312-musllinux_1_2_aarch64.whl (157.6 kB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

mdl_density_histogram-1.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (151.0 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

mdl_density_histogram-1.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (156.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

mdl_density_histogram-1.1.1-cp312-cp312-macosx_10_13_x86_64.whl (94.9 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

mdl_density_histogram-1.1.1-cp311-cp311-win_amd64.whl (86.5 kB view details)

Uploaded CPython 3.11Windows x86-64

mdl_density_histogram-1.1.1-cp311-cp311-musllinux_1_2_x86_64.whl (149.3 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

mdl_density_histogram-1.1.1-cp311-cp311-musllinux_1_2_aarch64.whl (159.4 kB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ ARM64

mdl_density_histogram-1.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (148.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

mdl_density_histogram-1.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (157.9 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

mdl_density_histogram-1.1.1-cp311-cp311-macosx_10_9_x86_64.whl (93.7 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

Details for the file mdl_density_histogram-1.1.1-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 64d0bc17d6e43864bd3478816c40b4a9d4933c9c4dfc3748a091b587937123bd
MD5 135742a677d6ce966697c290df38e178
BLAKE2b-256 69b3477a602323d510cd6b47afa1687635faff742bedf582254bbd29036a9ff1

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp313-cp313-win_amd64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 85dba5e86c7eccf78cfb5ca0d1d25ce6d536a1513b96aa48287469e7d0c171f9
MD5 4c59ffc290740284ef58e82e7ea1988f
BLAKE2b-256 9d61ca1d51e9c1483ae4ec649227c68adb2635094816ba19241aaa0ac65c6c8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp313-cp313-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp313-cp313-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 503ddad032f9a8103a83195c05cd01802f468b2757ea0cb078ac432644a2b386
MD5 4dd8b1d945a27a5af7ec7fb51453da69
BLAKE2b-256 d2f6149ec220799890d1b428d1d802370a4006c9987bc19061a02e7b6c99c0a8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp313-cp313-musllinux_1_2_aarch64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8e4374bce40148b535bd2ed46f760b87ac72dcadf903c0073fa6e8c8d12d3e07
MD5 7a1bee9e42f22733ce0c9152e332b94a
BLAKE2b-256 c0bc51fb9d840362d33f6c155f64566181232a0f438e8e5cca6714e8d1991d1d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 46715f08b41e3c70d08b3732864a86ddb7a17677183a7c67421241a10e23dabd
MD5 b9e8d9ddc7716f630eacd42a1c36a2c5
BLAKE2b-256 04bc4c103f60ddb5fb2a557caf7e5a420124a729b750a96748015f4881936e92

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b5670891dcb7dfa8620e3a64efa60ca220046433bb0cdca053a22866aa2abd58
MD5 9d2cd1206db27a5e5a9e5510253cd984
BLAKE2b-256 fdfae343f75cc7a9663d9c21e32c746785b534d82d95eb0ff4cac2e5794ce041

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 edab5394dce1a47254cffe703b22095b24e8f6677bbbc6a7cb6c3fbfa348a9f9
MD5 c55db5cde32217466fd761780f9d9da3
BLAKE2b-256 9ccf917587bcd3f5b01acfd71709084015792a81368eadc19b429069aab65d8c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp312-cp312-win_amd64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 047cfb8c225a226dfc4e7f1ad15152398679322c4f17e5da2106e41763f2b324
MD5 0ada2fbf07ad7acc723af047eb1f54fc
BLAKE2b-256 5d9fabe58b7376263447b763b51e464e8748fe4e3d568e74473d511ae9d134bb

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp312-cp312-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 74ce5eaf6bba06ef02637091a2fa7868004ebabaa11ab39fdcdbc770d5f302df
MD5 b98d62d309d59027bc2b0fcfba2fd0af
BLAKE2b-256 2e3bb502ab35d5d86ecf8fc48e6e422b351ce780ed2eb965ddc4db8cff41633e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp312-cp312-musllinux_1_2_aarch64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e3adcf8bd2c1eddfc17d4adf787012c2c620fae4dfa56364c11081525195c727
MD5 ce9f5c91be95937e0075e117327bc7ae
BLAKE2b-256 3f309bb936575a3c0866199aee0fc2ca6edab716de3e75d978b1503326a4ce24

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6ca389b90052e5891d8861216cc78830b64c432e47d3a098768d2af4e4bae59e
MD5 d57167389852893837aa46f67327d660
BLAKE2b-256 23e6817cf3922679574ead8f7ebdadd4260b816e38382243f57aea90b7a6fd0a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 530746c46a2eb52a9930d449f6229d1c47ddf3b3917fc2d2b358679255747a8e
MD5 fa6061af634d4fabe5abb47c874c53ff
BLAKE2b-256 f26a796f091e3410c151c11b20c2373de68388694960cb19df47b3903f8ddeeb

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 552c446d16d7a1edd1ef9e028ddf2298ab31737083b325c349b4ee50b09303ef
MD5 bf17a4a158380ccae9656735a451f849
BLAKE2b-256 74246ee3a31df862762239873bdaf9699e1df8559ba7f7a3163e0a33de796968

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp311-cp311-win_amd64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9186d3d31bd9edab0173c2b809e1f4789ba1c5906034cc8a357a3788b51b1e94
MD5 ec4826ff27e1c4ee2f2bfb03de1a6636
BLAKE2b-256 77a8b94635aba2389a845d2cece508c3601ccdcc5511fb62d6c99c8b9edad2ce

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp311-cp311-musllinux_1_2_x86_64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp311-cp311-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 aced070fe1a882a73508332bc18d032500b868f4f109d3517f05c4675c23b087
MD5 575d333efc7ed82afb2903d0362ce5e9
BLAKE2b-256 158caa5b5d81b69ad0179363904d680c9e4fece89a73f1bb11021a09bc2a21ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp311-cp311-musllinux_1_2_aarch64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6e98066b62cadb572c629718d509b1a3d6e63e5b428a1ecc07006b5e85803ff3
MD5 195af7d3dd4cbb8b0155ab205bffe8ea
BLAKE2b-256 7e1a7c8d6eab329f4196ccde10809302ebde74058be7d8ba929a2143625ea1f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6e06a0cc099014984b902d2931730b12318e9b50ac3c0c394194b1758dd94c8b
MD5 617e7f45dbc45452caf6bbc2e119b59b
BLAKE2b-256 33874e6b3dc7ff776b2e5b15112920c4647487b20acb9e8f32c17fdd57010a2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mdl_density_histogram-1.1.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for mdl_density_histogram-1.1.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 35fcf27ca3e6219fd004ce318e228e9e07321c792b5f41e129d0e3a183b6da4a
MD5 ae67dc85becbfc7387ded7094e656f3a
BLAKE2b-256 2622b726185429b0ae0cce261aec16130bb64d736652993c1b6976e7dbe4fc8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdl_density_histogram-1.1.1-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: python-publish.yml on MrTarantoga/MDL-Density-Histogram

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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