Skip to content

API reference / Evaluation

tsdive.eval.mixture_martingale

mixture_martingale(
    p_values: Iterable[float],
    epsilons: Iterable[float] = DEFAULT_EPSILONS,
) -> np.ndarray

Natural log of the mean over epsilons of the power martingales.

One value per stream position, computed in log space with np.logaddexp.reduce. A mixture of martingales is a martingale, so martingale_alarm keeps its bound. Raises ValueError when epsilons is empty or any epsilon lies outside (0, 1].

Examples:

>>> from tsdive.eval import mixture_martingale
>>> mixture_martingale([0.5, 0.2, 0.1]).round(3).tolist()
[-0.427, -0.385, -0.058]