HurstExponent
- class eyefeatures.features.measures.HurstExponent(coordinate, n_iters=10, fill_strategy='last', pk=None, eps=1e-22, return_df=True, ignore_errors=False)[source]
Bases:
MeasureTransformerApproximates Hurst Exponent using R/S analysis.
The Hurst exponent is a measure of the long-term memory of time series. It relates to the autocorrelations of the time series, and the rate at which these decrease as the lag between pairs of values increases. $H in (0.5, 1)$ indicates a persistent behavior (trend). $H in (0, 0.5)$ indicates an anti-persistent behavior (mean-reverting). $H = 0.5$ indicates a completely random series (Geometric Brownian Motion).
- Parameters:
coordinate (str) – coordinate column name (1D Hurst exponent currently available).
n_iters (int) – number of iterations to complete. Note: data must be of length more than \(2^{n\_iters}\).
fill_strategy (Literal['mean', 'reduce', 'last']) – how to make vector be length of power of \(2\). If “reduce”, then all values after \(2^k\)-th are removed, where \(n < 2^{(k + 1)}\). Other strategies specify the value to fill the vector up to the closest power of \(2\), “mean” being the mean of vector, “last” being the last value (makes time-series constant at the end).
pk (list[str]) – list of column names used to split pd.DataFrame.
eps (float) – division epsilon.
return_df (bool) – Return pd.Dataframe object else np.ndarray.
ignore_errors (bool) – If True, return NaN when feature computation fails; otherwise raise.
Example
Quick start with default parameters:
from eyefeatures.features.measures import HurstExponent transformer = HurstExponent(coordinate="x") features = transformer.fit_transform(fixations_df)
Time series is divided into segments (blocks) of equal size.
The mean is subtracted from each segment to center the data.
Compute the cumulative sum of the mean-adjusted data and determine the range (maximum - minimum) of the cumulative deviation.
Calculate the standard deviation of the original segment and the ratio of the range to the standard deviation.
The slope of he log of the block size and the log of the R/S ratio estimates the Hurst Exponent.
where \(\frac{R}{S}\) is the rescaled range, \(n\) is the block size, and \(C\) is some constant.