## Posts Tagged ‘optimization’

### Linear Addition from the Log Domain

February 24, 2013

Some speech recognizers and machine learning algorithms need to quickly calculate the quantity:

$\log(x+y)$

when given only $\log(x)$ and $\log(y)$. The straightforward algorithm first uses the exponential function to convert the log values to the linear domain representation $x$ and $y$, then performs the sum, and finally uses the log function to convert back to the log domain:

$\log(x+y) = \log(\exp(\log(x)) + \exp(\log(y)))$

These conversions between log and linear domains are slow and problems arise when $x$ is too large or small for a machine’s floating point representation.

Luckily, there is a clever approximation method that allows quick, accurate calculation with a relatively small precomputed table.