Here you can find the source of gammaln(double x)
public static final double gammaln(double x)
//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); } }