org.apache.commons.math3.special.Gamma.logGamma()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(190)

本文整理了Java中org.apache.commons.math3.special.Gamma.logGamma()方法的一些代码示例,展示了Gamma.logGamma()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Gamma.logGamma()方法的具体详情如下:
包路径:org.apache.commons.math3.special.Gamma
类名称:Gamma
方法名:logGamma

Gamma.logGamma介绍

[英]Returns the value of log Γ(x) for x > 0.

For x ≤ 8, the implementation is based on the double precision implementation in the NSWC Library of Mathematics Subroutines, DGAMLN. For x > 8, the implementation is based on

代码示例

代码示例来源:origin: org.apache.commons/commons-math3

  1. /** Recompute the normalization factor. */
  2. private void recomputeZ() {
  3. if (Double.isNaN(z)) {
  4. z = Gamma.logGamma(alpha) + Gamma.logGamma(beta) - Gamma.logGamma(alpha + beta);
  5. }
  6. }

代码示例来源:origin: org.apache.commons/commons-math3

  1. /**
  2. * Creates a t distribution.
  3. *
  4. * @param rng Random number generator.
  5. * @param degreesOfFreedom Degrees of freedom.
  6. * @param inverseCumAccuracy the maximum absolute error in inverse
  7. * cumulative probability estimates
  8. * (defaults to {@link #DEFAULT_INVERSE_ABSOLUTE_ACCURACY}).
  9. * @throws NotStrictlyPositiveException if {@code degreesOfFreedom <= 0}
  10. * @since 3.1
  11. */
  12. public TDistribution(RandomGenerator rng,
  13. double degreesOfFreedom,
  14. double inverseCumAccuracy)
  15. throws NotStrictlyPositiveException {
  16. super(rng);
  17. if (degreesOfFreedom <= 0) {
  18. throw new NotStrictlyPositiveException(LocalizedFormats.DEGREES_OF_FREEDOM,
  19. degreesOfFreedom);
  20. }
  21. this.degreesOfFreedom = degreesOfFreedom;
  22. solverAbsoluteAccuracy = inverseCumAccuracy;
  23. final double n = degreesOfFreedom;
  24. final double nPlus1Over2 = (n + 1) / 2;
  25. factor = Gamma.logGamma(nPlus1Over2) -
  26. 0.5 * (FastMath.log(FastMath.PI) + FastMath.log(n)) -
  27. Gamma.logGamma(n / 2);
  28. }

代码示例来源:origin: org.apache.commons/commons-math3

  1. /**
  2. * used by {@link #getNumericalMean()}
  3. *
  4. * @return the mean of this distribution
  5. */
  6. protected double calculateNumericalMean() {
  7. final double sh = getShape();
  8. final double sc = getScale();
  9. return sc * FastMath.exp(Gamma.logGamma(1 + (1 / sh)));
  10. }

