Skip to main content

Python 3x pypi

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=0.5:~ \mathrm{fBm}(H)$ is the Brownian motion.
  • $H\in(0.5,1):~$ persistent behavior.

Features

  • Spectral density options:
    • fGn (This is the current default option, corresponding to fGn_Paxson, with K=10)
    • arfima
    • fGn_Paxson
    • fGn_Hurwitz
    • fGn_truncation
    • fGn_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

Whittle for 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}")

TDML for fGn

The Time-Domain Maximum Likelihood (TDML) method estimates $H$ from fGn observations by fitting the likelihood function directly in the time domain. TDML performs a similar root finding as Whittle's method, but Whittle operates in the frequency domain. Despite significant optimizations TDML remains much slower than Whittle. TDML offers marginally improved accuracy, especially at the edges of the Hurst parameter range.

Usage:

import numpy as np
from whittlehurst import tdml, fbm

# Original Hurst value to test with
H=0.42

# Generate an fBm realization
fBm_seq = fbm(H=H, n=10000)

# Calculate the increments
fGn_seq = np.diff(fBm_seq)

# Estimate the Hurst exponent
H_est = tdml(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$.

  • DFA: Detrended Fluctuation Analysis is a popular Hurst estimator robust for non-stationary processes (this robustness is not required in the below tests). Available through the nolds package.

  • Variogram: Our variogram implementation of order $p = 1$ (madogram) accessible as from whittlehurst import variogram.

  • TDML: Our TDML implementation.

RMSE by Sequence Length

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=32$ 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.

Compute Time

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

Local RMSE at n=2048

Scatter Plot

fGn spectral density approximations

The fGn spectral density calculations recommended by Shi et al. are accessible within our package:

  • fGn or fGn_Paxson: The default recommended spectral model. Uses Paxson's approximation with a configurable parameter K=10.
  • fGn_Hurwitz: Relies on the gamma function and the Hurwitz zeta function $\zeta(s,q)=\sum_{j=0}^{\infty}(j+q)^{-s}$ from scipy.
  • fGn_truncation: Approximates the infinite series by a configurable truncation K=200.
  • fGn_Taylor: Uses a Taylor series expansion to approximate the spectral density at near-zero frequency.

RMSE by Sequence Length

Compute Time

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

Local RMSE at n=2048

Scatter Plot

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}$

ARFIMA Local RMSE

How to Cite

@misc{csanády2025whittlehurstpythonpackageimplementing,
      title={$whittlehurst$: A Python package implementing Whittle's likelihood estimation of the Hurst exponent}, 
      author={Bálint Csanády and Lóránt Nagy and András Lukács},
      year={2025},
      eprint={2506.01985},
      archivePrefix={arXiv},
      primaryClass={stat.CO},
      url={https://arxiv.org/abs/2506.01985}, 
}

References

License

This project is licensed under the MIT License (c) 2025 Bálint Csanády, aielte-research. See the LICENSE file for details.

Metadata

Release files for whittlehurst 1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for whittlehurst 1.4
File Size Uploaded Provenance Actions
whittlehurst-1.4.tar.gz 14.9 kB Without provenance Details for whittlehurst-1.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for whittlehurst 1.4
File Interpreter ABI Platform Actions
whittlehurst-1.4-py3-none-any.whl Python 3 none any Details for whittlehurst-1.4-py3-none-any.whl

Total release size: 28.1 kB

Release files / whittlehurst-1.4.tar.gz

Download URL whittlehurst-1.4.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3d0fd1f9659c75b130c433eb8877599bde3225561b7dd3d1e2eaded86fcf8fd5
BLAKE2b-256 checksum
How to use checksums
40ffdb9385b60ddb44227b4373a4b43159c1d0583e51378bfe657a5d6b3e8c90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / whittlehurst-1.4-py3-none-any.whl

Download URL whittlehurst-1.4-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cba916d20642ba8f96c80daa3fecd7d67bdae6b9e0424b90dcbbda7ac8ffbcec
BLAKE2b-256 checksum
How to use checksums
eebbe3d002d419c353b37a9b3a7a5dfa61d7c7290bcc51e3b6774b698adb1e37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for whittlehurst 1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page