3
$\begingroup$

I have a mixture distribution with likelihood function

$$ L(\theta) = \prod_{i=1}^N \sum_{k=1}^K f(X_i|\theta_k) \lambda_k $$

where $N$ is the sample size, $K$ is the number of component, $\theta_k$ is the parameter vector of component $k$, and $\lambda_k$ is the mixing probability of component $k$.

If I take the log of this I get

$$ \log \left[ L(\theta) \right] = \sum_{i=1}^N \log \left[ \sum_{k=1}^K f(X_i|\theta_k) \lambda_k \right] $$

My question is how do I evaluate the log-term for given $X$, $\theta$ and $\lambda$? Theoretically, I could compute the likelihoods $f(X_i|\theta_k)$ and sum them up weighted by the $\lambda_k$ and after take the log. However, I need to work with the log likelihoods to avoid floating point problems. My question therefore is how to compute the log term in the log likelihood above, if I can only compute $\log \left[ f(X_i|\theta_k) \right]$.

$\endgroup$
4
  • 1
    $\begingroup$ the major overflow would have happened in the outer multiplication due to high number of samples, $N$, but you've already solved that by converting it into summation of logs. Why do you think that you'll have overflow problems in the inner part, isn't $K<<N$? $\endgroup$
    – gunes
    Commented Feb 17, 2021 at 11:25
  • 1
    $\begingroup$ @gunes - (+1) I have the same feeling that, except for outlandish values of some parameters, there is very little chance a single sum leads to floating point problems. $\endgroup$
    – Xi'an
    Commented Feb 17, 2021 at 11:28
  • $\begingroup$ Yes @Xian, you've written the complete answer (+1) while I'm commenting. $\endgroup$
    – gunes
    Commented Feb 17, 2021 at 11:30
  • 1
    $\begingroup$ Thanks for your quick replies! I use pseudolikelihoods for large Ising models; in this case each conditional ends up being a logistic regression. For example, if I have 1000 predictors and all of them are in state 1, and let's say the weight associated with each predictor is 1, then the sum in the exponential is 1000. $\endgroup$
    – jmb
    Commented Feb 17, 2021 at 11:36

1 Answer 1

3
$\begingroup$

Consider all terms in $$\sum_{k=1}^K f(X_i|\theta_k) \lambda_k$$ namely $$(\log\{f(X_i|\theta_1) \lambda_1\},\ldots,\log\{f(X_i|\theta_K) \lambda_K\})$$ then identify the largest $$\log\{f(X_i|\theta_\zeta) \lambda_\zeta\}=\max(\log\{f(X_i|\theta_1) \lambda_1\},\ldots,\log\{f(X_i|\theta_K) \lambda_K\})$$ and write $$ \begin{aligned} \log\left\{\sum_{k=1}^K f(X_i|\theta_k) \lambda_k\right\} &=\log\{f(X_i|\theta_\zeta) \lambda_\zeta\} \\ &+\log\left\{ \sum_{k=1}^K \exp[\log\{f(X_i|\theta_k) \lambda_k\}-\log\{f(X_i|\theta_\zeta) \lambda_\zeta\}]\right\} \end{aligned} $$ Since all exponentiated terms are negative there should be no overflow issue.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.