log-sum-exp trick why not recursive

前端 未结 3 1355
盖世英雄少女心
盖世英雄少女心 2021-01-04 21:46

I have been researching the log-sum-exp problem. I have a list of numbers stored as logarithms which I would like to sum and store in a logarithm.

the naive algorith

3条回答
  •  无人及你
    2021-01-04 22:49

    Not really any better to do it recursively. The problem's just that you want to make sure your finite-precision arithmetic doesn't swamp the answer in noise. By dealing with the max on its own, you ensure that any junk is kept small in the final answer because the most significant component of it is guaranteed to get through.

    Apologies for the waffly explanation. Try it with some numbers yourself (a sensible list to start with might be [1E-5,1E25,1E-5]) and see what happens to get a feel for it.

提交回复
热议问题