On Thu, Oct 1, 2015 at 2:45 PM, Paulo da Silva <p_s_d_a_s_i_l_v_a...@netcabo.pt> wrote: > Hi all. > > What is the fastest way to do the following: > > I have an initial value V and a vector vec of (financial) indexes. > I want to generate a new vector nvec as > > V, V*vec[0], V*vec[0]*vec[1], V*vec[0]*vec[1]*vec[2], ... > > A numpy vectorized solution would be better.
That looks hard to vectorize since each calculation depends on the previous. You might be stuck with something like: result = [V] for x in vec: result.append(result[-1] * x) -- https://mail.python.org/mailman/listinfo/python-list