Python Numpy.log() - Logarithme

Jinku Hu 30 janvier 2023
  1. Syntaxe de numpy.log()
  2. Exemples de codes: numpy.log()
  3. Exemples de codes: numpy.log2() - Numpy Log Base 2
  4. Exemples de codes: numpy.log10() - Numpy Log Base 10
Python Numpy.log() - Logarithme

La fonction Numpy.log() calcule le logarithme naturel de chaque élément du tableau donné.

logarithme naturel engourdi

Syntaxe de numpy.log()

numpy.log(arr)

Paramètres

arr tableau d’entrée

Revenir

Il retourne un tableau du logarithme naturel de chaque élément du tableau d’entrée.

Exemples de codes: numpy.log()

import numpy as np

arr = [1, np.e, np.e**2, np.e**3]
print(np.log(arr))

Production:

[0. 1. 2. 3.]

Exemples de codes: numpy.log2() - Numpy Log Base 2

numpy.log2() est similaire à numpy.log(), mais a la base comme 2 au lieu de e.

numpy log2

import numpy as np

arr = [1, 2, np.e, 4]
print(np.log2(arr))

Production:

[0. 1. 1.44269504 2.]

Exemples de codes: numpy.log10() - Numpy Log Base 10

numpy.log10() est similaire à numpy.log(), mais a la base comme 10 au lieu de e.

numpy log10

import numpy as np

arr = [1, np.e, 10, 100]
print(np.log10(arr))

Production:

[0. 0.43429448 1. 2.]
Auteur: Jinku Hu
Jinku Hu avatar Jinku Hu avatar

Founder of DelftStack.com. Jinku has worked in the robotics and automotive industries for over 8 years. He sharpened his coding skills when he needed to do the automatic testing, data collection from remote servers and report creation from the endurance test. He is from an electrical/electronics engineering background but has expanded his interest to embedded electronics, embedded programming and front-/back-end programming.

LinkedIn Facebook