我很难理解R中的pnbinom(q, size, prob, mu, lower.tail = TRUE, log.p = FALSE)
是如何连接到scipy中的scipy.stats.nbinom.pmf(k,n,p,loc=0(的。
对于R函数,参数的定义如下。
q =vector of quantiles.
size = target for number of successful trials, or dispersion parameter (the shape parameter of the gamma mixing distribution). Must be strictly positive, need not be integer.
prob =probability of success in each trial. 0 < prob <= 1.
mu = alternative parametrization via mean: see ‘Details’.
log, log.p =logical; if TRUE, probabilities p are given as log(p).
lower.tail = logical; if TRUE (default), probabilities are P[X ≤ x], otherwise, P[X > x].
对于SciPy函数,参数定义如下。
n is the number of successes
p is the probability of a single success.
例如,如果
k=20
a=1.2
p=0.1
在R中,pnbinom(k,a,p) = 0.8518848
。这里,k
插入q
,即分位数的矢量,a
插入size
,p
插入"prob"。
另一方面,在SciPy中,我假设n
是用作size
的,p
是我们在R中用作prob
的。在该设置中,nbinom.pmf(k, a, p) = 0.01530062999480606
。
有人能帮我确认一下我缺了什么吗?
nbinom.pmf(k, a, p)
返回pmf(概率质量函数(,而pnbinom(k, a, p)
是cdf(累积分布函数(。
尝试nbinom.cdf(k, a, p)
从scipy中获取cdf,或者尝试dnbinom(k, a, p)
在R.中获取pmf