The so-called "log sum of exponentials" is a functional form commonly encountered in dynamic discrete choice models in Eco Nomics. It arises when the choice-specific error terms has a Type 1 extreme value distribution–a very common assumption. In these problems there are typically a vector v of length J which represents the non-stochastic payoff associated with EAC H of J choices. In addition to VJ, the payoff associated with Choice J have a random componentεj. If These components is independent and identically distributed across J and follow the type 1 extreme value distribution, Then the expected payoff from choosing optimally are?? [Max{v1+ε1,..., vj+εj}]=ln[exp (v1) +...+exp (VJ)]. We need to numerically evaluate the expression on the right hand side for many different vectors v.
Special care are required to calculate this expression in compiled languages such as Fortran or C to avoid numerical proble Ms The function needs to work for V with very large and very small components. A large VJ can cause overflow due to the exponentiation. Similarly, when the VJ is large (in absolute value) and negative, the exponential terms vanish. Taking the logarithm of a very small number can result in underflow.
A simple transformation can avoid both of these problems. Consider the case where v= (A, B). Note: We can write exp (a) +exp (b) =[exp (a−c) +exp (b−c)]exp (c) for any c. Furthermore, we have ln[(exp (a−c) +exp (B−C)) exp (c)]=ln[exp (a−c) +exp (b−c)]+c. We can choose C in a by that reduces the possibility of overflow. Underflow is also possible when taking the logarithm of a number close to zero, since ln (x) →−∞as x→0. Thus, we also need to account for large negative elements of V.
Log sum of exponential