I want to solve the following equation for x p=a*exp(-x^2/2)+b*P(Z>x) where p,a,b are known, Z is a standard normal variable. Clearly there is no analytic form for P(Z>x). I am wondering if any expert could direct one easy way on this. Thank you.
Try something like this:> g <- function(x) return(p-a*exp(-x^2/2)+b*pnorm(x,0,1,lower.tail=F)) > p <- -0.5 > a <- 1 > b <- 1> uniroot(g,c(-100,10))$root [1] -1.336607 $f.root [1] 4.738e-06 $iter [1] 11 $estim.prec [1] 6.103516e-05 Regards, Andreas ----- Original Message ----- From: "Cunningham Kerry" <kerryrekky at yahoo.com> To: <r-help at stat.math.ethz.ch> Sent: Sunday, November 06, 2005 10:47 PM Subject: [R] solving a complicated equation>I want to solve the following equation for x > > p=a*exp(-x^2/2)+b*P(Z>x) > > where p,a,b are known, Z is a standard normal > variable. Clearly there is no analytic form for > P(Z>x). > > I am wondering if any expert could direct one easy way > on this. Thank you. > > ______________________________________________ > R-help at 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 >
Try ?uniroot and ?pnorm. On 7/11/2005 11:47 a.m., Cunningham Kerry wrote:> I want to solve the following equation for x > > p=a*exp(-x^2/2)+b*P(Z>x) > > where p,a,b are known, Z is a standard normal > variable. Clearly there is no analytic form for > P(Z>x). > > I am wondering if any expert could direct one easy way > on this. Thank you. > > ______________________________________________ > R-help at 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-- James Reilly Department of Statistics, University of Auckland Private Bag 92019, Auckland, New Zealand
Try this: f <- function(x, a, b, p) a * exp(-x*x/2)+ b * pnorm(x, lower.tail = FALSE) - p uniroot(f, lower = -3, upper = 3, a = 1, b = 1, p = 0.5) On 11/6/05, Cunningham Kerry <kerryrekky at yahoo.com> wrote:> I want to solve the following equation for x > > p=a*exp(-x^2/2)+b*P(Z>x) > > where p,a,b are known, Z is a standard normal > variable. Clearly there is no analytic form for > P(Z>x). > > I am wondering if any expert could direct one easy way > on this. Thank you. > > ______________________________________________ > R-help at 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 >