Skip to main content

Hurst exponent evaluation and R/S-analysis

Project description


Hurst exponent evaluation and R/S-analysis

Python 2.7 Python 3x Build Status pypi Downloads

hurst is a small Python module for analysing random walks and evaluating the Hurst exponent (H).

H = 0.5 — Brownian motion,
0.5 < H < 1.0 — persistent behavior,
0 < H < 0.5 — anti-persistent behavior.


Install hurst module with
pip install hurst
pip install -e git+


import numpy as np
import matplotlib.pyplot as plt
from hurst import compute_Hc, random_walk

# Use random_walk() function or generate a random walk series manually:
# series = random_walk(99999, cumprod=True)
random_changes = 1. + np.random.randn(99999) / 1000.
series = np.cumprod(random_changes)  # create a random walk from random changes

# Evaluate Hurst equation
H, c, data = compute_Hc(series, kind='price', simplified=True)

# Plot
f, ax = plt.subplots()
ax.plot(data[0], c*data[0]**H, color="deepskyblue")
ax.scatter(data[0], data[1], color="purple")
ax.set_xlabel('Time interval')
ax.set_ylabel('R/S ratio')

print("H={:.4f}, c={:.4f}".format(H,c))

R/S analysis

H=0.4964, c=1.4877

Kinds of series

The kind parameter of the compute_Hc function can have the following values:
'change': a series is just random values (i.e. np.random.randn(...))
'random_walk': a series is a cumulative sum of changes (i.e. np.cumsum(np.random.randn(...)))
'price': a series is a cumulative product of changes (i.e. np.cumprod(1+epsilon*np.random.randn(...))

Brownian motion, persistent and antipersistent random walks

You can generate random walks with random_walk() function as following:


brownian = random_walk(99999, proba=0.5)

Brownian motion


persistent = random_walk(99999, proba=0.7)

Persistent random walk


antipersistent = random_walk(99999, proba=0.3)

Antipersistent random walk

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
hurst-0.0.5-py3-none-any.whl (5.9 kB) Copy SHA256 hash SHA256 Wheel py3

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page