docs: public static double logpmf(double x, int n, double p) {
      // Invalid values
      if(x < 0 || x > n) {
        return Double.NEGATIVE_INFINITY;
      }
      // Extreme probabilities
      if(p <= 0.) {
        return x == 0 ? 0. : Double.NEGATIVE_INFINITY;
      }
      if(p >= 1.) {
        return x == n ? 0. : Double.NEGATIVE_INFINITY;
      }
      final double q = 1 - p;
      // FIXME: check for x to be integer, return 0 otherwise?
  
      // Extreme values of x
      if(x == 0) {
        if(p < .1) {
          return -devianceTerm(n, n * q) - n * p;
        }
        else {
          return n * FastMath.log(q);
        }
      }
      if(x == n) {
        if(p > .9) {
          return -devianceTerm(n, n * p) - n * q;
        }
        else {
          return n * FastMath.log(p);
        }
      }
      final double lc = stirlingError(n) - stirlingError(x) - stirlingError(n - x) - devianceTerm(x, n * p) - devianceTerm(n - x, n * q);
      final double f = (MathUtil.TWOPI * x * (n - x)) / n;
      return lc - .5 * FastMath.log(f);
    }