pyhctsa.operations.symbolic.binary_stretch

pyhctsa.operations.symbolic.binary_stretch(x, stretch_what='lseq1')

Characterize stretches of 0s or 1s in a binarized time series.

This function binarizes the input time series based on its mean: values above the mean are converted to 1, and values below to 0. It then computes a statistic related to the lengths of consecutive 0s or 1s in the resulting binary sequence, depending on the stretch_what argument.

Note: Due to an implementation error in the original version, this function does not correctly compute the longest stretch of 0s or 1s, but still produces a potentially interesting statistic.

Parameters:
x : array-like

The input time series.

stretch_what : str, optional

Specifies which binary symbol’s stretch length to analyze:

  • ’lseq1’: Analyze stretches related to consecutive 1s (default).

  • ’lseq0’: Analyze stretches related to consecutive 0s.

Returns:

A statistic related to the stretch length of consecutive 0s or 1s, normalized by the time-series length.

Return type:

float