I'm trying to compute a vector, whose sum is 1 and whose elements are defined as such:
v[i] = exp(tmp[i])/exp(tmp).sum()
The problem is that the value in the exponential may be large (between -10^2 and 10^2), making the exponential to evaluate to inf or 0.
I tried some variations, like substracting the biggest element or the mean of tmp to the numerator and the denominator, but it's still not enough.
Basically, I'm need of a transformation that reduces the mean value and the dispersion in tmp or of a clever ordering for this computation.
I'm using numpy arrays as containers and exp is numpy.exp.