Skip to content

Commit

Permalink
Simplify __get_RS() code, fix a typo in README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottl committed Nov 8, 2018
1 parent 2d8a03e commit bfcd29f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
7 changes: 2 additions & 5 deletions hurst/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,15 @@ 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)
S = np.std(incs, ddof=1)

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)
Expand Down

0 comments on commit bfcd29f

Please sign in to comment.