|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.knowceans.util.Gamma
public class Gamma
Gamma represents the Gamma function and its derivatives
Field Summary | |
---|---|
static double |
GAMMA
Euler- Mascheroni constant |
Constructor Summary | |
---|---|
Gamma()
|
Method Summary | |
---|---|
static double |
digamma(double x)
Computes the digamma function of x. |
static double |
digamma0(double x)
Nonrecursive version, truncated Taylor series of Psi(x) = d/dx Gamma(x). |
static double |
diPochhammer(double x,
int n)
Pochhammer digamma function |
static int |
factorial(int n)
faculty of an integer. |
static long |
fak(int i)
Recursive implementation of the factorial. |
static double |
fdelta(double[] x)
|
static double |
fdelta(int[] x)
|
static double |
fdelta(int[] x,
double alpha)
"standard" fdelta function |
static double |
fdelta(int K,
double x)
|
static double |
fdeltaRatio(int[] nk,
double[] alphak,
int[] nkless,
double[] tempk)
compute the ratio of the dirichlet partition functions |
static double |
fgamma(double x)
gamma function |
static double |
invdigamma(double y)
coarse approximation of the inverse of the digamma function (after Eqs. |
static double |
ldelta(double[] x)
"Dirichlet delta function" is the partition function of the Dirichlet distribution and the k-dimensional generalisation of the beta function. |
static double |
ldelta(int[] x)
|
static double |
ldelta(int[] x,
double alpha)
log Delta function with a symmetric concentration parameter alpha that is added to every element in the vector. |
static double |
ldelta(int[] x,
double[] alpha)
log Delta function with a concentration parameter alpha that is added to every element in the vector. |
static double |
ldelta(int K,
double x)
Symmetric version of the log Dirichlet delta function |
static double |
lgamma(double x)
Returns the natural logarithm of the gamma function Γ(x). |
static double |
lgamma0(double x)
truncated Taylor series of log Gamma(x). |
static double |
trigamma(double x)
Computes the trigamma function of x. |
static double |
trigamma0(double x)
Non-recursive version, truncated Taylor series of d/dx Psi(x) = d^2/dx^2 Gamma(x). |
static double |
triPochhammer(double x,
int n)
Pochhammer trigamma function. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final double GAMMA
Constructor Detail |
---|
public Gamma()
Method Detail |
---|
public static double lgamma(double x)
x
- the value.
public static double lgamma0(double x)
x
-
public static double fgamma(double x)
x
-
public static int factorial(int n)
n
-
public static double ldelta(double[] x)
x
-
public static double fdelta(double[] x)
public static double ldelta(int[] x)
public static double fdelta(int[] x)
public static double ldelta(int[] x, double alpha)
x
- alpha
-
public static double ldelta(int[] x, double[] alpha)
x
- alpha
-
public static double fdelta(int[] x, double alpha)
x
- alpha
-
public static double ldelta(int K, double x)
K
- x
-
public static double fdelta(int K, double x)
public static double fdeltaRatio(int[] nk, double[] alphak, int[] nkless, double[] tempk)
delta(n(k) + alpha(k)) / delta(n(k) - nless(k) + alpha(k))
nk
- [K] numerator counts / integer partalphak
- [K] numerator hyperparameter / fractional partnkless
- [K] count vector that denominator is less than numeratortemp
- [K] buffer used for computing
public static double digamma(double x)
Computes the digamma function of x.
This is an independently written implementation of the algorithm described in Jose Bernardo, Algorithm AS 103: Psi (Digamma) Function, Applied Statistics, 1976.
Some of the constants have been changed to increase accuracy at the moderate expense of run-time. The result should be accurate to within 10^-8 absolute tolerance for x >= 10^-5 and within 10^-8 relative tolerance for x > 0.
Performance for large negative values of x will be quite expensive (proportional to |x|). Accuracy for negative values of x should be about 10^-8 absolute for results less than 10^5 and 10^-8 relative for results larger than that.
gregh: this implementation sets 0 argument to a very small double (1e-15) in order to cope with degenerate Dirichlet distributions
x
- the argument
public static double digamma0(double x)
x
-
public static double invdigamma(double y)
public static double trigamma(double x)
Computes the trigamma function of x. This function is derived by taking the derivative of the implementation of digamma.
x
- the argument
Gamma1#digamma(double)
public static double trigamma0(double x)
x
-
public static long fak(int i)
i
-
public static double diPochhammer(double x, int n)
x
- n
-
public static double triPochhammer(double x, int n)
x
- n
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |