daniel f.
daniel f.

Reputation: 1461

Calculate area between two curves (that are normal distributions)

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:

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

Upvotes: 2

Views: 3079

Answers (1)

ev-br
ev-br

Reputation: 26070

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.

Upvotes: 3

Related Questions