@Override public double cumulativeProbability(double x) { double ret; if (x < 0) { ret = 0.0D; } else if (x >= this.numberOfTrials) { ret = 1.0D; } else { ret = 1.0D - Beta.regularizedBeta(this.probabilityOfSuccess, x + 1.0D, (this.numberOfTrials - x)); } return ret; }
/** * Returns the natural logarithm of the beta function B(a, b). * * The implementation of this method is based on: * <ul> * <li><a href="http://mathworld.wolfram.com/BetaFunction.html"> * Beta Function</a>, equation (1).</li> * </ul> * * @param a Parameter {@code a}. * @param b Parameter {@code b}. * @param epsilon This parameter is ignored. * @param maxIterations This parameter is ignored. * @return log(B(a, b)). * @deprecated as of version 3.1, this method is deprecated as the * computation of the beta function is no longer iterative; it will be * removed in version 4.0. Current implementation of this method * internally calls {@link #logBeta(double, double)}. */ @Deprecated public static double logBeta(double a, double b, double epsilon, int maxIterations) { return logBeta(a, b); }
final double b = FastMath.max(p, q); if (a >= 10.0) { final double w = sumDeltaMinusDeltaSum(a, b); final double h = a / b; final double c = h / (1.0 + h); logGammaMinusLogGammaSum(ared, b)); } else { double prod1 = 1.0; (Gamma.logGamma(ared) + (Gamma.logGamma(bred) - logGammaSum(ared, bred))); } else { return FastMath.log(prod1) + Gamma.logGamma(ared) + logGammaMinusLogGammaSum(ared, b); (Gamma.logGamma(a) + (Gamma.logGamma(bred) - logGammaSum(a, bred))); } else { return Gamma.logGamma(a) + logGammaMinusLogGammaSum(a, b); logGammaSum(a, b); logGammaMinusLogGammaSum(a, b); } else {
} else if (x > (a + 1) / (2 + b + a) && 1 - x <= (b + 1) / (2 + b + a)) { ret = 1 - regularizedBeta(1 - x, b, a, epsilon, maxIterations); } else { ContinuedFraction fraction = new ContinuedFraction() { FastMath.log(a) - logBeta(a, b)) * 1.0 / fraction.evaluate(x, epsilon, maxIterations);
if (a <= b) { d = b + (a - 0.5); w = deltaMinusDeltaSum(a, b); } else { d = a + (b - 0.5); w = deltaMinusDeltaSum(b, a);
final double b = Math.max(p, q); if (a >= 10.0) { final double w = sumDeltaMinusDeltaSum(a, b); final double h = a / b; final double c = h / (1.0 + h); logGammaMinusLogGammaSum(ared, b)); } else { double prod1 = 1.0; (Gamma.logGamma(ared) + (Gamma.logGamma(bred) - logGammaSum(ared, bred))); } else { return Math.log(prod1) + Gamma.logGamma(ared) + logGammaMinusLogGammaSum(ared, b); (Gamma.logGamma(a) + (Gamma.logGamma(bred) - logGammaSum(a, bred))); } else { return Gamma.logGamma(a) + logGammaMinusLogGammaSum(a, b); logGammaSum(a, b); logGammaMinusLogGammaSum(a, b); } else {
} else if (x > (a + 1) / (2 + b + a) && 1 - x <= (b + 1) / (2 + b + a)) { ret = 1 - regularizedBeta(1 - x, b, a, epsilon, maxIterations); } else { ContinuedFraction fraction = new ContinuedFraction() { Math.log(a) - logBeta(a, b)) * 1.0 / fraction.evaluate(x, epsilon, maxIterations);
/** * Returns the value of Δ(p) + Δ(q) - Δ(p + q), with p, q ≥ 10. Based on * the <em>NSWC Library of Mathematics Subroutines</em> double precision * implementation, {@code DBCORR}. In * {@code BetaTest.testSumDeltaMinusDeltaSum()}, this private method is * accessed through reflection. * * @param p First argument. * @param q Second argument. * @return the value of {@code Delta(p) + Delta(q) - Delta(p + q)}. * @throws NumberIsTooSmallException if {@code p < 10.0} or {@code q < 10.0}. */ private static double sumDeltaMinusDeltaSum(final double p, final double q) { if (p < 10.0) { throw new NumberIsTooSmallException(p, 10.0, true); } if (q < 10.0) { throw new NumberIsTooSmallException(q, 10.0, true); } final double a = FastMath.min(p, q); final double b = FastMath.max(p, q); final double sqrtT = 10.0 / a; final double t = sqrtT * sqrtT; double z = DELTA[DELTA.length - 1]; for (int i = DELTA.length - 2; i >= 0; i--) { z = t * z + DELTA[i]; } return z / a + deltaMinusDeltaSum(a, b); }
/** {@inheritDoc} */ public double cumulativeProbability(double x) { if (x <= 0) { return 0; } else if (x >= 1) { return 1; } else { return Beta.regularizedBeta(x, alpha, beta); } }
final double b = FastMath.max(p, q); if (a >= 10.0) { final double w = sumDeltaMinusDeltaSum(a, b); final double h = a / b; final double c = h / (1.0 + h); logGammaMinusLogGammaSum(ared, b)); } else { double prod1 = 1.0; (Gamma.logGamma(ared) + (Gamma.logGamma(bred) - logGammaSum(ared, bred))); } else { return FastMath.log(prod1) + Gamma.logGamma(ared) + logGammaMinusLogGammaSum(ared, b); (Gamma.logGamma(a) + (Gamma.logGamma(bred) - logGammaSum(a, bred))); } else { return Gamma.logGamma(a) + logGammaMinusLogGammaSum(a, b); logGammaSum(a, b); logGammaMinusLogGammaSum(a, b); } else {
} else if (x > (a + 1) / (2 + b + a) && 1 - x <= (b + 1) / (2 + b + a)) { ret = 1 - regularizedBeta(1 - x, b, a, epsilon, maxIterations); } else { ContinuedFraction fraction = new ContinuedFraction() { FastMath.log(a) - logBeta(a, b)) * 1.0 / fraction.evaluate(x, epsilon, maxIterations);
/** {@inheritDoc} **/ @Override public double logDensity(double x) { final double nhalf = numeratorDegreesOfFreedom / 2; final double mhalf = denominatorDegreesOfFreedom / 2; final double logx = FastMath.log(x); final double logn = FastMath.log(numeratorDegreesOfFreedom); final double logm = FastMath.log(denominatorDegreesOfFreedom); final double lognxm = FastMath.log(numeratorDegreesOfFreedom * x + denominatorDegreesOfFreedom); return nhalf * logn + nhalf * logx - logx + mhalf * logm - nhalf * lognxm - mhalf * lognxm - Beta.logBeta(nhalf, mhalf); }
/** * Returns the value of ?(p) + ?(q) - ?(p + q), with p, q ? 10. Based on * the <em>NSWC Library of Mathematics Subroutines</em> double precision * implementation, {@code DBCORR}. In * {@code BetaTest.testSumDeltaMinusDeltaSum()}, this private method is * accessed through reflection. * * @param p First argument. * @param q Second argument. * @return the value of {@code Delta(p) + Delta(q) - Delta(p + q)}. * @throws NumberIsTooSmallException if {@code p < 10.0} or {@code q < 10.0}. */ private static double sumDeltaMinusDeltaSum(final double p, final double q) { if (p < 10.0) { throw new NumberIsTooSmallException(p, 10.0, true); } if (q < 10.0) { throw new NumberIsTooSmallException(q, 10.0, true); } final double a = Math.min(p, q); final double b = Math.max(p, q); final double sqrtT = 10.0 / a; final double t = sqrtT * sqrtT; double z = DELTA[DELTA.length - 1]; for (int i = DELTA.length - 2; i >= 0; i--) { z = t * z + DELTA[i]; } return z / a + deltaMinusDeltaSum(a, b); }
/** {@inheritDoc} */ public double cumulativeProbability(int x) { double ret; if (x < 0) { ret = 0.0; } else { ret = Beta.regularizedBeta(probabilityOfSuccess, numberOfSuccesses, x + 1.0); } return ret; }
final public static double beta(double a, double b) { return Math.exp(Beta.logBeta(a, b)); }
if (a <= b) { d = b + (a - 0.5); w = deltaMinusDeltaSum(a, b); } else { d = a + (b - 0.5); w = deltaMinusDeltaSum(b, a);
/** {@inheritDoc} */ public double cumulativeProbability(int x) { double ret; if (x < 0) { ret = 0.0; } else if (x >= numberOfTrials) { ret = 1.0; } else { ret = 1.0 - Beta.regularizedBeta(probabilityOfSuccess, x + 1.0, numberOfTrials - x); } return ret; }
/** * Returns the natural logarithm of the beta function B(a, b). * * The implementation of this method is based on: * <ul> * <li><a href="http://mathworld.wolfram.com/BetaFunction.html"> * Beta Function</a>, equation (1).</li> * </ul> * * @param a Parameter {@code a}. * @param b Parameter {@code b}. * @param epsilon This parameter is ignored. * @param maxIterations This parameter is ignored. * @return log(B(a, b)). * @deprecated as of version 3.1, this method is deprecated as the * computation of the beta function is no longer iterative; it will be * removed in version 4.0. Current implementation of this method * internally calls {@link #logBeta(double, double)}. */ @Deprecated public static double logBeta(double a, double b, double epsilon, int maxIterations) { return logBeta(a, b); }
if (a <= b) { d = b + (a - 0.5); w = deltaMinusDeltaSum(a, b); } else { d = a + (b - 0.5); w = deltaMinusDeltaSum(b, a);
/** * {@inheritDoc} */ public double cumulativeProbability(int x) { double ret; if (x < 0) { ret = 0.0; } else if (x >= numberOfTrials) { ret = 1.0; } else { ret = 1.0 - Beta.regularizedBeta(probabilityOfSuccess, x + 1.0, numberOfTrials - x); } return ret; }