Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
import numpy as np data = [128,64,32,16,8,4,2,1] data = np.array(data, dtype=float) velocity = np.diff(data) acceleration = np.diff(velocity) print(acceleration)
上面的代码给了我以下输出:
[32. 16. 8. 4. 2. 1.]
这些数字应该是负数,我不知道 numpy 发生了什么
谢谢!
这些数字应该是负数,我不知道 numpy 发生了什么。
这不是 numpy 的问题。这里的速度是负的,但加速度是正的(因为速度随着时间的推移而增加)。