本文介绍了计算两条曲线之间的面积(即正态分布)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要计算两条曲线之间的面积.我有很多数据,所以我想通过编程来完成.

I need to calculate the area between two curves.I have lots of data, so I'd like to do it programmatically.

基本上,我总是有2个正态分布,根据平均值和标准偏差计算得出.然后,我想计算它们相交的程度.这是我的意思的示例,以及还有一些 R 中的代码(我不知道).

Basically, I always have 2 normal distributions, calculated from a mean value and standard deviation. I would then like to calculate how much they intersect.Here is an example of what I mean, and also some code in R (that I don't know).

matplotlibscipy 或其他一些模块中是否已经有一个函数可以为我完成它?万一我必须自己实现它,我认为我应该这样做:

Is there already a function in matplotlib or scipy or some other module that does it for me?In case I have to implement it myself, I think that I should do:

  • 找到交点(最多有 2 个)
  • 查看交点之前,之间和之后哪个函数较低
  • 计算下部函数的积分并将它们全部加在一起

是吗?我该如何完成单个步骤?有功能,模块等可以帮助您吗?

Is that right? How can I do the single steps? Are there functions, modules, etc that can help?

推荐答案

我也不知道 R,但答案似乎在您提供的链接中:只集成最少的发行版.您不需要找到交点,只需将 min(f(x), g(x)) 提供给 scipy.integrate.quad.

I don't know R either, but the answer seems to be in the link you provided: just integrate the minimum of your distributions.You don't need to find intersections, just feed min(f(x), g(x)) to scipy.integrate.quad.

这篇关于计算两条曲线之间的面积(即正态分布)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 15:52