在左侧和右手的两条曲线之间划分绿色区域
您好,如何计算绿色区域(以python为python)的值,该绿色区域的价值位于蓝线和蓝线右侧的其他区域?
因此,只有在黑线在黄线上的地方(线是由数组而不是函数产生的)
< img src =“ https://i.sstatic.net/fhbkk.png” alt =“显示Ilustrativ曲线”>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您的黑线向量
f
和黄线g
是在同一点定义的,则可以集成曲线h = f -g
其中h
大于零:如果您的
x
值存储在vectorxx /code>,并且图块之间两个部分之间的截止是
cutoff
(蓝线),然后您可以用numpy> numpy.trapz
:example Output(带有估计的输入数据):
Provided your vectors of your black line
f
and your yellow lineg
are defined at the same points, you can integrate the curveh = f - g
whereh
is greater than zero:If your
x
values are stored in a vectorxx
and your cutoff between the two parts of your plot iscutoff
(the blue line) then you can calculate the integral ofh_positive
numerically withnumpy.trapz
:Example output (with estimated input data):
让黑线为函数f(x),黄色为g(x)。您想做的是计算积分:
从算法上讲,您要做的是:
找到蓝线和X轴的交集,将X轴分为左右间隔。
对于每个间隔,请执行以下操作:
2.1。查找f(x),g(x)
的交点
2.2。找到G(x)&lt的间隔; f(x)
2.3。对于步骤2.2的每个间隔:
2.3.1计算上述积分以找到绿色区域
每个 技能可以为您提供细节。
Let the black line be a function f(x) and yellow be g(x). What you want to do is calculate the integral:
Algorithmically speaking what you have to do is:
Find the intersection of the blue line and the x-axis to split to left and right interval.
For each interval do the following:
2.1. Find intersection points of f(x), g(x)
2.2. Find the intervals for which g(x) < f(x)
2.3. For each interval of step 2.2:
2.3.1 Calculate the integral mentioned above to find the green area
I haven't worked with Python for Mathematical computations so I can't really guide you through the Python steps but hopefully my comment along with your googling skills can give you the specifics.