本文整理汇总了Java中org.apache.commons.math.util.MathUtils.binomialCoefficientDouble方法的典型用法代码示例。如果您正苦于以下问题:Java MathUtils.binomialCoefficientDouble方法的具体用法?Java MathUtils.binomialCoefficientDouble怎么用?Java MathUtils.binomialCoefficientDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math.util.MathUtils
的用法示例。
在下文中一共展示了MathUtils.binomialCoefficientDouble方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: choose
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
public static double choose(double n, int k) {
/*
* Because gamma(a+1) = factorial(a)
* we use gamma(n+1) /(gamma(n-k+1) * gamma(k+1)) instead of
* Binomial(n,k) = n! / ((n-k)! * k!) for non-integer n values.
*
*/
if (k < 0) {
return (0);
} else if (k == 0) {
return (1);
} else if ((int) n == n) {
return (MathUtils.binomialCoefficientDouble((int) n, k));
} else {
return (MathExt.gamma(n + 1) / (MathExt.gamma(n - k + 1) * MathExt.gamma(k + 1)));
}
}
示例2: probability
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* For this distribution, X, this method returns P(X = x).
* @param x the value at which the PMF is evaluated
* @return PMF for this distribution
*/
public double probability(int x) {
double ret;
if (x < 0) {
ret = 0.0;
} else {
ret = MathUtils.binomialCoefficientDouble(x +
getNumberOfSuccesses() - 1, getNumberOfSuccesses() - 1) *
Math.pow(getProbabilityOfSuccess(), getNumberOfSuccesses()) *
Math.pow(1.0 - getProbabilityOfSuccess(), x);
}
return ret;
}
示例3: probability
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* For this disbution, X, this method returns P(X = x).
*
* @param x the value at which the PMF is evaluated.
* @return PMF for this distribution.
*/
public double probability(int x) {
double ret;
if (x < 0 || x > getNumberOfTrials()) {
ret = 0.0;
} else {
ret = MathUtils.binomialCoefficientDouble(
getNumberOfTrials(), x) *
Math.pow(getProbabilityOfSuccess(), x) *
Math.pow(1.0 - getProbabilityOfSuccess(),
getNumberOfTrials() - x);
}
return ret;
}
示例4: probability
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* For this distribution, X, this method returns P(X = x).
*
* @param x the value at which the PMF is evaluated
* @return PMF for this distribution
*/
@Override
public double probability(int x) {
double ret;
if (x < 0) {
ret = 0.0;
} else {
ret = MathUtils.binomialCoefficientDouble(x +
numberOfSuccesses - 1, numberOfSuccesses - 1) *
Math.pow(probabilityOfSuccess, numberOfSuccesses) *
Math.pow(1.0 - probabilityOfSuccess, x);
}
return ret;
}
示例5: probability
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* For this distribution, {@code X}, this method returns {@code P(X = x)}.
*
* @param x Value at which the PMF is evaluated.
* @return PMF for this distribution.
*/
public double probability(int x) {
double ret;
if (x < 0) {
ret = 0.0;
} else {
ret = MathUtils.binomialCoefficientDouble(x +
numberOfSuccesses - 1, numberOfSuccesses - 1) *
FastMath.pow(probabilityOfSuccess, numberOfSuccesses) *
FastMath.pow(1.0 - probabilityOfSuccess, x);
}
return ret;
}
示例6: probability
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* For this distribution, X, this method returns P(X = x).
* @param x the value at which the PMF is evaluated
* @return PMF for this distribution
*/
public double probability(int x) {
double ret;
if (x < 0) {
ret = 0.0;
} else {
ret = MathUtils.binomialCoefficientDouble(x +
numberOfSuccesses - 1, numberOfSuccesses - 1) *
Math.pow(probabilityOfSuccess, numberOfSuccesses) *
Math.pow(1.0 - probabilityOfSuccess, x);
}
return ret;
}
示例7: probability
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* For this distribution, X, this method returns P(X = x).
*
* @param x the value at which the PMF is evaluated.
* @return PMF for this distribution.
*/
public double probability(int x) {
double ret;
if (x < 0 || x > getNumberOfTrials()) {
ret = 0.0;
} else {
ret = MathUtils.binomialCoefficientDouble(
getNumberOfTrials(), x) *
Math.pow(getProbabilityOfSuccess(), x) *
Math.pow(1.0 - getProbabilityOfSuccess(),
getNumberOfTrials() - x);
}
return ret;
}
示例8: probability
import org.apache.commons.math.util.MathUtils; //导入方法依赖的package包/类
/**
* For this distribution, X, this method returns P(X = x).
*
* @param x the value at which the PMF is evaluated
* @return PMF for this distribution
*/
public double probability(int x) {
double ret;
if (x < 0) {
ret = 0.0;
} else {
ret = MathUtils.binomialCoefficientDouble(x + getNumberOfSuccesses() - 1,
getNumberOfSuccesses() - 1) *
Math.pow(getProbabilityOfSuccess(), getNumberOfSuccesses()) *
Math.pow(1.0 - getProbabilityOfSuccess(),
x);
}
return ret;
}