I am trying to evaluate the log-likelihood of a mixture of weibull distributions and am running into problems with the numerical aspect. In short, I have $M$ mixtures and want to evaluate: $$ \log \left[ \sum_{m=1}^M \pi_m \frac{\beta_m}{\alpha_m} \left( \frac{x}{\alpha_m}\right)^{\beta_m -1} e^{-\left( \frac{x}{\alpha_m}\right)^{\beta_m}} \right] $$

with $\pi_m$ being the mixing probability, $\alpha_m$ and $\beta_m$ being parameters for distribution $m$ and $x$ being some data-point we've collected.

My problem comes from evaluating the exponential term here, where I often just get 0 on my computer due to the power being very negative. I have been reading and found the 'log-sum-exponential trick' at various sources, but it is unclear to me if this is valid when we have coefficients in-front of the exponential. Is there a known numerically stable way to evaluate this, and if the log-sum-exponential trick is indeed valid, can someone show how this works with the coefficients?

  • 1
    $\begingroup$ if all the terms in front of each exponential are positive you can do $ae^x = e^{x + \log a}$ to turn it into an actual log-sum-exp $\endgroup$ – jld Sep 1 '20 at 15:17
  • 1
    $\begingroup$ All the coefficients in front of the exponential are also exponentials (of their logs, of course!) For an example of this see the function Y in my post at stats.stackexchange.com/a/485474/919: it implements a product and sum of Weibull distribution values. $\endgroup$ – whuber Sep 1 '20 at 15:18
  • 1
    $\begingroup$ Thanks whuber (and @jld but I can't tag both) with this I've expressed the entire function as standard form log-sum-exp and applied it from there. $\endgroup$ – Kieran108 Sep 1 '20 at 16:40
  • $\begingroup$ great, glad this was helpful! $\endgroup$ – jld Sep 1 '20 at 18:34