| Nbinom-class {distr} | R Documentation |
Class "Nbinom"
Description
The negative binomial distribution with size = n, by default =1, and
prob = p, by default =0.5, has density
d(x) = \frac{\Gamma(x+n)}{\Gamma(n) x!} p^n (1-p)^x
for x = 0, 1, 2, \ldots
This represents the number of failures
which occur in a sequence of Bernoulli trials before a target number
of successes is reached.
C.f. rnbinom
Objects from the Class
Objects can be created by calls of the form Nbinom(prob, size).
This object is a negative binomial distribution.
Slots
imgObject of class
"Naturals": The space of the image of this distribution has got dimension 1 and the name "Natural Space".paramObject of class
"NbinomParameter": the parameter of this distribution (prob, size), declared at its instantiationrObject of class
"function": generates random numbers (calls functionrnbinom)dObject of class
"function": density function (calls functiondnbinom)pObject of class
"function": cumulative function (calls functionpnbinom)qObject of class
"function": inverse of the cumulative function (calls functionqnbinom). The quantile is defined as the smallest valuexsuch thatF(x) \ge p, whereFis the distribution function.supportObject of class
"numeric": a (sorted) vector containing the support of the discrete density function.withArithlogical: used internally to issue warnings as to interpretation of arithmetics
.withSimlogical: used internally to issue warnings as to accuracy
.logExactlogical: used internally to flag the case where there are explicit formulae for the log version of density, cdf, and quantile function
.lowerExactlogical: used internally to flag the case where there are explicit formulae for the lower tail version of cdf and quantile function
Symmetryobject of class
"DistributionSymmetry"; used internally to avoid unnecessary calculations.
Extends
Class "DiscreteDistribution", directly.
Class "UnivariateDistribution", by class "DiscreteDistribution".
Class "Distribution", by class "DiscreteDistribution".
Methods
- initialize
signature(.Object = "Nbinom"): initialize method- prob
signature(object = "Nbinom"): returns the slotprobof the parameter of the distribution- prob<-
signature(object = "Nbinom"): modifies the slotprobof the parameter of the distribution- size
signature(object = "Nbinom"): returns the slotsizeof the parameter of the distribution- size<-
signature(object = "Nbinom"): modifies the slotsizeof the parameter of the distribution- +
signature(e1 = "Nbinom", e2 = "Nbinom"): For the negative binomial distribution we use its closedness under convolutions.
Note
Working with a computer, we use a finite interval as support which carries at least mass 1-getdistrOption("TruncQuantile").
Author(s)
Thomas Stabla statho3@web.de,
Florian Camphausen fcampi@gmx.de,
Peter Ruckdeschel peter.ruckdeschel@uni-oldenburg.de,
Matthias Kohl Matthias.Kohl@stamats.de
See Also
NbinomParameter-class
Geom-class
DiscreteDistribution-class
Naturals-class
rnbinom
Examples
N <- Nbinom(prob = 0.5, size = 1) # N is a binomial distribution with prob=0.5 and size=1.
r(N)(1) # one random number generated from this distribution, e.g. 3
d(N)(1) # Density of this distribution is 0.25 for x=1.
p(N)(0.4) # Probability that x<0.4 is 0.5.
q(N)(.1) # x=0 is the smallest value x such that p(B)(x)>=0.1.
## in RStudio or Jupyter IRKernel, use q.l(.)(.) instead of q(.)(.)
size(N) # size of this distribution is 1.
size(N) <- 2 # size of this distribution is now 2.