I am having hard time to understand how the pnbinom(q, size, prob, mu, lower.tail = TRUE, log.p = FALSE)
in R to the scipy.stats.nbinom.pmf(k, n, p, loc=0) in SciPy.
For the R function, the definitions of the parameters are as follows.
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].
For the SciPy function, the parameters are defined as follows.
n is the number of successes
p is the probability of a single success.
For example, if
k=20
a=1.2
p=0.1
In R, pnbinom(k,a,p) = 0.8518848
. Here, k
is plugged into q
i.e. the vector of quantiles, a
is plugged into size
, and p
is plugged into 'prob'.
On the other hand, in SciPy, I assumed n
is what used as size
and p
is what we used as prob
in R. In that setting, nbinom.pmf(k, a, p) = 0.01530062999480606
.
Could anyone please help to identify what I am missing?