Python math.gamma() 方法
实例
查找不同数字的 gamma 函数:
# Import math Libraryimport math# Return the gamma function for different numbersprint(math.gamma(-0.1))print(math.gamma(8))print(math.gamma(1.2))print(math.gamma(80))print(math.gamma(-0.55))
定义与用法
math.gamma() 方法将 gamma 函数以数字形式返回。
提示:要查找数字的对数伽马值,请使用 math.lgamma() 方法.
语法
math.gamma(x)
参数值
| 参数 | 描述 |
|---|---|
| x | 必填。 用于查找伽马函数的数字。如果该数字为负整数,则返回 ValueError。如果不是数字,则返回 TypeError。 |
技术细节
| 返回值: | 一个 float 值, 表示作用于 x 的 gamma 函数返回值 |
|---|---|
| Python 版本: | 3.2 |