pyhctsa.operations.symbolic.binary_stats_ar1

pyhctsa.operations.symbolic.binary_stats_ar1(y, binary_method='mean')

Binary run-length statistics normalized against an AR(1) null.

Binarizes the time series (as binary_stats()) and compares the resulting run-length statistics to their analytic expectation under a Gaussian AR(1) null process with the same lag-1 autocorrelation as the series. Ratios near 1 indicate that the binary run structure is what linear autocorrelation alone would give.

For a stationary Gaussian process u (u = y for ‘mean’; u = diff(y) for ‘diff’, i.e., whichever series is actually thresholded at zero), the probability that consecutive samples lie on the same side of the mean follows the arcsine law, p = 1/2 + arcsin(rho)/pi, with rho the lag-1 autocorrelation of u. Treating the binary sign sequence as a two-state Markov chain with persistence probability p gives geometrically distributed run lengths, so the expected mean run length is 1/(1-p) and the expected proportion of runs of 1s (per sample) is (1-p)/2. Only the statistics whose theory holds up empirically (the mean run lengths and the number of runs) get an AR(1)-normalized counterpart; for the fuller set of empirical run-length statistics see binary_stats().

Parameters:
y : array-like

The input time series.

binary_method : {'mean', 'diff'}, optional

The binary symbolization rule: ‘mean’ (1 above the mean, 0 below) or ‘diff’ (1 for an increase, 0 otherwise). Unlike binary_stats(), ‘median’ and ‘iqr’ are not supported: the theory is specific to a sign threshold at the mean of a (possibly transformed) Gaussian series. Default is 'mean'.

Returns:

  • ‘pstretch1’: the number of runs of 1s divided by the length of the binary string,

  • ’meanstretch0’, ‘meanstretch1’: the mean run length of 0s, and of 1s (NaN if there are no such runs),

  • ’ar1_p’: the AR(1)-implied persistence probability p,

  • ’meanstretch_ar1exp’: the expected mean run length, 1/(1-p),

  • ’pstretch1_ar1exp’: the expected value of ‘pstretch1’, (1-p)/2,

  • ’meanstretch0_ar1rat’, ‘meanstretch1_ar1rat’: ‘meanstretch0’ and ‘meanstretch1’ divided by ‘meanstretch_ar1exp’,

  • ’pstretch1_ar1rat’: ‘pstretch1’ divided by ‘pstretch1_ar1exp’.

In the degenerate limit of a lag-1 autocorrelation of 1 the ratios are NaN, ‘meanstretch_ar1exp’ is Inf and ‘pstretch1_ar1exp’ is 0.

Return type:

dict