Hi, I'd like to find which values of x will give me a y. In other words, in the example of a gaussian curve, I want to find the values of x that will give me a density, let's say, of 0.02. curve(((1/(sqrt(2*pi)*10))*exp(-((x-50)^2)/(2*10^2))),xlim=c(0,100)) Thanks for any help, Antonio Olinto ------------------------------------------------- WebMail Bignet - O seu provedor do litoral www.bignet.com.br
Antonio Olinto wrote:> Hi, > > I'd like to find which values of x will give me a y. > > In other words, in the example of a gaussian curve, I want to find the values of > x that will give me a density, let's say, of 0.02. > > curve(((1/(sqrt(2*pi)*10))*exp(-((x-50)^2)/(2*10^2))),xlim=c(0,100))Numerical optimization might help: optimize( function(x) (1/(sqrt(2*pi)*10) * exp(-((x-50)^2)/(2*10^2)) - 0.02)^2, interval = c(0, 50)) Uwe Ligges> Thanks for any help, > > Antonio Olinto > > > > > ------------------------------------------------- > WebMail Bignet - O seu provedor do litoral > www.bignet.com.br > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, reproducible code.
>>>>> "AOlinto" == Antonio Olinto <aolinto_r at bignet.com.br> >>>>> on Mon, 7 Aug 2006 19:49:42 -0300 writes:AOlinto> Hi, AOlinto> I'd like to find which values of x will give me a y. AOlinto> In other words, in the example of a gaussian curve, I want to find the values of AOlinto> x that will give me a density, let's say, of 0.02. AOlinto> curve(((1/(sqrt(2*pi)*10))*exp(-((x-50)^2)/(2*10^2))),xlim=c(0,100)) In other words, you are trying to *invert a function* numerically, i.e., find x such that f(x) = y0 Now, this is trivially the same as finding the "root" (or "zero") of the function f~(x) = f(x) - y0 ==> Use *the* R root finding function : uniroot() [or polyroot() if f(.) is a polynomial] Martin Maechler, ETH Zurich