## ./

# sumofsmalls.pro

## topsumofsmalls

math

`result = sumofsmalls(logs)`

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.

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.

### Return value

The _natural log_ of the sum of small numbers

### Parameters

- logs in required
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.

## File attributes

Modifcation date: | Mon Mar 29 16:54:35 2010 |

Lines: | 50 |