Hurst exponent estimation using Whittle's method
Project description
Overview
This module implements Whittle's likelihood estimation method for determining the Hurst exponent of a time series. The method fits the theoretical spectral density to the periodogram computed from the time series realization. This implementation includes spectral density approximations for fractional Gaussian noise (increments of fractional Brownian motion) and ARFIMA processes.
The Hurst exponent ($H$) controls the roughness, self-similarity, and long-range dependence of fBm paths:
- $H\in(0,0.5):~$ anti-persistent (mean-reverting) behavior.
- $H\in(0.5,1):~$ persistent behavior.
- $H=0.5:~ \mathrm{fBm}(H)$ is the Brownian motion.
- $H\rightarrow 0:~ \mathrm{fBm}(H)\rightarrow$ White noise.
- $H\rightarrow 1:~ \mathrm{fBm}(H)\rightarrow$ Linear trend.
Features
- Spectral density options:
fGnarfimafGn_paxsonfGn_truncationfGn_taylor
- A flexible interface that supports custom spectral density callback functions.
- Good performance both in terms of speed and accuracy.
- Included generators for fBm and ARFIMA.
Installation
pip install whittlehurst
Usage
fBm and fGn
import numpy as np
from whittlehurst import whittle, fbm
# Original Hurst value to test with
H=0.42
# Generate an fBm realization
fBm_seq = fbm(H=H, n=10000)
# Calculate the increments (the estimator works with the fGn spectrum)
fGn_seq = np.diff(fBm_seq)
# Estimate the Hurst exponent
H_est = whittle(fGn_seq)
print(f"Original H: {H:0.04f}, estimated H: {H_est:0.04f}")
ARFIMA
import numpy as np
from whittlehurst import whittle, arfima
# Original Hurst value to test with
H=0.42
# Generate a realization of an ARFIMA(0, H - 0.5, 0) process.
arfima_seq = arfima(H=H, n=10000)
# No need to take the increments here
# Estimate the "Hurst exponent" using the ARFIMA spectrum
H_est = whittle(arfima_seq, spectrum="arfima")
print(f"Original H: {H:0.04f}, estimated H: {H_est:0.04f}")
Performance
Compared to other methods
Our Whittle-based estimator offers a compelling alternative to traditional approaches for estimating the Hurst exponent. In particular, we compare it with:
-
R/S Method: Implemented in the hurst package, this method has been widely used for estimating $H$.
-
Higuchi's Method: Available through the antropy package, it performs quite well especially for smaller $H$ values, but its performance drops when $H\rightarrow 1$.
-
Variogram: Our variogram implementation of order $p = 1$ (madogram) accessible as
from whittlehurst import variogram.
Inference times represent the computation time per input sequence, and were calculated as: $t = w\cdot T/k$, where $k=100000$ is the number of sequences, $w=42$ is the number of workers (processing threads), and $T$ is the total elapsed time. Single-thread performance is likely superior, the results are mainly comparative.
The following results were calculated on $100000$ fBm realizations of length $n=1600$.
fGn spectral density approximations
The fGn spectral density calculations recommended by Shi et al. are accessible within our package:
-
fGn: The default recommended spectral model. It relies on the gamma function and the Hurwitz zeta function $\zeta(s,q)=\sum_{j=0}^{\infty}(j+q)^{-s}$ from scipy. Terms independent from $H$ or $\lambda$ are omitted, as they are not required for minimizing the Whittle objective. With $s=2H+1$:$g(\lambda,H) = \Gamma(s) \sin(\pi H) (1-\cos(\lambda))(2\pi)^{-s}\left[ \zeta\left(s, 1-\frac{\lambda}{2\pi}\right) + \zeta\left(s, \frac{\lambda}{2\pi}\right) \right].$
-
fGn_Paxson: Uses Paxson's approximation with a configurable parameterK=50. -
fGn_truncation: Approximates the infinite series by a configurable truncationK=200. -
fGn_Taylor: Uses a Taylor series expansion to approximate the spectral density at near-zero frequency.
The following results were calculated on $100000$ fBm realizations of length $n=1600$.
ARFIMA
For the $\text{ARFIMA}(0, H - 0.5, 0)$ process, the spectral density calculation is simpler. With terms independent from $H$ or $\lambda$ omitted, we use:
$g(\lambda,H) = (2\cdot\sin(\lambda/2))^{1 - 2H}$
References
-
The initial implementation of Whittle's method was adapted from:
https://github.com/JFBazille/ICode/blob/master/ICode/estimators/whittle.py
-
For further details on spectral density models for fractional Gaussian noise, refer to:
Shuping Shi, Jun Yu, and Chen Zhang. Fractional gaussian noise: Spectral density and estimation methods. Journal of Time Series Analysis, 2024. https://onlinelibrary.wiley.com/doi/full/10.1111/jtsa.12750
License
This project is licensed under the MIT License (c) 2025 Bálint Csanády, aielte-research. See the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file whittlehurst-0.8.tar.gz.
File metadata
- Download URL: whittlehurst-0.8.tar.gz
- Upload date:
- Size: 12.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1004f60f68261353487bed959d47cce3a78113773e680d6d6fb52fcd03b7a4c
|
|
| MD5 |
2f3fa0221956a6c4fb3ec94b8d59cb40
|
|
| BLAKE2b-256 |
cae4e0be0810128c83167471687c7afe6e1f54c7421df5746712c6dcb8949ba6
|
File details
Details for the file whittlehurst-0.8-py3-none-any.whl.
File metadata
- Download URL: whittlehurst-0.8-py3-none-any.whl
- Upload date:
- Size: 11.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93a5b84f8abed8123bfe72edd805136b4bacdd54f64c000c6996315bb2aa03d6
|
|
| MD5 |
c8792ff72960129a614eda5d0f9a81c7
|
|
| BLAKE2b-256 |
18ac3ee16f1818106f96d9feb61a2d8cfdc617ca054d52dcef946581e8074c7a
|