utils.ks.KS_test

utils.ks.KS_test(series, w_min, w_max, n_w, d_c, n_c, s_c, x_c=None)

Detect tipping points using Kolmogorov-Smirnov test

Applies sliding window KS test to detect abrupt transitions using the method of Bagniewski et al. (2021).

Parameters

series : ammonyte.Series

Series object containing time and value data

w_min : float

Size of smallest sliding window in time units

w_max : float

Size of largest sliding window in time units

n_w : int

Number of window sizes to test

d_c : float

Cut-off threshold for KS statistic

n_c : int

Minimum sample size per window

s_c : float

Standard deviation ratio threshold

x_c : float = None

Change threshold. If None, auto-calculated

Returns

jumps : numpy.ndarray

Array of detected transitions with shape (n, 2) Each row: [time, direction] where direction is +1 (up) or -1 (down)

d_statistics : numpy.ndarray

Array of KS D-statistics corresponding to each detected transition

p_values : numpy.ndarray

Array of p-values corresponding to each detected transition

Examples

Basic usage (typically called via Series.kstest):

.. jupyter-execute::

import os, ammonyte as amt
from ammonyte.utils.ks import KS_test
ngrip = amt.Series.from_csv(os.path.join(os.path.dirname(amt.__file__), 'data', 'NGRIP.csv'))
transitions = KS_test(ngrip, w_min=0.12, w_max=2.5, n_w=15, d_c=0.77, n_c=3, s_c=2.0, x_c=0.8)
print(f"Detected {len(transitions[0])} transitions")

See Also

Series.kstest : High-level interface to this function

References

Bagniewski, W., et al. (2021). Automatic detection of abrupt transitions in paleoclimate records. Chaos, 31(11), 113129.