org.apache.mahout.math.jet.random.Gamma.logGamma()方法的使用及代码示例

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

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

Gamma.logGamma介绍

[英]Returns a quick approximation of log(gamma(x)).
[中]返回对数(gamma(x))的快速近似值。

代码示例

代码示例来源:origin: apache/mahout

  1. /** Returns the probability distribution function.
  2. * @param x Where to compute the density function.
  3. *
  4. * @return The value of the gamma density at x.
  5. */
  6. @Override
  7. public double pdf(double x) {
  8. if (x < 0) {
  9. throw new IllegalArgumentException();
  10. }
  11. if (x == 0) {
  12. if (alpha == 1.0) {
  13. return rate;
  14. } else if (alpha < 1) {
  15. return Double.POSITIVE_INFINITY;
  16. } else {
  17. return 0;
  18. }
  19. }
  20. if (alpha == 1.0) {
  21. return rate * Math.exp(-x * rate);
  22. }
  23. return rate * Math.exp((alpha - 1.0) * Math.log(x * rate) - x * rate - logGamma(alpha));
  24. }

代码示例来源:origin: cloudera/mahout

  1. /** Returns the probability distribution function.
  2. * @param x Where to compute the density function.
  3. *
  4. * @return The value of the gamma density at x.
  5. */
  6. @Override
  7. public double pdf(double x) {
  8. if (x < 0) {
  9. throw new IllegalArgumentException();
  10. }
  11. if (x == 0) {
  12. if (alpha == 1.0) {
  13. return rate;
  14. } else if (alpha < 1) {
  15. return Double.POSITIVE_INFINITY;
  16. } else {
  17. return 0;
  18. }
  19. }
  20. if (alpha == 1.0) {
  21. return rate * Math.exp(-x * rate);
  22. }
  23. return rate * Math.exp((alpha - 1.0) * Math.log(x * rate) - x * rate - logGamma(alpha));
  24. }

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

  1. /** Returns the probability distribution function.
  2. * @param x Where to compute the density function.
  3. *
  4. * @return The value of the gamma density at x.
  5. */
  6. @Override
  7. public double pdf(double x) {
  8. if (x < 0) {
  9. throw new IllegalArgumentException();
  10. }
  11. if (x == 0) {
  12. if (alpha == 1.0) {
  13. return rate;
  14. } else if (alpha < 1) {
  15. return Double.POSITIVE_INFINITY;
  16. } else {
  17. return 0;
  18. }
  19. }
  20. if (alpha == 1.0) {
  21. return rate * Math.exp(-x * rate);
  22. }
  23. return rate * Math.exp((alpha - 1.0) * Math.log(x * rate) - x * rate - logGamma(alpha));
  24. }

相关文章