Handling Ratio of Gamma Functions in MLE for Dirichlet-Multinomial Distribution

63 Views Asked by At

I am trying to perform Maximum-Likelihood estimation for the $\boldsymbol{\alpha}$ parameters of the Dirichlet-Multinomial function for a single observation, taken from this paper:

$$ p(\boldsymbol{x}|\boldsymbol{\alpha})=\frac{\Gamma(\sum_{k}\alpha_k)}{\Gamma(\sum_kn_k+\alpha_k)}\prod_k\frac{\Gamma(n_k+\alpha_k)}{\Gamma(\alpha_k)} $$

To do this, I re-implemented the function in Python and tried to use some numerical optimization approaches for it, like scipy.optimize.minimize. However, if any $n_k$ gets reasonably large (>175), the Gamma function values overflow. This is not helped by e.g. log transformations.

Thus, I was wondering if there is any algebraic procedure to re-write the ratio of $\Gamma$ into an expression that does not get this large.

Alternatively, I am also happy for ways to handle the overflow.

1

There are 1 best solutions below

1
On

The issue seems to revolve round how to evaluate \begin{equation} \frac{\Gamma(n_1 + \alpha_1)\cdots\Gamma(n_K + \alpha_K)}{\Gamma(n_1 + \alpha_1 + \cdots + n_K + \alpha_K)}. \end{equation} You might want to work with the logarithm of this quantity instead. If you're doing MLE or MAP estimation this will come about naturally, a nice illustration here.

ADDED

Using a current version of scipy.special.loggamma I'm able to get $\log\Gamma(x)$ for $x = 10^{305}$.