Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.