pyhctsa.operations.entropy.lempel_ziv_complexity

pyhctsa.operations.entropy.lempel_ziv_complexity(x, n_bits=2, pre_proc=None, rng=0)

Compute the normalized Lempel-Ziv (LZ) complexity of an n-bit encoding of a time series.

This function measures the complexity of a time series by counting the number of distinct symbol sequences (phrases) in its n-bit symbolic encoding, normalized by the expected number for a random (noise) sequence. Optionally, a preprocessing step can be applied before symbolization.

Parameters:
x : array-like

Input time series (1-D array or list).

n_bits : int, optional

Number of bits (alphabet size) to encode the data into (default: 2).

pre_proc : str, optional

Preprocessing method to apply before symbolization. Currently supported:
  • ’diff’: Use z-scored first differences of the time series.

rng : int, optional

Random seed for reproducibility (default: 0). Used for adding small random noise to break ties during symbolization.

Returns:

Normalized Lempel-Ziv complexity: the number of distinct symbol sequences divided by the expected number for a noise sequence.

Return type:

float