Skip to content

[Python] NameError: name 'hurst' is not defined

3 messages · Allan Tanaka, Jeff Newmiller

#
Hi. Not sure why this code produces the error like this. This error appears when i run the code of print "Hurst(GBM): ? %s" % hurst(gbm):?
Traceback (most recent call last):? File "<pyshell#31>", line 1, in <module>? ? print "Hurst(GBM): ? %s" % hurst(gbm)NameError: name 'hurst' is not defined

Here is the full code:>>> import statsmodels.tsa.stattools as ts

  
  
#
Correction, it should look like this:**def hurst(ts): lags = range(2, 100) tau = [np.sqrt(std(subtract(ts[lag:], ts[:-lag]))) for lag in lags] poly = np.polyfit(log(lags), log(tau), 1) return poly[0]*2.0
On Tuesday, 14 February 2017, 0:06, Allan Tanaka <allantanaka11 at yahoo.com> wrote:
Hi. Not sure why this code produces the error like this. This error appears when i run the code of print "Hurst(GBM): ? %s" % hurst(gbm):?
Traceback (most recent call last):? File "<pyshell#31>", line 1, in <module>? ? print "Hurst(GBM): ? %s" % hurst(gbm)NameError: name 'hurst' is not defined

Here is the full code:>>> import statsmodels.tsa.stattools as ts

  
  
#
This question is off topic here.