How can I rework the code up that ema(x, 5) returns the data now in emaout? I'm trying to enclose everything in one def.Right now its in a for loop and a def.x = [32.47, 32.70, 32.77, 33.11, 33.25, 33.23, 33.23, 33.0, 33.04, 33.21]def ema(series, period, prevma):    smoothing = 2.0 / (period + 1.0)                    return prevma + smoothing * (series[bar] - prevma)prevema = x[0] emaout =[]for bar, close in enumerate(x):    curema = ema(x, 5, prevema)     prevema = curema    emaout.append(curema)print print emaoutx could be a NumPy array.
Moving average of a data series
python;numpy