How do you do natural logs (e.g. “ln()”) with numpy in Python?

一个人想着一个人 提交于 2019-12-03 01:58:47
JoshAdel

Correct, np.log(x) is the Natural Log (base e log) of x.

For other bases, remember this law of logs: log-b(x) = log-k(x) / log-k(b) where log-b is the log in some arbitrary base b, and log-k is the log in base k, e.g.

here k = e

l = np.log(x) / np.log(100)

and l is the log-base-100 of x

I usually do like this:

from numpy import log as ln

Perhaps this can make you more comfortable.

from numpy.lib.scimath import logn
from math import e

#using: x - var
logn(e, x)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!