Skip to contents

Calculates the natural logarithm of the gamma function

Usage

gammaln(A)

Arguments

A

a non-negative, real matrix, vector or scalar

Value

An element-by-element ln(gamma())-transformed A

Note

For MATLAB output reproduction, non-positive values will be

Author

Waldir Leoncio

Examples

gammaln(8)
#> [1] 8.525161
gammaln(0)
#> [1] Inf
gammaln(matrix(1:9, 3))
#>           [,1]     [,2]      [,3]
#> [1,] 0.0000000 1.791759  6.579251
#> [2,] 0.0000000 3.178054  8.525161
#> [3,] 0.6931472 4.787492 10.604603
gammaln(-4:10)
#>  [1]        Inf        Inf        Inf        Inf        Inf  0.0000000
#>  [7]  0.0000000  0.6931472  1.7917595  3.1780538  4.7874917  6.5792512
#> [13]  8.5251614 10.6046029 12.8018275