Here you can find the source of digammaDiff(double x, int d)
Parameter | Description |
---|---|
x | a parameter |
d | a parameter |
public static double digammaDiff(double x, int d)
//package com.java2s; //License from project: Apache License public class Main { public static final double c1 = -0.5; public static final double c2 = -1.0 / 12; public static final double c4 = 1.0 / 120; public static final double c6 = -1.0 / 252; /**// www . j a v a 2s .c o m * Compute digamma difference * * @param x * @param d * @return */ public static double digammaDiff(double x, int d) { double sum = 0; int dcutoff = 16; if (d > dcutoff) { return (digamma(x + d) - digamma(x)); } for (int i = 0; i < d; ++i) { sum += 1 / (x + i); } return (sum); } /** * Compute the value of digamma function * * @param x * @return */ public static double digamma(double x) { double y, y2, sum = 0; for (y = x; y < 10; y++) { sum -= 1.0 / y; } y2 = 1.0 / (y * y); sum += Math.log(y) + c1 / y + y2 * (c2 + y2 * (c4 + y2 * c6)); return sum; } }