Skip to content

Instantly share code, notes, and snippets.

@marcotav
Created June 9, 2019 01:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcotav/78690b027a632d327d940add982838cf to your computer and use it in GitHub Desktop.
Save marcotav/78690b027a632d327d940add982838cf to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
from hurst import compute_Hc, random_walk
import seaborn as sns
sns.set();
%matplotlib inline
np.random.seed(42)
random_changes = 1. + np.random.randn(99999) / 1000.
series = np.cumprod(random_changes)
H, c, result = compute_Hc(series, kind='price', simplified=True)
plt.rcParams['figure.figsize'] = 10, 5
f, ax = plt.subplots()
_ = ax.plot(result[0], c*result[0]**H)
_ = ax.scatter(result[0], result[1])
_ = ax.set_xscale('log')
_ = ax.set_yscale('log')
_ = ax.set_xlabel('log(time interval)')
_ = ax.set_ylabel('log(R/S ratio)')
print("H={:.3f}, c={:.3f}".format(H,c))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment