Calculate area between two curves (that are normal distributions)

笑着哭i 提交于 2019-12-11 03:25:34

问题


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

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).

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:

  • find the intersections (there will be max 2)
  • see which function is lower before, [between], and after the intersection
  • calculate the integral of the lower function and add them all together

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


回答1:


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.



来源:https://stackoverflow.com/questions/15361125/calculate-area-between-two-curves-that-are-normal-distributions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!