Log Gamma Function

@param Z
@return
516244
public static double logGamma(double Z) {
        double S = 1.0 + 76.18009173/Z-86.50532033/(Z+1.0)+24.01409822/(Z+2.0)-1.231739516/(Z+3.0)+0.00120858003/(Z+4.0)-0.00000536382/(Z+5.0);
        double LG = (Z-0.5)*Math.log(Z+4.5)-(Z+4.5)+Math.log(S*2.50662827465);
        
        return LG;
    }
1202394
@Pure
	public static double toESRI_z(double z) {
		if (Double.isInfinite(z) || Double.isNaN(z)) {
			return ESRI_NAN;
		}
		return z;
	}
1347265
public static double gamma( double x ) {
        double tmp = (x - 0.5) * log(x + 4.5) - (x + 4.5);
        double ser = 1.0 + 76.18009173 / (x + 0) - 86.50532033 / (x + 1) + 24.01409822 / (x + 2) - 1.231739516 / (x + 3)
                + 0.00120858003 / (x + 4) - 0.00000536382 / (x + 5);
        double gamma = exp(tmp + log(ser * sqrt(2 * PI)));
        return gamma;
    }
991485
def log_interp1d(self, xx, yy, kind='linear'):
        
        logx = np.log10(xx)
        logy = np.log10(yy)
        lin_interp = interp1d(logx, logy, kind=kind)
        log_interp = lambda zz: np.power(10.0, lin_interp(np.log10(zz)))
        return log_interp
1372680
private static function _beta($p, $q) {
		if ($p <= 0.0 || $q <= 0.0 || ($p + $q) > LOG_GAMMA_X_MAX_VALUE) {
			return 0.0;
		} else {
			return exp(self::_logBeta($p, $q));
		}
	}
224617
def log_likelihood_of(self, z):
        

        if z is None:
            return log(sys.float_info.min)
        return logpdf(z, dot(self.H, self.x), self.S)
877520
@Override
    public double logLikelihood(double[] x) {
        double L = 0.0;
        
        for (double xi : x)
            L += logp(xi);
        
        return L;
    }
477012
private double sumlogneg(double[][] f) {
        int m = f.length;
        int n = f[0].length;

        double sum = 0.0;
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                sum += Math.log(-f[i][j]);
            }
        }

        return sum;
    }
281096
function gamma(x) {
      var expx;

      expx = Math.exp(lgamma(x));

      return x > 0 && x === Math.round(x) ? Math.round(expx) : expx;
   }
556688
def logCdfNormal(z):
    
    if (abs(z) < ERF_CODY_LIMIT1):
        # Phi(z) approx  (1+y R_3(y^2))/2, y=z/sqrt(2)
        return np.log1p((z / M_SQRT2) * _erfRationalHelperR3(0.5 * z * z)) - M_LN2
    elif (z < 0.0):
        # Phi(z) approx N(z)Q(-z)/(-z), z<0
        return logPdfNormal(z) - np.log(-z) + np.log(_erfRationalHelper(-z))
    else:
        return np.log1p(-(np.exp(logPdfNormal(z))) * _erfRationalHelper(z) / z)
54418
private void processElementGamma(GeneratorSingleCluster cluster, Node cur) {
    double k = 1.0;
    double theta = 1.0;
    String kstr = ((Element) cur).getAttribute(ATTR_K);
    if(kstr != null && kstr.length() > 0) {
      k = ParseUtil.parseDouble(kstr);
    }
    String thetastr = ((Element) cur).getAttribute(ATTR_THETA);
    if(thetastr != null && thetastr.length() > 0) {
      theta = ParseUtil.parseDouble(thetastr);
    }

    // *** New normal distribution generator
    Random random = cluster.getNewRandomGenerator();
    Distribution generator = new GammaDistribution(k, theta, random);
    cluster.addGenerator(generator);

    // TODO: check for unknown attributes.
    XMLNodeIterator iter = new XMLNodeIterator(cur.getFirstChild());
    while(iter.hasNext()) {
      Node child = iter.next();
      if(child.getNodeType() == Node.ELEMENT_NODE) {
        LOG.warning("Unknown element in XML specification file: " + child.getNodeName());
      }
    }
  }
474259
def (z):
    
    if z < -6:
        return 1, -1.0e12, -1
    if z > 6:
        return 0, 0, 1
    else:
        logphi = -0.5 * (z * z + l2p)
        logPhi = np.log(.5 * special.erfc(-z / sq2))
        e = np.exp(logphi - logPhi)
    return e, logPhi, 0
875666
public javax.el.ValueExpression getGamma() {
		return (javax.el.ValueExpression) getStateHelper().eval(PropertyKeys.gamma);
	}
389764
def _log_phi(z):
    """"""
    # Adapted from the GPML function `logphi.m`.
    if z * z < 0.0492:
        # First case: z close to zero.
        coef = -z / SQRT2PI
        val = functools.reduce(lambda acc, c: coef * (c + acc), CS, 0)
        res = -2 * val - log(2)
        dres = exp(-(z * z) / 2 - res) / SQRT2PI
    elif z < -11.3137:
        # Second case: z very small.
        num = functools.reduce(
                lambda acc, r: -z * acc / SQRT2 + r, RS, 0.5641895835477550741)
        den = functools.reduce(lambda acc, q: -z * acc / SQRT2 + q, QS, 1.0)
        res = log(num / (2 * den)) - (z * z) / 2
        dres = abs(den / num) * sqrt(2.0 / pi)
    else:
        res = log(normal_cdf(z))
        dres = exp(-(z * z) / 2 - res) / SQRT2PI
    return res, dres
884960
function gamma(number) {
    const p = [0.99999999999980993, 676.5203681218851, -1259.1392167224028,
        771.32342877765313, -176.61502916214059, 12.507343278686905,
        -0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7
    ];
 
    const g = 7;
    if (number < 0.5) {
        return Math.PI / (Math.sin(Math.PI * number) * gamma(1 - number));
    }
 
    number -= 1;
    var a = p[0];
    const t = number + g + 0.5;
    for (var i = 1; i < p.length; i++) {
        a += p[i] / (number + i);
    }
 
    return Math.sqrt(2 * Math.PI) * Math.pow(t, number + 0.5) * Math.exp(-t) * a;
}
558794
def LogGamma(input_vertex: vertex_constructor_param_types, label: Optional[str]=None) -> Vertex:
    
    return Double(context.jvm_view().LogGammaVertex, label, cast_to_double_vertex(input_vertex))
439432
public static ZMatrixRMaj householder(ZMatrixRMaj u , double gamma ) {
        int N = u.getDataLength()/2;
        // u*u^H
        ZMatrixRMaj uut = new ZMatrixRMaj(N,N);
        VectorVectorMult_ZDRM.outerProdH(u, u, uut);
        // foo = -gamma*u*u^H
        CommonOps_ZDRM.elementMultiply(uut,-gamma,0,uut);

        // I + foo
        for (int i = 0; i < N; i++) {
            int index = (i*uut.numCols+i)*2;
            uut.data[index] = 1 + uut.data[index];
        }

        return uut;
    }