pyhctsa.operations.stationarity.drifting_mean

pyhctsa.operations.stationarity.drifting_mean(y, segment_how='fix', l=20)

Measures mean drift by analyzing mean and variance in time-series subsegments.

This operation splits a time series into segments, computes the mean and variance in each segment, and compares the maximum and minimum means to the mean variance. This helps identify if the time series has a drifting mean by comparing local statistics across different segments.

The method follows this approach: 1. Splits signal into frames of length N (or num segments) 2. Computes means of each frame 3. Computes variance for each frame 4. Compares ratio of max/min means with mean variance

Original idea by Rune from Matlab Central forum: http://www.mathworks.de/matlabcentral/newsreader/view_thread/136539

Parameters:
y : array-like

The input time series

segment_how : str, optional

Method to segment the time series:

  • ’fix’: fixed-length segments of length l (default)

  • ’num’: splits into l number of segments

l : int, optional

Specifies either:

  • The length of segments when segment_how=’fix’ (default=20)

  • The number of segments when segment_how=’num’

Returns:

Dictionary containing the measures of mean drift.

Return type:

Dict[str, float]