当前位置: 首页>>代码示例>>Java>>正文


Java MathUtils.TWO_PI属性代码示例

本文整理汇总了Java中org.apache.commons.math.util.MathUtils.TWO_PI属性的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.TWO_PI属性的具体用法?Java MathUtils.TWO_PI怎么用?Java MathUtils.TWO_PI使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.math.util.MathUtils的用法示例。


在下文中一共展示了MathUtils.TWO_PI属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logBinomialProbability

/**
 * Compute the PMF for a binomial distribution using the saddle point
 * expansion.
 *
 * @param x the value at which the probability is evaluated.
 * @param n the number of trials.
 * @param p the probability of success.
 * @param q the probability of failure (1 - p).
 * @return log(p(x)).
 */
static double logBinomialProbability(int x, int n, double p, double q) {
    double ret;
    if (x == 0) {
        if (p < 0.1) {
            ret = -getDeviancePart(n, n * q) - n * p;
        } else {
            ret = n * Math.log(q);
        }
    } else if (x == n) {
        if (q < 0.1) {
            ret = -getDeviancePart(n, n * p) - n * q;
        } else {
            ret = n * Math.log(p);
        }
    } else {
        ret = getStirlingError(n) - getStirlingError(x) -
                getStirlingError(n - x) - getDeviancePart(x, n * p) -
                getDeviancePart(n - x, n * q);
        double f = (MathUtils.TWO_PI * x * (n - x)) / n;
        ret = -0.5 * Math.log(f) + ret;
    }
    return ret;
}
 
开发者ID:CompEvol,项目名称:beast2,代码行数:33,代码来源:SaddlePointExpansion.java

示例2: logBinomialProbability

/**
 * Compute the PMF for a binomial distribution using the saddle point
 * expansion.
 *
 * @param x the value at which the probability is evaluated.
 * @param n the number of trials.
 * @param p the probability of success.
 * @param q the probability of failure (1 - p).
 * @return log(p(x)).
 */
static double logBinomialProbability(int x, int n, double p, double q) {
    double ret;
    if (x == 0) {
        if (p < 0.1) {
            ret = -getDeviancePart(n, n * q) - n * p;
        } else {
            ret = n * Math.log(q);
        }
    } else if (x == n) {
        if (q < 0.1) {
            ret = -getDeviancePart(n, n * p) - n * q;
        } else {
            ret = n * Math.log(p);
        }
    } else {
        ret = getStirlingError(n) - getStirlingError(x) -
              getStirlingError(n - x) - getDeviancePart(x, n * p) -
              getDeviancePart(n - x, n * q);
        double f = (MathUtils.TWO_PI * x * (n - x)) / n;
        ret = -0.5 * Math.log(f) + ret;
    }
    return ret;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:33,代码来源:SaddlePointExpansion.java

示例3: logBinomialProbability

/**
 * Compute the PMF for a binomial distribution using the saddle point
 * expansion.
 *
 * @param x the value at which the probability is evaluated.
 * @param n the number of trials.
 * @param p the probability of success.
 * @param q the probability of failure (1 - p).
 * @return log(p(x)).
 */
static double logBinomialProbability(int x, int n, double p, double q) {
    double ret;
    if (x == 0) {
        if (p < 0.1) {
            ret = -getDeviancePart(n, n * q) - n * p;
        } else {
            ret = n * FastMath.log(q);
        }
    } else if (x == n) {
        if (q < 0.1) {
            ret = -getDeviancePart(n, n * p) - n * q;
        } else {
            ret = n * FastMath.log(p);
        }
    } else {
        ret = getStirlingError(n) - getStirlingError(x) -
              getStirlingError(n - x) - getDeviancePart(x, n * p) -
              getDeviancePart(n - x, n * q);
        double f = (MathUtils.TWO_PI * x * (n - x)) / n;
        ret = -0.5 * FastMath.log(f) + ret;
    }
    return ret;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:33,代码来源:SaddlePointExpansion.java


注:本文中的org.apache.commons.math.util.MathUtils.TWO_PI属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。