loglikelihood.negativebinomial(mean : number, dispersion : number, k : number) 🡒 number, autodiff pure function

The logarithm of the likelihood of the negative binomial distribution. The first argument is the mean of the negative binomial distribution. It should be positive. The second argument is the dispersion of the negative binomial. It should be greater or equal to 1. The dispersion $d$ follows the relationship $\sigma^2 = d * \mu$, where $\sigma^2$ is the variance and $\mu$ is the mean. The third argument is the observation. It should be a non-negative integer.


table T = extend.range(1000)
mu0 = 1
d0 = 2

// learn a parametric distribution from observations
T.X = random.negativebinomial(mu0 into T, d0)
autodiff T with
  params mu auto
  params d in [1.0 ..] auto(1.5, 0.1)
  return -loglikelihood.negativebinomial(mu, d, T.X)

show summary "Regressed negative binomial distribution" a1b1 with mu, d // 1.05, 2.03