红宝石 |数学 erf()函数
Ruby 中的erf()函数返回 x 的错误函数。它接受 [-inf, +inf] 范围内的值并返回 [-1, +1] 范围内的值。
Syntax: Math.erf(value)
Parameter: The function takes the value whose error function is to be returned.
Return Value: The function returns the error function.
示例 1 :
# Ruby program for erf() function
# Assigning values
val1 = 0.98
val2 = -0.9
val3 = 6
val4 = 1
# Prints the erf() value
puts Math.erf(val1)
puts Math.erf(val2)
puts Math.erf(val3)
puts Math.erf(val4)
输出:
0.8342315043402079
-0.7969082124228322
1.0
0.8427007929497149
示例 2 :
# Ruby program for erf() function
# Assigning values
val1 = 0.67
val2 = -0.12
val3 = 2.4
val4 = 89
# Prints the erf() value
puts Math.erf(val1)
puts Math.erf(val2)
puts Math.erf(val3)
puts Math.erf(val4)
输出:
0.6566277023003051
-0.13475835181992007
0.999311486103355
1.0
参考:https://devdocs.io/ruby~2.5/math#method-c-erf