Reputation: 6515
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.
Upvotes: 2
Views: 11087
Reputation: 40973
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])
Base 10 logarithm:
>>> np.log10([1e-15, -3.])
array([-15., NaN])
Base 2 logarithm:
>>> x = np.array([0, 1, 2, 2**4])
>>> np.log2(x)
array([-Inf, 0., 1., 4.])
In your example:
>>> np.log([9000000]) # ln(9000000)
array([ 16.01273514])
>>> np.exp([16.01273514]) # e^16
array([ 9000000.04229556])
Upvotes: 8