【问题标题】:Error Function Erf(z)误差函数 Erf(z)
【发布时间】:2015-03-16 00:25:40
【问题描述】:

这可能很快。

我无法在 R 中找到数学“误差函数”或“逆误差函数”的函数。我也没有看到包。

我知道我可以编写这个脚本,但我认为现在有人必须已经为它的各种近似值制作了一个包。由于通用术语“错误函数”,谷歌搜索可能很糟糕......

【问题讨论】:

  • pracma package 具有erf 功能。
  • Re: 搜索词——试试“高斯误差函数”,我认为这会带来正确的结果。

标签: r function statistics


【解决方案1】:

这些与pnorm()qnorm() 密切相关:参见?pnorm 中示例代码的最后4 行:

 ## 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)

如果你想使用复值参数,你需要来自pracma 包的erfz(正如上面@eipi10 所评论的那样)。否则,不清楚使用pracma 中的版本是否有优势(pnorm()qnorm() 的实现已经在各种参数值上进行了非常彻底的测试......)

就搜索而言,

library("sos")
findFn("erf")

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-09
    • 2015-09-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-12
    相关资源
    最近更新 更多