Home  >  Article  >  Backend Development  >  A brief discussion on the application scenarios of scipy.misc.logsumexp function in python

A brief discussion on the application scenarios of scipy.misc.logsumexp function in python

WBOY
WBOYOriginal
2016-07-06 13:29:521516browse

The input parameters of the scipy.misc.logsumexp function are (a, axis=None, b=None, keepdims=False, return_sign=False). The specific configuration can be found here. The returned value is np.log(np.sum (np.exp(a))).

What needs to be emphasized here is the scenario of using this function:

Generally speaking, this function is mainly used for operations with very small values ​​(such as Monte Carlo sampling samples). In this case, keeping the data in log processing is a must. So at this time, if you want to accumulate and sum the data in the array, you need to calculate log(sum(exp(a))) like this, but doing so will cause some accuracy problems, and this
The problem scipy.misc.logsumexp was introduced and solved, so you can directly use the scipy.misc.logsumexp function for summing small data.

Reference: https://github.com/numpy/numpy/issues/5652

The above is the entire content of the application scenarios of the scipy.misc.logsumexp function in Python brought to you by the editor. I hope you will support Script Home~

Statement:
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