Let's say I have two numpy arrays:
import numpy as np
a = np.ones(5)
b = np.array([1.0, 1.1, 1.05, 1.2, 1.25])
I'd like that element a[1]=a[0]*b[1], lets call this a[1] a new_a, then a[2]=new_a*b[2]. Can this be done without using a loop in numpy? With a loop code looks like this:
for i in range(len(a)-1):
a[i+1] = a[i]*b[i+1]
print (a)
prints:
[ 1. 1.1 1.155 1.386 1.7325]