Inverse Error Function In R
Contents |
[ author ] Nathan Dabney wrote: >
R Pnorm
Do any of the R libraries have an implementation of the Inverse Error > Function complementary error function (Inverse ERF)? > > ref: > http://mathworld.wolfram.com/InverseErf.html > http://functions.wolfram.com/GammaBetaErf/InverseErf/ > > Thanks, > Nathan > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > erfc https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Don't know of a built-in function, but you can try this: ## if you want the so-called 'error function' ## from ?pnorm erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1 erf.inv <- function(x) qnorm((x + 1)/2)/sqrt(2) erf.inv(1) erf.inv(0) erf.inv(-1) erf.inv(erf(.25)) erf(erf.inv(.25)) erf.inv(.5) HTH, --sundar Previous message: [R] Inverse Error Function Next message: [R] Inverse Error Function Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] More information about the R-help mailing list
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings
Normal Distribution
and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it https://stat.ethz.ch/pipermail/r-help/2006-June/108153.html only takes a minute: Sign up R Error Function Erf(z) up vote 2 down vote favorite 1 This could be a quick one. I have not been able to find a function for the mathematical "error function" or the "inverse error function" in R. I have not seen a package either. I am aware I can script this but I http://stackoverflow.com/questions/29067916/r-error-function-erfz thought someone MUST have made a package for its various approximations by now. Could be poor googling due to generic terms "error function". Thanks in advance.. r function statistics share|improve this question asked Mar 16 '15 at 0:25 deposition 3215 The pracma package has the erf function. –eipi10 Mar 16 '15 at 0:29 Re: search terms -- try "Gaussian error function", I think that brings up the right thing. –Robert Dodier Mar 16 '15 at 16:55 add a comment| 1 Answer 1 active oldest votes up vote 6 down vote These are very closely related to pnorm() and qnorm(): see the last 4 lines of the example code in ?pnorm: ## if you want the so-called 'error function' erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1 ## (see Abramowitz and Stegun 29.2.29) ## and the so-called 'complementary error function' erfc <- function(x) 2 * pnorm(x * sqrt(2), lower = FALSE) ## and the inverses erfinv <- function (x) qnorm((1 + x)/2)/sqrt(2) erfcinv <- function (x) qnorm(x/2, lower = FALSE)/sqrt(2) If you
Arguments x, y vector http://grokbase.com/t/r/r-help/066tkpncyt/r-inverse-error-function of real numbers. z real or complex number; must be a scalar. Details erf and erfinv are the error and inverse error functions. erfc error function and erfcinv are the complementary error function and its inverse. erfcx is the scaled complementary error function. erfz is the complex, erfi the imaginary error function. Value Real or complex inverse error function number(s), the value(s) of the function. Note For the complex error function we used Fortran code from the book S. Zhang & J. Jin “Computation of Special Functions” (Wiley, 1996). Author(s) First version by Hans W Borchers; vectorized version of erfz by Michael Lachmann. See Also pnorm Examples x <- 1.0 erf(x); 2*pnorm(sqrt(2)*x) - 1 # [1] 0.842700792949715 # [1] 0.842700792949715 erfc(x); 1 - erf(x); 2*pnorm(-sqrt(2)*x) # [1] 0.157299207050285 # [1] 0.157299207050285 # [1] 0.157299207050285 erfz(x) # [1] 0.842700792949715 erfi(x) # [1] 1.650425758797543 [Package pracma version 1.9.5 Index]
reply Tweet Search Discussions Search All Groups r-help 2 responses Oldest Nested Sundar Dorai-Raj Don't know of a built-in function, but you can try this: ## if you want the so-called 'error function' ## from ?pnorm erf <- function(x) 2 * pnorm(x * sqrt(2)) - 1 erf.inv <- function(x) qnorm((x + 1)/2)/sqrt(2) erf.inv(1) erf.inv(0) erf.inv(-1) erf.inv(erf(.25)) erf(erf.inv(.25)) erf.inv(.5) HTH, --sundar Sundar Dorai-Raj at Jun 26, 2006 at 7:44 pm ⇧ Nathan Dabney wrote:Do any of the R libraries have an implementation of the Inverse ErrorFunction (Inverse ERF)?ref:http://mathworld.wolfram.com/InverseErf.htmlhttp://functions.wolfram.com/GammaBetaErf/InverseErf/Thanks,Nathan[[alternative HTML version deleted]]______________________________________________R-help at stat.math.ethz.ch mailing listhttps://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide! http://www.R-project.org/posting-guide.htmlDon't know of a built-in function, but you can try this:## if you want the so-called 'error function'## from ?pnormerf <- function(x) 2 * pnorm(x * sqrt(2)) - 1erf.inv <- function(x) qnorm((x + 1)/2)/sqrt(2)erf.inv(1)erf.inv(0)erf.inv(-1)erf.inv(erf(.25))erf(erf.inv(.25))erf.inv(.5)HTH,--sundar reply | permalink Ravi Varadhan Hi, You can use the following relation between standard normal probability distribution (\Phi) and error function: Erf(z) = 2 * \Phi(\sqrt(2) z) - 1 to evaluate invErf(x) in R as follows: invErf <- function(x) { # argument x must lie between -1 and 1 qnorm((1 + x) /2) / sqrt(2) } For example, [1] 0.4769362762 Hope this helps, Ravi. -------------------------------------------------------------------------- Ravi Varadhan, Ph.D. Assistant Professor, The Center on Aging and Hea