Doing multiplication, adding logarithms --- zero unit element?

It is clear that I need to multiply the probabilities of each event in coincidence. Since there can be so many events, I have a computer that adds logarithms to avoid overflow.

But all of a sudden, I cannot convince myself that I need to initialize zero before initializing the return value. I know that zero is an identification element to add, and I remember how I do it, but looking at the logarithm graph , I can clearly see that the zero antilogue is negative infinity.

So, initializing the return value to zero should be equivalent to multiplying all my probabilities by negative infinity, which is definitely wrong. What am I doing wrong?

+3
source share
3 answers

The antilogue of zero is one, not negative infinity. This means that the beginning of adding with zero for the logarithm is the same as the beginning of multiplying by one for the probabilities themselves.

+6
source

If you multiply the values ​​together, they look like this:

product = 1*p1*....*pn

If you take the natural log of both sides, it looks like this:

ln(product) = ln(1) + ln(p1) + .... + ln(pn)

But ln(1) = 0, since you initialize the sum of the logarithms. Set it to zero.

Remember what you are summarizing here: the journal of each probability is added to the journal of full probability. Once you complete the amount, you can receive the product as follows:

product = exp(ln(product)) = exp(ln(sum of ln(pn))
+7
source

. . . , .

0

Source: https://habr.com/ru/post/1791459/


All Articles