# [R] Finding points with equal probability betweennormaldistributions

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.be
Mon Aug 7 14:15:57 CEST 2006

```----- Original Message -----
From: "Dimitris Rizopoulos" <dimitris.rizopoulos at med.kuleuven.be>
To: "Eleni Rapsomaniki" <e.rapsomaniki at mail.cryst.bbk.ac.uk>
Cc: <r-help at stat.math.ethz.ch>
Sent: Monday, August 07, 2006 1:18 PM
Subject: Re: [R] Finding points with equal probability
betweennormaldistributions

> if you want to base it on Normality, then you can use:
>
> prob <- function(x){
>    dnorm((x - 5.2) / 2.1) / 2.1 - dnorm((x - 4.2) / 1.1) / 1.1
> }
>
> uniroot(prob, c(-3, 3))
>

sorry but the above gives you only the one solution, probably you need
both:

dn <- function(x){
dnorm(x, 5.2, 2.1) - dnorm(x, 4.2, 1.1)
}

rout1 <- uniroot(dn, c(0, 5))\$root
rout2 <- uniroot(dn, c(5, 10))\$root

x <- seq(-3, 14, 0.1)
plot(x, dnorm(x, 4.2,  1.1), type = "l", col = "red")
lines(x, dnorm(x, 5.2, 2.1), col = "blue")
abline(v = c(rout1, rout2))

Best,
Dimitris

> otherwise if you want to estimate it you can use Uwe's solution.
>
>
> I hope it helps.
>
> Best,
> Dimitris
>
> ----
> Dimitris Rizopoulos
> Ph.D. Student
> Biostatistical Centre
> School of Public Health
> Catholic University of Leuven
>
> Address: Kapucijnenvoer 35, Leuven, Belgium
> Tel: +32/(0)16/336899
> Fax: +32/(0)16/337015
> Web: http://med.kuleuven.be/biostat/
>     http://www.student.kuleuven.be/~m0390867/dimitris.htm
>
>
> ----- Original Message -----
> From: "Eleni Rapsomaniki" <e.rapsomaniki at mail.cryst.bbk.ac.uk>
> To: <r-help at stat.math.ethz.ch>
> Sent: Monday, August 07, 2006 12:35 PM
> Subject: [R] Finding points with equal probability between
> normaldistributions
>
>
>> Dear mailing list,
>>
>> For two normal distributions, e.g:
>>
>> r1 =rnorm(20,5.2,2.1)
>> r2 =rnorm(20,4.2,1.1)
>> plot(density(r2), col="blue")
>> lines(density(r1), col="red")
>>
>> Is there a way in R to compute/estimate the point(s) x where the
>> density of the
>> two distributions cross (ie where x has equal probability of
>> belonging to
>> either of the two distributions)?
>>
>> Many Thanks
>>
>> Eleni Rapsomaniki
>> PhD student
>> Birkbeck College, UK
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>
>
> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help