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

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

本文整理了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

/** Returns the probability distribution function.
 * @param x Where to compute the density function.
 *
 * @return The value of the gamma density at x.
 */
@Override
public double pdf(double x) {
 if (x < 0) {
  throw new IllegalArgumentException();
 }
 if (x == 0) {
  if (alpha == 1.0) {
   return rate;
  } else if (alpha < 1) {
   return Double.POSITIVE_INFINITY;
  } else {
   return 0;
  }
 }
 if (alpha == 1.0) {
  return rate * Math.exp(-x * rate);
 }
 return rate * Math.exp((alpha - 1.0) * Math.log(x * rate) - x * rate - logGamma(alpha));
}

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

/** Returns the probability distribution function.
 * @param x Where to compute the density function.
 *
 * @return The value of the gamma density at x.
 */
@Override
public double pdf(double x) {
 if (x < 0) {
  throw new IllegalArgumentException();
 }
 if (x == 0) {
  if (alpha == 1.0) {
   return rate;
  } else if (alpha < 1) {
   return Double.POSITIVE_INFINITY;
  } else {
   return 0;
  }
 }
 if (alpha == 1.0) {
  return rate * Math.exp(-x * rate);
 }
 return rate * Math.exp((alpha - 1.0) * Math.log(x * rate) - x * rate - logGamma(alpha));
}

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

/** Returns the probability distribution function.
 * @param x Where to compute the density function.
 *
 * @return The value of the gamma density at x.
 */
@Override
public double pdf(double x) {
 if (x < 0) {
  throw new IllegalArgumentException();
 }
 if (x == 0) {
  if (alpha == 1.0) {
   return rate;
  } else if (alpha < 1) {
   return Double.POSITIVE_INFINITY;
  } else {
   return 0;
  }
 }
 if (alpha == 1.0) {
  return rate * Math.exp(-x * rate);
 }
 return rate * Math.exp((alpha - 1.0) * Math.log(x * rate) - x * rate - logGamma(alpha));
}

相关文章