Say I have a for loop using range as shown below. Is there a good way to eliminate the for loop and use numpy arrays only?
y =[146, 96, 59, 133, 192, 127, 79, 186, 272, 155, 98, 219]
At=3
Bt=2
Aindex=[]
Bindex=[]
for i in range(len(y)-1):
A =At
B =Bt
At =y[i] / y[i] + 5 * (A + B)
Aindex.append(At)
Bt =(At - A) + y[i+1] * B
Bindex.append(Bt)
I would use something like
c=len(y)-1
Aindex=y[:c]/y[:c]+5* (A + B)
But A and B updates in the loop. I also do not know how to vectorize y[i+1] in the Bt equation