stratify
stratify(lower, upper, bins, logarithmic=False, probability=False)Stratify an axis into equal-width bins.
Mirrors the C# Stratify.XValues(StratificationOptions, isLogarithmic): splits [lower, upper] into bins equal-width strata (equal-width in log10 space when logarithmic=True), each carrying a weight defaulting to its own width. probability=True always returns zero rows, matching Stratify.XValues‘s own early return for probability-space options – the ported header exposes only the StratificationOptions overload used by the BestFit estimators’ profile-likelihood grids, not the probability-stratification methods (Probabilities, XToProbability, …), which are out of scope (see stratify.hpp’s file header).
lower, upper, and bins are validated rather than passed through to the C++ layer, which would otherwise silently return zero rows for lower >= upper (and for bins < 2) instead of raising an error.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| lower | float | Bounds of the axis to stratify. lower must be less than upper. |
required |
| upper | float | Bounds of the axis to stratify. lower must be less than upper. |
required |
| bins | int | Number of bins, greater than 1. | required |
| logarithmic | bool | Stratify on a log10 scale. Default False. |
False |
| probability | bool | Mark the axis as a probability axis; kept only for parity with the C# constructor argument – it always yields zero bins (see above). Default False. |
False |
Returns
| Name | Type | Description |
|---|---|---|
| dict | Keys lower, upper, midpoint, weight (each :class:numpy.ndarray, one entry per bin). |
Examples
>>> from corehydropy import stratify
>>> s = stratify(0, 1, bins=4)
>>> s["midpoint"]
array([0.125, 0.375, 0.625, 0.875])