spiegelhalter_z_test

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

spiegelhalter_z_test(y_true: ndarray, y_prob: ndarray) → Tuple[float, float][source]

Perform Spiegelhalter’s Z-test of calibration for binary outcomes.

The statistic compares observed minus expected event counts against the variance implied by the predicted probabilities: z = sum(y - p) / sqrt(sum(p * (1 - p))).

Parameters:
  • y_true – Binary outcomes (0/1).

  • y_prob – Predicted event probabilities, aligned to y_true.

Returns:

Tuple (z_statistic, p_value) (two-sided).