[R] Point of intersection

jim holtman jholtman at gmail.com
Fri Oct 3 14:18:12 CEST 2008


Here it is by hand.  You can probably create an iterative solution:

> x=seq(-10,10,length=100)
> p1=dnorm(x,0,1)
> plot(x,p1,type='n',ylab="Density",main="Overlap Measure")
>
>
> points(x,p1,type='l')
> abline(0.07,0.01)
>
> f.x <- function(x) abs(dnorm(x,0,1) - (.07 + .01*x))
>
> optimize(f.x, c(-10,0))
$minimum
[1] -7.000003

$objective
[1] 3.463897e-08

> optimize(f.x, c(-5,0))
$minimum
[1] -2.042199

$objective
[1] 9.272141e-07

> optimize(f.x, c(-2,10))
$minimum
[1] 1.742439

$objective
[1] 3.366173e-07

>


On Thu, Oct 2, 2008 at 11:44 PM, Lavan <rsumithran at yahoo.com> wrote:
>
> Hi,
>
> Let say I have a normal density X~n(0,1) and I have a line y=0.01x+0.07. the
> following code generate the plots.
>
> x=seq(-10,10,length=100)
> plot(x,p1,type='n',ylab="Density",main="Overlap Measure",xaxt="n",yaxt="n")
>
> pi=dnorm(x,0,1)
> points(x,p1,type='l')
> abline(0.07,0.01)
>
> you can see that the curves intersects at 3 points. My question is how do I
> mark the point of the intersection? I like to mark it as (x1,y1) as the
> first point of intersection and so on. or I can just mark the x-coordinate
> of the 1st intersection as x1 on the x-axis.
>
> Thanks,
>
> lavan
> --
> View this message in context: http://www.nabble.com/Point-of-intersection-tp19791632p19791632.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



More information about the R-help mailing list