I have a bit of code which I think is correct. However, it should return a vector of values but it returns a single cumulated value instead.
pExact = 0.8
pOvershoot = 0.1
pUndershoot = 0.1
def move(p, U):
q = []
for i in range(len(p)):
s = pExact * p[(i - U) % len(p)]
s = s + pOvershoot * p[(i - U - 1) % len(p)]
s = s + pUndershoot * p[(i - U + 1) % len(p)]
print i, s # check if calculations are corrects
q.append(s)
return q # should return a vector
p = [0, 1, 0, 0]
print move(p, 1) # prints only cumulated value
I try to understand why it prints only one value [0.10000000000000001] not a vector [0, 0.1, 0.8, 0.1] how I think it should.
q.append(s)belongs into theforloop? (indent it by one step to the right)