numpy confusion

Papalagi Pakeha papalagi.pakeha at gmail.com
Tue Oct 23 08:12:40 EDT 2007


Hi all,

I'm trying to do some calculations with NumPy but apparently didn't
quite got the basics. For example I need Exponential Moving Average
function. That is, I have an array of values and want to apply a
function F(current, previous) to each element of the array. How can I
pass the 'previous' element to the function? In plain python it would
be a simple loop:

for index in arange(len(in_data[1:])):
    result[index] = F(in_data[index], result[index-1])

I assume it's somehow possible with numpy.frompyfunc() and actually
found one example in SciPy TimeSeries library. Unfortunately I don't
fully understand how that one works :-/

Is anyone able to shed some light on this thing?

Thanks

PaPa



More information about the Python-list mailing list