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)
The above code gives me the following output:
[32. 16. 8. 4. 2. 1.]
These numbers should be NEGATIVE and I have no idea what's going on with numpy
Thank you!
These numbers should be NEGATIVE and I have no idea what's going on with numpy.
This is not a problem with numpy. The velocity here is negative , but the acceleration is positive (since the velocity is increasing over time).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.