/// <inheritdoc/> public new double logProbability(int x) { double ret; int[] domain = getDomain(populationSize, numberOfSuccesses, sampleSize); if (x < domain[0] || x > domain[1]) { ret = Double.NegativeInfinity; } else { double p = (double)sampleSize / (double)populationSize; double q = (double)(populationSize - sampleSize) / (double)populationSize; double p1 = SaddlePointExpansion.logBinomialProbability(x, numberOfSuccesses, p, q); double p2 = SaddlePointExpansion.logBinomialProbability(sampleSize - x, populationSize - numberOfSuccesses, p, q); double p3 = SaddlePointExpansion.logBinomialProbability(sampleSize, populationSize, p, q); ret = p1 + p2 - p3; } return(ret); }
/// <inheritdoc/> public new double logProbability(int x) { if (numberOfTrials == 0) { return((x == 0) ? 0d : Double.NegativeInfinity); } double ret; if (x < 0 || x > numberOfTrials) { ret = Double.NegativeInfinity; } else { ret = SaddlePointExpansion.logBinomialProbability(x, numberOfTrials, probabilityOfSuccess, 1.0 - probabilityOfSuccess); } return(ret); }
/// <inheritdoc/> public new double logProbability(int x) { double ret; if (x < 0 || x == Int32.MaxValue) { ret = Double.NegativeInfinity; } else if (x == 0) { ret = -mean; } else { ret = -SaddlePointExpansion.getStirlingError(x) - SaddlePointExpansion.getDeviancePart(x, mean) - 0.5 * FastMath.log(MathUtils.TWO_PI) - 0.5 * FastMath.log(x); } return(ret); }