numpy confusion

P

Papalagi Pakeha

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top