Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.lgamma() Method

Python math.lgamma() Method

Python math Module Python math Module

Python math.lgamma(x) The method returns the natural logarithm of the gamma value of a number.

We can also use the math.gamma() method to find the gamma value, and then use the math.log() method to compute the natural logarithm of that value.

The gamma value equals factorial(x-1).

Python version: 3.2

Syntax

The syntax of the math.lgamma() method is as follows:

math.lgamma(x)

Parameter Description:

Return Value

A floating-point value representing the log-gamma value of a number.

Example

The following example computes the natural log-gamma value of different numbers:

Example

Import the math package

import

math

Compute the natural log-gamma value of different numbers

print

(

math

.

lgamma

(

7

)

)

print

(

math

.

lgamma

(

4.2

)

)

Output result:



6.579251212010102

-1.8075166614192908

Python math Module Python math Module