Re: [R] Finding points with equal probability betweennormaldistributions

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.be>
Date: Mon 07 Aug 2006 - 22:15:57 EST

> 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@mail.cryst.bbk.ac.uk>
> To: <r-help@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@stat.math.ethz.ch 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.
>>
>
>
> Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
>
> ______________________________________________
> R-help@stat.math.ethz.ch 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.
>

Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm



R-help@stat.math.ethz.ch 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. Received on Mon Aug 07 22:15:48 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 08 Aug 2006 - 00:19:00 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.