【问题标题】:R zipfR and Wolfram Mathematica return different values for inverse regularized incomplete gamma functionR zipfR 和 Wolfram Mathematica 为逆正则化不完全伽马函数返回不同的值
【发布时间】:2019-08-22 17:57:39
【问题描述】:

zipfR 库函数 Rgamma.inv 和 wolfram mathematica 函数 InverseGammaRegularized 为某些输入返回不同的值。两者之间的数学区别是什么?

我的偏好是使用 R,我的目标是使用 R 中的一个函数,该函数输出经验 CDF 的泊松参数。 wolfram alpha 函数可以很好地做到这一点,但 Rgamma.inv 没有。以下是 R 中的代码示例,然后是 wolfram mathematica 中的代码示例。

Rgamma.inv(11, ppois(10, 10.66852))
#returns 10.66852 which is correct

Rgamma.inv(101, ppois(100, 60* 20/9))
#returns 73.83016, not 133.33
InverseGammaRegularized[11,0.5]
#returns 10.66852 which is correct

InverseGammaRegularized[101,0.001543465] 
#returns 133.33 which is correct

【问题讨论】:

    标签: r wolfram-mathematica poisson


    【解决方案1】:

    两者都是正确的。只是您在使用 R 时计算较低的正则化伽玛,但在使用 wolfram mathematica 时正在计算上层正则化伽玛。您正在比较两个不同的结果。因此不会相同。要获得相同的结果,请确保您也使用 R 计算上正则化 gamma 并进行比较:

    使用 R:

    计算上正则化 gamma:

    Rgamma.inv(11, ppois(10, 10.66852),lower = FALSE)
    [1] 10.66852
    Rgamma.inv(101, ppois(100, 60* 20/9),lower = FALSE)
    [1] 133.3333
    

    这些是上面给出的结果

    【讨论】:

    • 是的。还要注意Rgamma.inv()stats::qgamma() 的薄包装; qgamma(x=ppois(100, 60* 20/9), shape=101, lower.tail=FALSE) 给出相同的结果...
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-23
    • 1970-01-01
    • 1970-01-01
    • 2018-07-22
    • 1970-01-01
    相关资源
    最近更新 更多