udnbinom function

UNU.RAN object for Negative Binomial distribution

UNU.RAN object for Negative Binomial distribution

Create UNU.RAN object for a Negative Binomial distribution with parameters size and prob.

[Distribution] -- Negative Binomial.

udnbinom(size, prob, lb = 0, ub = Inf)

Arguments

  • size: target for number of successful trials, or dispersion parameter (the shape parameter of the gamma mixing distribution). Must be strictly positive.
  • prob: probability of success in each trial. 0 < prob <= 1.
  • lb: lower bound of (truncated) distribution.
  • ub: upper bound of (truncated) distribution.

Details

The Negative Binomial distribution with size =n= n and prob =p= p has density

p(x)=Γ(x+n)Γ(n)x!pn(1p)xp(x)=Gamma(x+n)/(Gamma(n)x!)pn(1p)x p(x) = \frac{\Gamma(x+n)}{\Gamma(n) x!} p^n (1-p)^xp(x) = Gamma(x+n)/(Gamma(n) x!) p^n (1-p)^x

for x=0,1,2,x = 0, 1, 2, \ldots, n>0n > 0 and 0<p10 < 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 domain of the distribution can be truncated to the interval (lb,ub).

Returns

An object of class "unuran.discr".

See Also

unuran.discr.

References

N.L. Johnson, S. Kotz, and A.W. Kemp (1992): Univariate Discrete Distributions. 2nd edition, John Wiley & Sons, Inc., New York. Sect. 5.1, p. 200.

Author(s)

Josef Leydold and Wolfgang H"ormann unuran@statmath.wu.ac.at .

Examples

## Create distribution object for Negative Binomial distribution dist <- udnbinom(size=100, prob=0.33) ## Generate generator object; use method DARI gen <- darid.new(dist) ## Draw a sample of size 100 x <- ur(gen,100)
  • Maintainer: Josef Leydold
  • License: GPL (>= 2)
  • Last published: 2024-10-04