Negative Binomial Distribution with alternative parameterization.
Uses the parameterization:
- r = a (number of successes, can be any positive real)
- p = 1 / (1 + b) (probability of success)
Which gives:
- mean = a * b
- variance = a * b * (1 + b)
Under this parameterisation, as b -> 0, the distribution will converge to Poisson(ab). The parameter b is therefore a measure of overdispersion.
Implementation uses the gamma-Poisson mixture representation, which allows non-integer a: If λ ~ Gamma(a, b) and X | λ ~ Poisson(λ), then X ~ NegativeBinomial(a, b)
Value parameters
- a
-
shape parameter (must be positive, can be non-integer)
- b
-
scale/dispersion parameter (must be positive)
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait HasVariance[Double]trait HasCdf[Int]trait HasMean[Double]trait DiscreteDistr[Int]trait Rand[Int]trait Density[Int]class Objecttrait Matchableclass AnyShow all
Members list
Value members
Concrete methods
Draw using gamma-Poisson mixture: λ ~ Gamma(a, b), X | λ ~ Poisson(λ)
Draw using gamma-Poisson mixture: λ ~ Gamma(a, b), X | λ ~ Poisson(λ)
Attributes
Log PMF: log P(X = k) = logΓ(a + k) − logΓ(a) − logΓ(k + 1) + a·log(p) + k·log(1−p).
Log PMF: log P(X = k) = logΓ(a + k) − logΓ(a) − logΓ(k + 1) + a·log(p) + k·log(1−p).
For k ≥ 1 the gamma terms equal −log k − log B(a, k). Differencing log Γ directly loses ~a·log(a)·ε absolutely, which is garbage for large a (near-Poisson fits, NegativeBinomial.poisson); log B is evaluated without that cancellation.
Attributes
- Definition Classes
As plot, applying mods (e.g. Plots.fixedSize) to the spec after the built-in modifications.
As plot, applying mods (e.g. Plots.fixedSize) to the spec after the built-in modifications.
Attributes
As plotCdf, applying mods (e.g. Plots.fixedSize) to the spec after the built-in modifications.
As plotCdf, applying mods (e.g. Plots.fixedSize) to the spec after the built-in modifications.
Attributes
Attributes
- Definition Classes
PMF: P(X = k) = Γ(a + k) / (Γ(a) * k!) * p^a * (1-p)^k
PMF: P(X = k) = Γ(a + k) / (Γ(a) * k!) * p^a * (1-p)^k
Attributes
Inherited methods
Returns the unnormalized value of the measure
Overridden by filter/map/flatmap for monadic invocations. Basically, rejection samplers will return None here
Overridden by filter/map/flatmap for monadic invocations. Basically, rejection samplers will return None here
Attributes
- Inherited from:
- Rand
Returns the log unnormalized value of the measure
Returns the log unnormalized value of the measure
Attributes
- Definition Classes
- Inherited from:
- DiscreteDistr
Converts a random sampler of one type to a random sampler of another type. Examples: uniform.map(_2) gives a Rand[Double] in the range [0,2] Equivalently, for(x <- uniform) yield 2x
Converts a random sampler of one type to a random sampler of another type. Examples: uniform.map(_2) gives a Rand[Double] in the range [0,2] Equivalently, for(x <- uniform) yield 2x
Value parameters
- f
-
the transform to apply to the sampled value.
Attributes
- Inherited from:
- Rand
An iterator over the names of all the elements of this product.
An iterator over the names of all the elements of this product.
Attributes
- Inherited from:
- Product
An iterator over all the elements of this product.
An iterator over all the elements of this product.
Attributes
- Returns
-
in the default implementation, an
Iterator[Any] - Inherited from:
- Product
Gets n samples from the distribution.
Gets one sample from the distribution. Equivalent to get
Gets n samples from the distribution into a specified collection type.
Gets n samples from the distribution into a specified collection type.
Attributes
- Inherited from:
- Rand
An infinitely long iterator that samples repeatedly from the Rand
An infinitely long iterator that samples repeatedly from the Rand
Attributes
- Returns
-
an iterator that repeatedly samples
- Inherited from:
- Rand
Attributes
- Inherited from:
- DiscreteDistr
Returns the probability of that draw up to a constant
Attributes
- Inherited from:
- Rand