浅谈python中scipy.misc.logsumexp函数的运用场景

WBOY
Release: 2016-07-06 13:29:52
Original
1474 people have browsed it

scipy.misc.logsumexp函数的输入参数有(a, axis=None, b=None, keepdims=False, return_sign=False),具体配置可参见这里,返回的值是np.log(np.sum(np.exp(a)))。

这里需要强调的是使用该函数的场景:

一般来说,该函数主要用于非常小的数值的运算(比如蒙特卡洛取样样本)。在这种情况下,将数据保持log处理是必须的。所以这时你如果想将数组中的数据累加求和就需要这样计算log(sum(exp(a))),但这样做就会产生一些精确性的问题,而这个
问题scipy.misc.logsumexp是引进解决了的,所以进行小数据求和可以直接使用scipy.misc.logsumexp函数。

参考:https://github.com/numpy/numpy/issues/5652

以上就是小编为大家带来的浅谈python中scipy.misc.logsumexp函数的运用场景全部内容了,希望大家多多支持脚本之家~

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!