错误功能Erf(z)

dep*_*ion 12 statistics r function

这可能是一个快速的.

我无法在R中找到数学"错误函数"或"反向错误函数"的函数.我也没有看过包.

我知道我可以编写这个脚本,但我认为有人必须为它的各种近似值制作一个包.由于通用术语"错误功能",可能是糟糕的谷歌搜索...

Ben*_*ker 29

这些都是非常密切的关系pnorm()qnorm():看最后的4行的示例代码?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)
Run Code Online (Sandbox Code Playgroud)

如果你想使用复数值的参数,你需要erfzpracma包中(如上面@ eipi10所述).否则,不清楚使用这些版本是否有优势pracma(在各种参数值的实现pnorm()qnorm()已经过彻底测试......)

就搜索而言,

library("sos")
findFn("erf")
Run Code Online (Sandbox Code Playgroud)

似乎工作得很好......