Skip to main content
Module

x/simplestatistics/index.js>gamma

simple statistics for node & browser javascript
Go to Latest
function gamma
import { gamma } from "https://deno.land/x/simplestatistics@v7.7.5/index.js";

Compute the gamma function of a value using Nemes' approximation. The gamma of n is equivalent to (n-1)!, but unlike the factorial function, gamma is defined for all real n except zero and negative integers (where NaN is returned). Note, the gamma function is also well-defined for complex numbers, though this implementation currently does not handle complex numbers as input values. Nemes' approximation is defined here as Theorem 2.2. Negative values use Euler's reflection formula for computation.

Examples

gamma(11.5); // 11899423.084037038 gamma(-11.5); // 2.29575810481609e-8 gamma(5); // 24

Parameters

n

Any real number except for zero and negative integers.