[R] intersection of 2 density curves

Monica Pisica pisicandru at hotmail.com
Thu Oct 8 15:48:03 CEST 2009



Hi,
 
I would like to find out the coordinates of the intersection points of 2 density curves. I did a search but i didn't get any significant results. I really hope some of you have some ideas. here it is an example:
 
set.seed(123)
x1 <- rnorm(100, 1, 1)
x2 <- rnorm(100, 0, 1)
d1 <- density(x1)
d2 <- density(x2)
 
plot(d1, col = 2)
 lines(d2, col = 4)

Now i would like to know the coordinates of the intersection point. I did some "trial and error" and i come up with these .... (that means i did several vertical and horizontal lines through the graph until visually i "hit" the intersection point)
 
abline(v = 0.35, lty = 2)
abline(h = 0.34, lty = 2)
 
I really appreciate any hints you may have, thanks so much,
 
Monica 		 	   		  
_________________________________________________________________
Your E-mail and More On-the-Go. Get Windows Live Hotmail Free.
http://clk.atdmt.com/GBL/go/171222985/direct/01/



More information about the R-help mailing list