Python 中带有 log.p 参数的 R 的 qchisq?
R's qchisq in Python with the log.p argument?
这里的非统计学家试图复制 Python 中的一些代码。
R 具有函数 qchisq
。
qchisq(c(0.5, 0.1, 0.99), df=1, lower.tail=F)
# [1] 0.4549364231 2.7055434541 0.0001570879
它可以像这样在 Python 中复制:
from scipy.special import chdtri
import pandas as pd
chdtri(1, pd.Series([0.5, 0.1, 0.99]))
# Out[57]:
# 0 0.454936
# 1 2.705543
# 2 0.000157
但是,Rs qchisq
也可以有标志 log.p
,这让我可以做:
qchisq(-c(0.5, 0.1, 0.99) * log(10), df=1, lower.tail=F, log.p=T)
# [1] 1.00448472 0.06796154 2.66885996
我在 Python 中找不到任何方法来执行此操作。我如何实现同样的目标?
也许在不设置 R:
参数的情况下尝试重新制作 log.p
的效果是有用的
qchisq(.5, 1, lower.tail = FALSE)
# 0.4549364
qchisq(-.5, 1, lower.tail = FALSE, log.p = TRUE)
# 0.265258
qchisq(exp(-.5), 1, lower.tail = FALSE)
# 0.265258
其中 log(10)
的部分给出:
qchisq(exp(-c(0.5, 0.1, 0.99)*log(10)), df=1, lower.tail=F)
# [1] 1.00448472 0.06796154 2.66885996
好像是qchisq(exp(x)) == qchisq(x, log.p = TRUE)
.
这里的非统计学家试图复制 Python 中的一些代码。
R 具有函数 qchisq
。
qchisq(c(0.5, 0.1, 0.99), df=1, lower.tail=F)
# [1] 0.4549364231 2.7055434541 0.0001570879
它可以像这样在 Python 中复制:
from scipy.special import chdtri
import pandas as pd
chdtri(1, pd.Series([0.5, 0.1, 0.99]))
# Out[57]:
# 0 0.454936
# 1 2.705543
# 2 0.000157
但是,Rs qchisq
也可以有标志 log.p
,这让我可以做:
qchisq(-c(0.5, 0.1, 0.99) * log(10), df=1, lower.tail=F, log.p=T)
# [1] 1.00448472 0.06796154 2.66885996
我在 Python 中找不到任何方法来执行此操作。我如何实现同样的目标?
也许在不设置 R:
参数的情况下尝试重新制作log.p
的效果是有用的
qchisq(.5, 1, lower.tail = FALSE)
# 0.4549364
qchisq(-.5, 1, lower.tail = FALSE, log.p = TRUE)
# 0.265258
qchisq(exp(-.5), 1, lower.tail = FALSE)
# 0.265258
其中 log(10)
的部分给出:
qchisq(exp(-c(0.5, 0.1, 0.99)*log(10)), df=1, lower.tail=F)
# [1] 1.00448472 0.06796154 2.66885996
好像是qchisq(exp(x)) == qchisq(x, log.p = TRUE)
.