码迷,mamicode.com
首页 > 其他好文 > 详细

log sum of exponential

时间:2015-10-08 23:06:42      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:

The so-called “log sum of exponentials” is a functional form commonly encountered in dynamic discrete choice models in economics. It arises when the choice-specific error terms have a type 1 extreme value distribution–a very common assumption. In these problems there is typically a vector v of length J which represents the non-stochastic payoff associated with each of J choices. In addition to vj, the payoff associated with choice j has a random component εj. If these components are independent and identically distributed across j and follow the type 1 extreme value distribution, then the expected payoff from choosing optimally is ??[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 is required to calculate this expression in compiled languages such as Fortran or C to avoid numerical problems. 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 are 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 that 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 way 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

标签:

原文地址:http://www.cnblogs.com/cslxiao/p/4789444.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!