Well-behaved log-likelihood of von Mises-Fisher distribution

68 Views Asked by At

I am trying to write a numerically stable version of the log-likelihood of the von Mises-Fisher distribution, specifically for the 2-sphere in $\mathbb{R}^3$.

The PDF can be written as

$$ f(\mathbf{x} | \boldsymbol{\mu}, \kappa) = C_3(\kappa)\exp(\kappa\boldsymbol{\mu}^T{}\mathbf{x}), $$

where

$$ C_3(\kappa) = \frac{\kappa}{4\pi\sinh\kappa}. $$

Now, the log likelihood can be written as

$$ L(\mathbf{x}|\boldsymbol{\mu}, \kappa) = \log(C_3(\kappa)) + \kappa\boldsymbol{\mu}^T\mathbf{x}. $$

I am using this log-likelihood inside a numerical optimization, and my problem is with the first term, which works out to

$$ \log\frac{\kappa}{4\pi\sinh\kappa}. $$

The first term has this massively expanding $\sinh$ function, and with any $\kappa >\, \sim\!50$ I'm getting numerical stability problems - a value for $\kappa$ that's not in any way unreasonable.

Is there any way I can write this term in a different way that does not require the computation of these extremely massive numbers to make my optimizer happy?

Thanks in advance!