Skip to content

API reference / Evaluation

tsdive.eval.power_martingale

power_martingale(
    p_values: Iterable[float], epsilon: float
) -> np.ndarray

Natural log of the power martingale prod(epsilon * p ** (epsilon - 1)).

One value per stream position, cumulative from the first. epsilon must lie in (0, 1]; epsilon == 1 gives zeros. Raises ValueError for epsilon outside that interval or a p-value outside (0, 1].

Examples:

>>> from tsdive.eval import power_martingale
>>> power_martingale([0.5, 0.2, 0.1], epsilon=0.5).round(3).tolist()
[-0.347, -0.235, 0.223]