Using logarithms to normalize a vector to avoid overflow

Posted by muscicapa on Stack Overflow See other posts from Stack Overflow or by muscicapa
Published on 2010-03-08T09:47:28Z Indexed on 2010/03/08 9:51 UTC
Read the original article Hit count: 370

Filed under:
|
|

http://stackoverflow.com/questions/2293762/problem-with-arithmetic-using-logarithms-to-avoid-numerical-underflow-take-2

Having seen the above and having seen softmax normalization I was trying to normalize a vector while avoiding overflow -

that is (x1 x2 x3 x4 ... xn) the normalized form for me has the sum of squares as 1.0

So what I thought of doing is s=(2*log(x1)+2*log(x2)+...+2*log(xn))/2 so the two factor can be taken off

and finally the normalized vector is

exp(log(x1)-s), , ..., exp(log(xn)-s)

but I am evidently doing something wrong here, what?

© Stack Overflow or respective owner

Related posts about numerical

Related posts about algorithm