代码示例来源:origin: deeplearning4j/nd4j

  1. ret = EXACT_STIRLING_ERRORS[(int) z2];
  2. } else {
  3. ret = Gamma.logGamma(z + 1.0) - (z + 0.5) * FastMath.log(z) + z - HALF_LOG_2_PI;

代码示例来源:origin: org.apache.commons/commons-math3

  1. ret = EXACT_STIRLING_ERRORS[(int) z2];
  2. } else {
  3. ret = Gamma.logGamma(z + 1.0) - (z + 0.5) * FastMath.log(z) +
  4. z - HALF_LOG_2_PI;

代码示例来源:origin: org.apache.commons/commons-math3

  1. /**
  2. * used by {@link #getNumericalVariance()}
  3. *
  4. * @return the variance of this distribution
  5. */
  6. protected double calculateNumericalVariance() {
  7. final double sh = getShape();
  8. final double sc = getScale();
  9. final double mn = getNumericalMean();
  10. return (sc * sc) * FastMath.exp(Gamma.logGamma(1 + (2 / sh))) -
  11. (mn * mn);
  12. }

代码示例来源:origin: org.apache.commons/commons-math3

  1. ret = FastMath.exp(-x + (a * FastMath.log(x)) - logGamma(a)) * ret;

代码示例来源:origin: org.apache.commons/commons-math3

  1. ret = 1.0;
  2. } else {
  3. ret = FastMath.exp(-x + (a * FastMath.log(x)) - logGamma(a)) * sum;

代码示例来源:origin: org.apache.commons/commons-math3

  1. (Gamma.logGamma(ared) +
  2. logGammaMinusLogGammaSum(ared, b));
  3. } else {
  4. (Gamma.logGamma(ared) +
  5. (Gamma.logGamma(bred) -
  6. logGammaSum(ared, bred)));
  7. } else {
  8. return FastMath.log(prod1) +
  9. Gamma.logGamma(ared) +
  10. logGammaMinusLogGammaSum(ared, b);
  11. (Gamma.logGamma(a) +
  12. (Gamma.logGamma(bred) -
  13. logGammaSum(a, bred)));
  14. } else {
  15. return Gamma.logGamma(a) +
  16. logGammaMinusLogGammaSum(a, b);
  17. return Gamma.logGamma(a) +
  18. Gamma.logGamma(b) -
  19. logGammaSum(a, b);
  20. return Gamma.logGamma(a) +
  21. logGammaMinusLogGammaSum(a, b);
  22. } else {

代码示例来源:origin: lenskit/lenskit

  1. pLL = (rating == 0) ? (-eThetaBeta) : Math.log(1 - Math.exp(-eThetaBeta));
  2. } else {
  3. pLL = rating * Math.log(eThetaBeta) - eThetaBeta - Gamma.logGamma(rating + 1);

代码示例来源:origin: improbable-research/keanu

  1. @Override
  2. public DoubleTensor logGammaInPlace() {
  3. value = Gamma.logGamma(value);
  4. return this;
  5. }

代码示例来源:origin: geogebra/geogebra

  1. /** Recompute the normalization factor. */
  2. private void recomputeZ() {
  3. if (Double.isNaN(z)) {
  4. z = Gamma.logGamma(alpha) + Gamma.logGamma(beta) - Gamma.logGamma(alpha + beta);
  5. }
  6. }

代码示例来源:origin: org.apache.mahout/mahout-mrlegacy

  1. @Override
  2. public double logP(double betaIJ) {
  3. return Gamma.logGamma((df + 1.0) / 2.0)
  4. - Math.log(df * Math.PI)
  5. - Gamma.logGamma(df / 2.0)
  6. - (df + 1.0) / 2.0 * Math.log1p(betaIJ * betaIJ);
  7. }

代码示例来源:origin: org.apache.mahout/mahout-mr

  1. @Override
  2. public double logP(double betaIJ) {
  3. return Gamma.logGamma((df + 1.0) / 2.0)
  4. - Math.log(df * Math.PI)
  5. - Gamma.logGamma(df / 2.0)
  6. - (df + 1.0) / 2.0 * Math.log1p(betaIJ * betaIJ);
  7. }

代码示例来源:origin: OpenGamma/Strata

  1. @Override
  2. public double applyAsDouble(double x) {
  3. if (x > 0.0) {
  4. return Math.exp(Gamma.logGamma(x));
  5. }
  6. return Math.PI / Math.sin(Math.PI * x) / applyAsDouble(1 - x);
  7. }

代码示例来源:origin: OpenGamma/Strata

  1. @Override
  2. public Double apply(Double x) {
  3. ArgChecker.isTrue(x > 0, "x must be greater than zero");
  4. return Gamma.logGamma(x);
  5. }

代码示例来源:origin: lenskit/lenskit

  1. pLL = (rating == 0) ? (-eThetaBeta) : Math.log(1 - Math.exp(-eThetaBeta));
  2. } else {
  3. pLL = rating * Math.log(eThetaBeta) - eThetaBeta - Gamma.logGamma(rating + 1);

代码示例来源:origin: geogebra/geogebra

  1. /**
  2. * used by {@link #getNumericalMean()}
  3. *
  4. * @return the mean of this distribution
  5. */
  6. protected double calculateNumericalMean() {
  7. final double sh = getShape();
  8. final double sc = getScale();
  9. return sc * Math.exp(Gamma.logGamma(1 + (1 / sh)));
  10. }

代码示例来源:origin: improbable-research/keanu

  1. @Test
  2. public void logGammaMatrixVertexValues() {
  3. operatesOn2x2MatrixVertexValues(
  4. new double[]{0.0, 0.1, 0.2, 0.3},
  5. new double[]{Gamma.logGamma(0.0), Gamma.logGamma(0.1), Gamma.logGamma(0.2), Gamma.logGamma(0.3)},
  6. DoubleVertex::logGamma
  7. );
  8. }

代码示例来源:origin: geogebra/geogebra

  1. /**
  2. * used by {@link #getNumericalVariance()}
  3. *
  4. * @return the variance of this distribution
  5. */
  6. protected double calculateNumericalVariance() {
  7. final double sh = getShape();
  8. final double sc = getScale();
  9. final double mn = getNumericalMean();
  10. return (sc * sc) * Math.exp(Gamma.logGamma(1 + (2 / sh))) -
  11. (mn * mn);
  12. }

相关文章