CalibrationResult.histogram#

CalibrationResult.histogram(bins=10)[source]#

PIT histogram counts on equal-width bins over (0, 1).

The picture the diagnosis reads: flat is calibrated, U-shaped is overconfident, hump-shaped is overdispersed, sloped is biased. Each column sums to n_origins, and under correct calibration each cell has expectation n_origins / bins.

Parameters:

bins (int) – Number of equal-width bins, at least 2.

Return type:

NDArray[double]

Returns:

A (bins, k) array of counts.

Raises:

SpecificationError – If fewer than two bins are asked for.

Example

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> paths, outcomes = rng.standard_normal((80, 500, 2)), rng.standard_normal((80, 2))
>>> record = Calibration(paths, outcomes)
>>> counts = record.compute().histogram(4)
>>> counts.shape, counts.sum(axis=0)
((4, 2), array([80., 80.]))
>>> record.compute().histogram(1)
Traceback (most recent call last):
    ...
cultivars.exceptions.SpecificationError: bins must be at least 2; got 1.