API · NumPy
Python Numpy.log() - Logarithmus
Die Python-Funktion numpy.log() berechnet den natürlichen Logarithmus eines numpy-Arrays. numpy.log2() und numpy.log10() berechnen den Logorithmus zur Basis 2 und 10.
Auf dieser Seite
Die Funktion Numpy.log() berechnet den natürlichen Logarithmus jedes Elements im gegebenen Array.
Syntax von numpy.log()
numpy.log(arr)
Parameter
arr |
Eingabe-Array |
Zurück
Es gibt ein Array mit dem natürlichen Logarithmus jedes Elements im Eingabearray zurück.
Beispiel-Codes: numpy.log()
import numpy as np
arr = [1, np.e, np.e**2, np.e**3]
print(np.log(arr))
Ausgabe:
[0. 1. 2. 3.]
Beispielcodes: numpy.log2() - Numpy Log Base 2
numpy.log2() ist ähnlich wie numpy.log(), hat aber die Basis als 2 anstelle von e.
import numpy as np
arr = [1, 2, np.e, 4]
print(np.log2(arr))
Ausgabe:
[0. 1. 1.44269504 2.]
Beispielcodes: numpy.log10() - Numpy Log Base 10
numpy.log10() ist ähnlich wie numpy.log(), hat aber die Basis 10 anstelle von e.
import numpy as np
arr = [1, np.e, 10, 100]
print(np.log10(arr))
Ausgabe:
[0. 0.43429448 1. 2.]