Python math.lgamma()メソッド
例
さまざまな数値の対数ガンマ値を見つけます。
# Import math Library
import math
# Return the log gamma value of
different numbers
print (math.lgamma(7))
print (math.lgamma(-4.2))
定義と使用法
このmath.lgamma()
メソッドは、数値の自然対数ガンマ値を返します。
ヒント:math.gamma()
メソッドを使用してガンマ値を検索し、メソッドを使用してmath.log()
その値の対数を計算することで、ログのガンマ値を検索することもできます。
ヒント:ガンマ値はfactorial(x-1)と同じです。
構文
math.lgamma(x)
パラメータ値
Parameter | Description |
---|---|
x | Required. The number to find the log gamma value of. If the number is a negative integer, it returns a ValueError. If it is not a number, it returns a TypeError. |
技術的な詳細
戻り値: | 数値のfloat 対数ガンマ値を表す値 |
---|---|
Pythonバージョン: | 3.2 |