Generating a vector from successive multiplications of another vector from an initial value

Oscar Benjamin oscar.j.benjamin at gmail.com
Thu Oct 1 18:36:50 EDT 2015


On Thu, 1 Oct 2015 21:51 Paulo da Silva <p_s_d_a_s_i_l_v_a_ns at 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.



V * np.cumprod(vec)

--
Oscar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20151001/2a12520b/attachment.html>


More information about the Python-list mailing list