Python numpy.exp() 到底做了什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31951980/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 10:47:23  来源:igfitidea点击:

What exactly does numpy.exp() do?

pythonnumpystatisticsexp

提问by bugsyb

I'm very confused as to what np.exp() actually does. In the documentation it says that it: "Calculates the exponential of all elements in the input array." I'm confused as to what exactly this means. Could someone give me more information to what it actually does?

我对 np.exp() 的实际作用感到非常困惑。在文档中它说:“计算输入数组中所有元素的指数。” 我很困惑这到底是什么意思。有人能给我更多关于它实际作用的信息吗?

回答by Tom

It calculates exfor each xin your list where eis Euler's number (approximately 2.718). In other words, np.exp(range(5))is similar to [math.e**x for x in range(5)].

它为列表中的每个x计算e x,其中e是欧拉数(约 2.718)。换句话说,类似于。np.exp(range(5))[math.e**x for x in range(5)]

回答by machine yearning

The exponential function is e^xwhere eis a mathematical constant called Euler's number, approximately 2.718281. This value has a close mathematical relationship with piand the slope of the curve e^xis equal to its value at every point. np.exp()calculates e^xfor each value of xin your input array.

指数函数是e^x其中e是一个称为欧拉数的数学常数,大约为2.718281。该值具有密切的数学关系,pi曲线的斜率e^x在每一点都等于其值。np.exp()计算输入数组中的e^x每个值x

回答by Arijit

exp(x) = e^x where e= 2.718281(approx)

exp(x) = e^x 其中 e= 2.718281(approx)

import numpy as np

ar=np.array([1,2,3])
ar=np.exp(ar)
print ar

output of the Sample Code-> [ 2 7 20]

示例代码的输出-> [ 2 7 20]