Example usage for org.apache.commons.math.special Gamma logGamma

List of usage examples for org.apache.commons.math.special Gamma logGamma

Introduction

In this page you can find the example usage for org.apache.commons.math.special Gamma logGamma.

Prototype

public static double logGamma(double x) 

Source Link

Document

Returns the natural logarithm of the gamma function Γ(x).

Usage

From source file:org.renjin.MathExt.java

public static double gamma(double x) {
    return Math.exp(Gamma.logGamma(x));
}

From source file:org.renjin.MathExt.java

public static double lgamma(double x) {
    return Gamma.logGamma(x);
}

From source file:org.renjin.primitives.MathExt.java

@Deferrable
@Builtin
@DataParallel
public static double gamma(double x) {
    return Math.exp(Gamma.logGamma(x));
}

From source file:org.renjin.primitives.MathExt.java

@Deferrable
@Builtin
@DataParallel
public static double lgamma(double x) {
    return Gamma.logGamma(x);
}

From source file:org.renjin.primitives.random.Poisson.java

public static double dpois_raw(double x, double lambda, boolean give_log) {
    /*       x >= 0 ; integer for dpois(), but not e.g. for pgamma()!
    lambda >= 0/*  w w  w. j a v a2  s.c o m*/
     */
    if (lambda == 0) {
        return ((x == 0) ? SignRank.R_D__1(true, give_log) : SignRank.R_D__0(true, give_log));
    }
    if (!DoubleVector.isFinite(lambda)) {
        return SignRank.R_D__0(true, give_log);
    }
    if (x < 0) {
        return (SignRank.R_D__0(true, give_log));
    }
    if (x <= lambda * Double.MIN_VALUE) {
        return (SignRank.R_D_exp(-lambda, true, give_log));
    }
    if (lambda < x * Double.MIN_VALUE) {
        return (SignRank.R_D_exp(-lambda + x * Math.log(lambda) - Gamma.logGamma(x + 1), true, give_log));
    }
    return (SignRank.R_D_fexp(2 * Math.PI * x, -Binom.stirlerr(x) - Binom.bd0(x, lambda), true, give_log));
}

From source file:r.base.MathExt.java

@Recycle
public static double gamma(double x) {
    return Math.exp(Gamma.logGamma(x));
}

From source file:vagueobjects.ir.lda.online.matrix.MatrixUtil.java

public static Matrix gammaLn(Matrix m) {

    int nc = m.data.length;
    int nr = m.data[0].length;
    double[][] result = new double[nc][];
    for (int k = 0; k < nc; ++k) {
        result[k] = new double[nr];
        for (int w = 0; w < nr; ++w) {
            result[k][w] = Gamma.logGamma(m.data[k][w]);
        }/* w ww. j  a  va 2s  .  c om*/
    }
    return new Matrix(result);
}

From source file:vagueobjects.ir.lda.online.matrix.MatrixUtil.java

public static double gammaLn(double d) {
    return Gamma.logGamma(d);
}