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 the 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
’num’: splits into l number of segments
Default is
'fix'.- l : int, optional¶
Specifies either:
The length of segments when segment_how=’fix’ (default=20)
The number of segments when segment_how=’num’
Default is 20. If None, 200 samples for
'fix'or 5 segments for'num'.
- Returns:¶
Dictionary containing the measures of mean drift:
max,minandmean, the maximum, minimum and mean of the segment means divided by the mean of the segment variances, andmeanmaxminandmeanabsmaxmin, the average ofmaxandminand of their absolute values. When the segments tile the series exactly,meanis the mean of the series divided by the mean segment variance, so it is zero up to rounding for a z-scored series and carries no information there (hctsa does not register it).- Return type:¶
Dict[str, float]