I have a large vector of likelihoods all in the range (0 to 1) but all numbers are quite a bit less than 1. I need to compute the maximum likelihood of the product of these vectors.
How can I avoid underflow, my fitter is failing in all my attempts. The first step I took was to divide my array by the max value in my array. I am maximizing the product of the sum of two probabilities sampled n times, Ultimately I need to minimize as per the BIC:
BIC = -2. * ln(L) + 5n_theta(nz)
Anyways L
is an array of really small numbers of the form
L = product of ([(p(z1|a) + p(z1|b)), (p(z2|a) + p(z2|b)), ...., (p(zn|a) + p(zn|b))])
Here is an example with two parameters a
and b
that I vary and the array has size n
and each p
is < 1
.
Have you considered working in log-likelihood?
L = (p1 * p2 * p3) ** N
becomes ln(L) = N * (ln(p1) + ln(p2) + ln(p3))
Which will be much more resistant to numerical precision problems.
And then you can directly use ln(L)
in your -2.0 * ln(L) + 5n_theta(nz)