Click or drag to resize
Accord.NET (logo)

Gamma Class

Gamma Γ(x) functions.
Inheritance Hierarchy
SystemObject
  Accord.MathGamma

Namespace:  Accord.Math
Assembly:  Accord.Math (in Accord.Math.dll) Version: 3.8.0
Syntax
public static class Gamma
Request Example View Source

The Gamma type exposes the following members.

Methods
  NameDescription
Public methodStatic memberDigamma
Digamma function.
Public methodStatic memberFunction
Gamma function of the specified value.
Public methodStatic memberInverse
Public methodStatic memberInverseLowerIncomplete
Public methodStatic memberInverseUpperIncomplete
Public methodStatic memberLog(Double)
Natural logarithm of the gamma function.
Public methodStatic memberLog(Double, Int32)
Natural logarithm of the multivariate Gamma function.
Public methodStatic memberLowerIncomplete
Lower incomplete regularized gamma function P (a.k.a. the incomplete Gamma function).
Public methodStatic memberMultivariate
Multivariate Gamma function
Public methodStatic memberStirling
Gamma function as computed by Stirling's formula.
Public methodStatic memberTrigamma
Trigamma function.
Public methodStatic memberUpperIncomplete
Upper incomplete regularized Gamma function Q (a.k.a the incomplete complemented Gamma function)
Top
Fields
  NameDescription
Public fieldStatic memberGammaMax
Maximum gamma on the machine.
Top
Remarks

In mathematics, the gamma function (represented by the capital Greek letter Γ) is an extension of the factorial function, with its argument shifted down by 1, to real and complex numbers. That is, if n is a positive integer:

Γ(n) = (n-1)!

The gamma function is defined for all complex numbers except the negative integers and zero. For complex numbers with a positive real part, it is defined via an improper integral that converges:

       ∞
Γ(z) = ∫  t^(z-1)e^(-t) dt
       0

This integral function is extended by analytic continuation to all complex numbers except the non-positive integers (where the function has simple poles), yielding the meromorphic function we call the gamma function.

The gamma function is a component in various probability-distribution functions, and as such it is applicable in the fields of probability and statistics, as well as combinatorics.

References:

  • Wikipedia contributors, "Gamma function,". Wikipedia, The Free Encyclopedia. Available at: http://en.wikipedia.org/wiki/Gamma_function
  • Cephes Math Library, http://www.netlib.org/cephes/

Examples
double x = 0.17;

// Compute main Gamma function and variants
double gamma = Gamma.Function(x); // 5.4511741801042106
double gammap = Gamma.Function(x, p: 2); // -39.473585841300675
double log = Gamma.Log(x);        // 1.6958310313607003
double logp = Gamma.Log(x, p: 2); // 3.6756317353404273
double stir = Gamma.Stirling(x);  // 24.040352622960743
double psi = Gamma.Digamma(x);    // -6.2100942259248626
double tri = Gamma.Trigamma(x);   // 35.915302055854525

double a = 4.2;

// Compute the incomplete regularized Gamma functions P and Q:
double lower = Gamma.LowerIncomplete(a, x); // 0.000015685073063633753
double upper = Gamma.UpperIncomplete(a, x); // 0.9999843149269364
See Also