有人可以解释一下np.log的作用吗? [英] Can some one explain me what does np.log do?
本文介绍了有人可以解释一下np.log的作用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这是一个简单的问题,但是我无法获得np.log的确切功能?我看到了文档,但是我无法了解np.log
背后的逻辑. np.log([9000000])
我得到的输出为16.01273514.我不明白为什么要得到这个号码,我知道什么是
I understand that this is a simple question, but I couldnt get what exactly does np.log do? I saw the documentation from which I am not able to understand the logic behind np.log
. np.log([9000000])
I am getting the output as 16.01273514. I couldnt understand why I am getting this number, I fo know what a logarithm means.
推荐答案
np.log(x)
是自然对数,即必须将e
的幂提高到等于x
:
np.log(x)
is the natural logarithm, i.e. the power to which e
would have to be raised to equal x
:
>>> np.log([1, np.e, np.e**2, 0])
array([ 0., 1., 2., -Inf])
以10为底的对数:
>>> np.log10([1e-15, -3.])
array([-15., NaN])
以2为底的对数:
>>> x = np.array([0, 1, 2, 2**4])
>>> np.log2(x)
array([-Inf, 0., 1., 4.])
在您的示例中:
>>> np.log([9000000]) # ln(9000000)
array([ 16.01273514])
>>> np.exp([16.01273514]) # e^16
array([ 9000000.04229556])
这篇关于有人可以解释一下np.log的作用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文