All elements of the following function works outside the function but the function return an error
def histoautocorr(v,a):
def conds(x,a) :
if x > a :
return x
else :
return 0
def condi(x,a) :
if x <= a :
return x
else :
return 0
vs=[conds(x,a) for x in v]
vs=[condi(x,a) for x in v]
histoa=bar_chart(conds,rgbcolor=(0.15,0.5,0.5))
histoa.axes_labels([r'$o$',r'$v(o)$'])
histoa.fontsize(7)
histob=bar_chart(condi,rgbcolor=(0, 1, 0.45))
histob.axes_labels([r'$o$',r'$v(o)$'])
histob.fontsize(7)
return show(histoa+histob)
when applied to
ts=finance.TimeSeries([random() for _ in range(100)])
v=[ts.autocovariance(j) for j in range(1,30)]
that is histoautocorr(v,0.005)
. Also, by curiosity, I would appreciate to know if it is possible to redefine this fonction using two intermediate lambda
functions. Last but not least, is there a way to have a label which show the color associated with a bar < a and the opposite?