gamma(x)
Overview
The gamma
function calculates the Gamma function Γ(x) using the Lanczos approximation method.
Parameters
Parameter | Type | Description |
---|---|---|
x |
Number | The value to find the Gamma function of. |
Returns
Return | Type | Description |
---|---|---|
gam |
Number | The calculated Gamma function value Γ(x). |
Example
local x = 5
local result = StatBook.gamma(x)
print(result)
Mathematical Background
The function calculates Γ(x) using the Lanczos approximation, which is an efficient method to compute the Gamma function for complex numbers. The method approximates Γ(z) by:
Γ(z)≈√2π(z+56)z+12e−(z+56)(c0+c1z+1+c2z+2+⋯+cnz+n)
Here c0,c1,⋯,cn are precomputed coefficients used in the approximation.