Using logarithms to normalize a vector to avoid overflow
- by muscicapa
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?