From bfcd29f52c2939f276a1ff3b3d74605a766d3e1e Mon Sep 17 00:00:00 2001 From: Dmitry Mottl Date: Thu, 8 Nov 2018 11:02:19 +0100 Subject: [PATCH] Simplify __get_RS() code, fix a typo in README.md --- README.md | 3 +-- hurst/__init__.py | 7 ++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 05c1470..260c8f3 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,8 @@ or ## Usage ```python -import matplotlib.pyplot as plt import numpy as np -import matplotplotlib.pyplot as plt +import matplotlib.pyplot as plt from hurst import compute_Hc, random_walk # Use random_walk() function or generate a random walk series manually: diff --git a/hurst/__init__.py b/hurst/__init__.py index 3b50d23..b4073a2 100644 --- a/hurst/__init__.py +++ b/hurst/__init__.py @@ -84,9 +84,7 @@ def __get_RS(series, kind): elif kind == 'price': incs = __to_pct(series) - # convert price to percentt changes to price: - _series = np.hstack([[0.],np.cumsum(incs)]) - mean_inc = (_series[-1] - _series[0]) / len(incs) + mean_inc = np.sum(incs) / len(incs) deviations = incs - mean_inc Z = np.cumsum(deviations) R = max(Z) - min(Z) @@ -94,8 +92,7 @@ def __get_RS(series, kind): elif kind == 'change': incs = series - _series = np.hstack([[0.],np.cumsum(incs)]) - mean_inc = (series[-1] - series[0]) / len(incs) + mean_inc = np.sum(incs) / len(incs) deviations = incs - mean_inc Z = np.cumsum(deviations) R = max(Z) - min(Z)