문제

Using numpy, how can I do the following:

ln(x)

Is it equivalent to:

np.log(x)

I apologise for such a seemingly trivial question, but my understanding of the difference between log and ln is that ln is logspace e?

도움이 되었습니까?

해결책

다른 팁

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)

You could simple just do the reverse by making the base of log to e.

import math

e = 2.718281

math.log(e, 10) = 2.302585093
ln(10) = 2.30258093
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top