Say I have an array of x and y :
x = numpy.array([1,2,3,4,5,6,7,8,9,10])
There is a formula for y , and each element is based on the previous element, let i denote the index y , each element:
y[i] = y[i-1] * 2 + x[i]
When computing the first element, let y[i-1] = 50 . In other words, y should be:
[101, 204, 411, 826, 1657, 3320, 6647, 13302, 26613, 53236]
How to calculate y with numpy?
source share