This question already has an answer here:

I have two normally distributed random variables (estimated from two different sets of samples), and I'd like to know how "similar" those variables are (in order to compare the sets).

I had the idea of calculating the area common to both the PDFs of those variables, which would be between 0 and 1 (I think).

This would be the integral of the minimum of each PDF on every point (I think). I'm struggling a bit on calculating this, though.

If I was doing this manually, I'd calculate the intersections between the two PDFs, see which was the minimum PDF on each region, and integrate each separately.

However, I need to do this on a computer, for any two normal distributions. Is there a way to compute this easily?

Also, am I on the right track? Are there better ways of comparing two distributions?


marked as duplicate by Dilip Sarwate, whuber Apr 27 '15 at 15:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ The pdfs of two normal random variables have "intersection" everywhere since the normal pdf has nonzero value everywhere on the real line. $\endgroup$ – Dilip Sarwate Apr 26 '15 at 16:08
  • $\begingroup$ @DilipSarwate Yes, of course. I used the word "intersection" with two different meanings: the first referred to intersection of areas, the second referred to intersection of functions. In retrospective, it was a bad word choice, I'll try to make it clearer $\endgroup$ – goncalopp Apr 26 '15 at 16:20

It is unclear what is the difficulty with computing the area of the interstection between both cdfs. Here is an unsophisticated R implementation.

> comp=function(x,mean1,sd1,mean2,sd2){
 if (length(x)==1){ 
> integrate(comp,low=-Inf,upp=Inf,mean1=0,mean2=4,sd1=1,sd2=1)
0.04550026 with absolute error < 3.8e-05

which provides the common area under both densities.

Alternatives to this measure abound, from the metric ones ($L^1$, $L^p$, ...) to Kullback-Leibler divergence. Some, contrary to that one, are invariant to reparametrisation.

  • $\begingroup$ From how easy this seems, I think my main problem now is being using a imperative language instead of R :) $\endgroup$ – goncalopp Apr 26 '15 at 16:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.