简体   繁体   English

我应该如何找到对应于抛物线的最大或最小 y_value 的 x_value? (在 Python 中)

[英]How should I find the x_value corresponding to the max or min y_value of a parabola? (in Python)

I've been tying to use np.where to find the x value that corresponds to the maximum y value of a parabola, here is what I did:我一直想使用np.where来找到对应于抛物线的最大y值的x值,这就是我所做的:

import numpy as np
x = np.arange(-10,10,step=1)
y = x**2+2*x
x = np.where(y=max)
print(x)

This clearly doesn't work这显然行不通

You can simply use argmin您可以简单地使用 argmin

import numpy as np
x = np.arange(-10,10,step=1)
y = x**2+2*x
idx = np.argmin(y)
print(x[idx])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python在绘图中找到x值到相应的max y值 - Python find x value to corresponding max y value in plot 如何从熊猫数据框中找到最小和最大AND对应的x值? - How to find the min and max AND corresponding x-value from a pandas data frame? 如何在 plot 中给定指定的 Y 值找到对应的 X 值 - How to find corresponding X value given a specified Y value in a plot 如何在 plot 中找到给定 y 值的对应 x 值 - How to find the corresponding x value for a given y value in a plot 如何从 Python 中的该数据集中找到最大值或最小值? - How do I find the Max or Min value from this dataset in Python? 曲线拟合:如何在python中优化x_value model进行曲线拟合 - Curve fitting: How to optimize x_value model for curve fitting in python 需要帮助理解一行代码如何使用最大 y 坐标在 python 中找到相应的 X 值 - Need help understanding how a line of code is using a maximum y coordinate to find the corresponding X value in python 找到与最大直方图对应的x值 - Find the x value corresponding to a histogram max 如何为 X 的每个值获得 Y 的最小值? - How can I get min value of Y for each value of X? 在X轴上查找对应于Y的任意值的值,该值不包含在用于在python中绘制数据的列表中 - To find the value on X axis corresponding to an arbitrary value of Y that doesn't contain in the list used to plot the data in python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM