>  Docs Center  >  Libraries  >  Beaumont  >  SUMOFSMALLS
Libraries

SUMOFSMALLS

SUMOFSMALLS

Purpose


  This function calculates the sum of very small numbers in a way that
  avoids computer underflow errors. This is useful in situatioOBns like
  likelihood maximization, where individual terms in the likelihood
  can be very small. The program is vectorized to handle multiple
  sums simultaneously.

Category


  math

Inputs


  logs: The _natural log_ of the values to sum. NANs are
        treated as missing data. A vector or 2d array. If it is a
        vector, then the sum will be taken over all elements. If it
        is a 2D array, then separate sums will be taken over each row
        of data.
 

Outputs


  The _natural log_ of the sum of small numbers

Procedure


  Calculations are done on logarithms, since they are much larger and
  not susceptible to underflow. The basic calculation is
  Sum(x) = Xmax * Sum(x / xmax)
  the numbers x / xmax can be calculated from the logs.

Modification History


  December 2009: Written by Chris Beaumont



© 2024 NV5 Geospatial Solutions, Inc. |  Legal
   Contact Us