binny.correlations.scores module#

Per-index score utilities for curves on a shared grid.

These helpers reduce each curve to a single scalar per index (e.g. peak, mean, median, or a credible width). The returned dictionaries can be used as inputs to tuple filters that compare indices via these scores.

binny.correlations.scores.score_credible_width(*, z: ndarray[tuple[Any, ...], dtype[float64]], curves: Mapping[int, ndarray[tuple[Any, ...], dtype[float64]]], mass: float = 0.68) dict[int, float]#

Compute central credible widths for a collection of curves.

The credible width is defined as the width of the central interval containing the specified fraction of the total integrated curve area.

Parameters:
  • z – One-dimensional coordinate grid.

  • curves – Mapping from index to curve values evaluated on z.

  • mass – Fraction of total area contained within the interval.

Returns:

Mapping from index to credible interval widths.

Raises:

ValueError – If mass is not in the open interval (0, 1) or curve shapes are invalid.

binny.correlations.scores.score_mean_location(*, z: ndarray[tuple[Any, ...], dtype[float64]], curves: Mapping[int, ndarray[tuple[Any, ...], dtype[float64]]]) dict[int, float]#

Compute mean locations for a collection of curves on a shared grid.

The mean location is defined as the first moment of each curve with respect to the grid coordinate.

Parameters:
  • z – One-dimensional coordinate grid.

  • curves – Mapping from index to curve values evaluated on z.

Returns:

Mapping from index to mean location values.

Raises:

ValueError – If a curve does not have the same shape as z.

binny.correlations.scores.score_median_location(*, z: ndarray[tuple[Any, ...], dtype[float64]], curves: Mapping[int, ndarray[tuple[Any, ...], dtype[float64]]]) dict[int, float]#

Compute median locations for a collection of curves on a shared grid.

The median location is defined as the grid coordinate at which the cumulative integrated curve reaches one half of its total area.

Parameters:
  • z – One-dimensional coordinate grid.

  • curves – Mapping from index to curve values evaluated on z.

Returns:

Mapping from index to median location values.

Raises:

ValueError – If z has fewer than two points or curve shapes are invalid.

binny.correlations.scores.score_peak_location(*, z: ndarray[tuple[Any, ...], dtype[float64]], curves: Mapping[int, ndarray[tuple[Any, ...], dtype[float64]]]) dict[int, float]#

Compute peak locations for a collection of curves on a shared grid.

The peak location is defined as the grid coordinate corresponding to the maximum value of each curve.

Parameters:
  • z – One-dimensional coordinate grid.

  • curves – Mapping from index to curve values evaluated on z.

Returns:

Mapping from index to peak location along the grid.

Raises:

ValueError – If a curve does not have the same shape as z.