﻿ Gamma Class

# 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`

The Gamma type exposes the following members.

Methods
NameDescription
Digamma
Digamma function.
Function
Gamma function of the specified value.
Inverse
InverseLowerIncomplete
InverseUpperIncomplete
Log(Double)
Natural logarithm of the gamma function.
Log(Double, Int32)
Natural logarithm of the multivariate Gamma function.
LowerIncomplete
Lower incomplete regularized gamma function P (a.k.a. the incomplete Gamma function).
Multivariate
Multivariate Gamma function
Stirling
Gamma function as computed by Stirling's formula.
Trigamma
Trigamma function.
UpperIncomplete
Upper incomplete regularized Gamma function Q (a.k.a the incomplete complemented Gamma function)
Top
Fields
NameDescription
GammaMax
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```