size and prob.
It also allows sampling from the truncated distribution.
[Special Generator] -- Sampling Function: Negative Binomial.urnbinom(n, size, prob, lb = 0, ub = Inf)0 < prob <= 1<="" code="">.=>size $= n$ and
prob $= p$ has density
$$p(x) = \frac{\Gamma(x+n)}{\Gamma(n) x!} p^n (1-p)^x$$
for $x = 0, 1, 2, \ldots$, $n > 0$ and $0 < p \le 1$.
This represents the number of failures which occur in a sequence of
Bernoulli trials before a target number of successes is reached. The generation algorithm uses guide table based inversion when the
tails are not too heavy and method lb and ub can be used to generate
variates from the Negative Binomial distribution truncated to the
interval (lb,ub).
runif and .Random.seed about random number
generation, unuran for the UNU.RAN class, and
rnbinom for the Rbuilt-in generator.## Create a sample of size 1000
x <- urnbinom(n=1000,size=10,prob=0.3)Run the code above in your browser using DataLab