Python math.erf() 方法
实例
不同数字的打印错误功能:
# Import math Libraryimport math#Print the error function of a numberprint (math.erf(0.67))print (math.erf(1.34))print (math.erf(-6))
定义与用法
math.erf() 方法返回数字的误差函数。
此方法接受介于 -inf 和 +inf 之间的值,并返回介于 -1 和 +1 之间的值。
语法
math.erf(x)
参数值
| 参数 | 描述 |
|---|---|
| x | 必填。用于查找错误函数的数字 |
技术细节
| 返回值: | 一个 float 值,表示数字的错误函数 |
|---|---|
| Python 版本: | 3.2 |
更多实例
实例
计算相同数值的数学误差函数,正和负:
# Import math Libraryimport math#Print the error function of the same number, positive and negativeprint (math.erf(1.28))print (math.erf(-1.28))