Created
June 9, 2019 01:19
-
-
Save marcotav/78690b027a632d327d940add982838cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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