50% off: Unlimited data and AI learning.
State of Data and AI Literacy Report 2025

distr (version 1.5)

Nbinom-class: Class "Nbinom"

Description

The negative binomial distribution with size $= n$, by default $=1$, and prob $= p$, by default $=0.5$, has density d(x)=Γ(x+n)Γ(n)x!pn(1p)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

Arguments

Objects from the Class

Objects can be created by calls of the form Nbinom(prob, size). This object is a negative binomial distribution.

Extends

Class "DiscreteDistribution", directly. Class "UnivariateDistribution", by class "DiscreteDistribution". Class "Distribution", by class "DiscreteDistribution".

See Also

NbinomParameter-class DiscreteDistribution-class Naturals-class rnbinom

Examples

Run this code
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.
size(N) # size of this distribution is 1.
size(N)=2 # size of this distribution is now 2.

Run the code above in your browser using DataLab