hdrpy is a Python library that provides a NumPy-based implementation of High Dynamic Range (HDR) histograms. It was initially forked from HDRHistogram_py and replaced its C code dependency with NumPy. This library is designed for efficient recording and analyzing of sampled data value counts across a configurable integer range with specified value precision, making it particularly useful in latency and performance-sensitive applications.
pip install hdrpyVerified import paths — ran on the pinned version, not inferred.
Initialize an HdrHistogram instance, record values, and retrieve various statistics like mean, standard deviation, and percentiles.
Be aware of potential lack of active maintenance; consider contributions if specific new features or bug fixes are required.
For latency measurements where samples might be omitted due to system overload, use `histogram.record_corrected_value(value, expected_interval)` to accurately reflect the true distribution. The `expected_interval` is the expected sampling interval.
Carefully consider the `number_of_significant_value_digits` parameter when initializing `HdrHistogram` to ensure the required resolution for your data, particularly for small values. Higher precision requires more memory.
Ensure you are importing `HdrHistogram` directly from the `hdrpy` package: `from hdrpy import HdrHistogram`.
Always initialize `HdrHistogram` with its mandatory parameters, for example: `histogram = HdrHistogram(1, 3600000000, 3)` where the arguments specify the range and precision.
Ensure that all values you intend to record fall within the `lowest_discernible_value` and `highest_trackable_value` specified when creating the `HdrHistogram` instance. Adjust the histogram's range if necessary to accommodate your data.