Java Gamma gammaln(double x)

Here you can find the source of gammaln(double x)

Description

from numerical recipes in c (p.

License

Open Source License

Declaration

public static final double gammaln(double x) 

Method Source Code

//package com.java2s;
/*/*  w w  w  . ja va  2s  .  c  om*/
 * Copyright (C) 2008-2015 by Holger Arndt
 *
 * This file is part of the Universal Java Matrix Package (UJMP).
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership and licensing.
 *
 * UJMP is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * UJMP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with UJMP; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301  USA
 */

public class Main {
    private static final double COFGAMMALN[] = { 76.18009172947146, -86.50532032941677, 24.01409824083091,
            -1.231739572450155, 0.1208650973866179e-2, -0.5395239384953e-5 };

    /**
     * from numerical recipes in c (p. 214)
     */
    public static final double gammaln(double x) {
        double ser = 1.00000000090015;
        double y = x;
        double tmp = x + 5.5;
        tmp -= (x + 0.5) * Math.log(tmp);
        for (int j = 0; j < 5; j++) {
            ser += COFGAMMALN[j] / ++y;
        }
        return -tmp + Math.log(ser * 2.5066282751072975 / x);
    }
}

Related

  1. gammaCdf(double a, double x)
  2. gammaCdf(double a, double x)
  3. gammaCorrection(final float gamma, final float x)
  4. gammaFunction(double in)
  5. gammaFwd(double lc)
  6. gammaOfArgOn2Plus1(int d)
  7. gammaOfArgOn2Plus1IncludeDivisor(int d, double divisor)
  8. gammaPdf(double x, double a)
  9. gammaRand(double a)