title: taking log of very small values using numpy/scipy in Python
body: <p>I have an Nx1 array that corresponds to a probability distribution, i.e. the sum of the elements sums to 1.  This is represented as a regular numpy array.  Since N might be relatively large, e.g. 10 or 20, many of the individual elements are pretty close to 0.  I find that when I take log(my_array), I get the error "FloatingPointError: invalid value encountered in log".  Note that this is after setting seterr(invalid='raise') in numpy intentionally.</p>
  
  <p>How can I deal with this numerical issue?  I'd like to represent vectors corresponding to a probability distribution and their take log without rounding to 0, since then I end up taking log(0) which raises the error.</p>
  
  <p>thanks.</p>