Skip to main content

Hurst exponent estimation using Whittle's method

Project description

Python 3x pypi

Overview

This module provides an implementation of Whittle's likelihood method to estimate the Hurst exponent of a time series. The method fits a theoretical spectral density model to the periodogram of the time series realization. This implementation supports multiple 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:
    • fGn
    • arfima
    • fGn_paxson
    • fGn_truncation
    • fGn_taylor
  • Flexible interface with an option for a custom spectral density callback.
  • 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 an ARFIMA(0, H - 0.5, 0) realization
arfima_seq = arfima(H=H, n=10000)

# No need to take the increments here
# Estimate the "Hurst exponent"
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.

RMSE by Sequence Length

Inference times indicate per input sequence times, and were calculated as: $t = w\cdot T/k$, where $k=100000$ is the number of sequences, $w=32$ is the number of workers (processing threads), and $T$ is the total elapsed time. Single-thread performance is likely to be better, the results are mainly comparative.

Compute Time

The following results were calculated on $100000$ fBm realizations of length $n=1600$.

Local RMSE at n=1600

Scatter Plot

Notes

  • The default recommended spectral model is fGn which relies on Hurwitz's zeta function.
  • fGn_paxson, fGn_truncation, fGn_taylor are experimental approximations of the fGn spectrum.
  • For models fGn_paxson and fGn_truncation, the parameter K is configurable (defaults: 50 and 200 respectively).
  • A custom spectral density function may be provided via the spectrum_callback parameter.

References

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

whittlehurst-0.6.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

whittlehurst-0.6-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file whittlehurst-0.6.tar.gz.

File metadata

  • Download URL: whittlehurst-0.6.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.9

File hashes

Hashes for whittlehurst-0.6.tar.gz
Algorithm Hash digest
SHA256 a5cf23a266077e396039b110ef3db63a55a68cf4d85cd23bfea769eae67cb0e9
MD5 c4fdbafa38f1635a75a3d57625c96758
BLAKE2b-256 0bfbb0c84d5a0d63590308d46f7603bf9b5199213d3b50496f7a69a7b027c612

See more details on using hashes here.

File details

Details for the file whittlehurst-0.6-py3-none-any.whl.

File metadata

  • Download URL: whittlehurst-0.6-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

Hashes for whittlehurst-0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ba773982a15b0b57913733f8f0a0af6306f14a6ce28635650afc54c668f56441
MD5 4f04120d31eb6376b96a09b591f69eea
BLAKE2b-256 b9e3914c53c91bcfe9212d27c5adfb24cfb36c2a93043f3f5319e8367fbae300

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page