I need to find the maximum x value in Python of this function that I write through the code:
import numpy as np
y=np.abs(-np.exp(-x/1068)+np.exp(-x/46))
If I use this:
print(max(np.abs(-np.exp(-x/1068)+np.exp(-x/46))))
It prints only the maximum y value. How can I do to have also the maximum x value ?
如果x
是一个 np.array 并且您想找到与最大y
关联的x
,您可以使用np.argmax 。
x_max = x[np.argmax(y)]
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.