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

duncan smith buzzard at invalid.invalid
Thu Oct 1 19:44:19 EDT 2015


On 01/10/15 21:45, Paulo da Silva 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.
> 
> Thanks
> 

Maybe,

http://docs.scipy.org/doc/numpy/reference/generated/numpy.cumprod.html

Duncan



More information about the Python-list mailing list