pypomp.random.nbinomial_logw

pypomp.random.nbinomial_logw(x: Array, n: Array | float, p: Array | float | None = None, mu: Array | float | None = None) → Array[source]

DPOP log-weight of a negative binomial draw, such as from fast_nbinomial().

Parameters:
  • x (jax.Array) – The number of failures before n successes.

  • n (jax.Array or float) – The size parameter. Unlike the binomial’s number of trials, it is not held fixed, so its gradient is included.

  • p (jax.Array, float or None, optional) – The success probability. Mutually exclusive with mu.

  • mu (jax.Array, float or None, optional) – The mean, n * (1 - p) / p. Mutually exclusive with p.

Returns:

lgamma(x + n) - lgamma(n) + n * log(p) + x * log(1 - p), with p = n / (n + mu) when mu is given and x held fixed.

Return type:

jax.Array