【问题标题】:R qt equivalent in pythonpython中的R qt等价物
【发布时间】:2020-09-14 02:55:18
【问题描述】:

我有一个 R 函数,我正在尝试使用 scipy 在 python 中进行转换

R 功能:

lambda <- function(P) log(-log(P))
kt = function(x1, x2, n) suppressWarnings(qt(1 - x1, df = (n -1), ncp = (-sqrt(n) * lambda(x2))))

这是我开发的 python 等价物

R Func 的 Python 等价物

import scipy.stats as t
import nump as np
x = lambda P : np.log(-np.log(P))
kt = lambda x1,x2,n:(st.t.ppf(1 - x1, df = (n -1),scale=(-np.sqrt(n) * x(x2))))

现在我正在用数据测试这两个函数:

kt(0.05,0.99,15)

我在 python 中得到的结果与 R 不同。

我认为 scipy ppf 中没有导致此问题的参数 ncp。

R qt 是否有任何 python 的等效函数,我可以在这里使用 R 的所有参数,例如 df 和 ncp

【问题讨论】:

    标签: python r scipy


    【解决方案1】:

    您应该能够使用scipy.stats.nct,如文档here 中所示。

    【讨论】:

      猜你喜欢
      • 2018-07-18
      • 2016-06-14
      • 2016-05-23
      • 1970-01-01
      • 2022-10-13
      • 1970-01-01
      • 2013-06-13
      • 1970-01-01
      • 2020-04-17
      相关资源
      最近更新 更多