在 R 编程中计算数字的指数 - exp()函数
R 语言中的exp()
函数用于计算 e 的幂,即 e^y 或者我们可以说是 y 的指数。 e 的值大约等于 2.71828…..
Syntax: exp(y)
Parameters:
y: It is any valid R number either positive or negative.
Returns: Floating point number by calculating e^y.
示例 1:
# R program to calculate exp value
# Using exp() method
answer1 <- exp(4)
answer2 <- exp(-3)
answer3 <- exp(0.0)
print(answer1)
print(answer2)
print(answer3)
输出:
54.59815
0.04978707
1
示例 2:
# R program to calculate exp value
# Using exp() method
answer1 <- exp(c(pi, exp(1)))
print(answer1)
输出:
23.14069 15.15426