我有一些我认为是正确的代码。但是,它应该返回一个值向量,但它返回的是单个累积值。
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
我试图理解为什么它只打印一个值而不是我认为应该[0.10000000000000001]
的向量。[0, 0.1, 0.8, 0.1]