本文整理汇总了Java中org.apache.commons.math.special.Beta类的典型用法代码示例。如果您正苦于以下问题:Java Beta类的具体用法?Java Beta怎么用?Java Beta使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Beta类属于org.apache.commons.math.special包,在下文中一共展示了Beta类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cdf
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
public static double cdf(double x, double mean, double alpha) {
double theta = 1.0 / alpha;
double p = theta / (theta + mean);
try {
return Beta.regularizedBeta(p, theta, x+1);
} catch (MathException e) {
// AR - throwing exceptions deep in numerical code causes trouble. Catching runtime
// exceptions is bad. Better to return NaN and let the calling code deal with it.
return Double.NaN;
// throw MathRuntimeException.createIllegalArgumentException(
// "Couldn't calculate beta cdf for alpha = " + alpha + ", beta = " + beta + ": " +e.getMessage());
}
}
示例2: cumulativeProbability
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* For this disbution, X, this method returns P(X < <code>x</code>).
* @param x the value at which the CDF is evaluated.
* @return CDF evaluted at <code>x</code>.
* @throws MathException if the cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException{
double ret;
if (x == 0.0) {
ret = 0.5;
} else {
double t =
Beta.regularizedBeta(
getDegreesOfFreedom() / (getDegreesOfFreedom() + (x * x)),
0.5 * getDegreesOfFreedom(),
0.5);
if (x < 0.0) {
ret = 0.5 * t;
} else {
ret = 1.0 - 0.5 * t;
}
}
return ret;
}
示例3: cumulativeProbability
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* For this distribution, X, this method returns P(X ≤ x).
* @param x the value at which the PDF is evaluated.
* @return PDF for this distribution.
* @throws MathException if the cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(int x) throws MathException {
double ret;
if (x < 0) {
ret = 0.0;
} else if (x >= getNumberOfTrials()) {
ret = 1.0;
} else {
ret =
1.0 - Beta.regularizedBeta(
getProbabilityOfSuccess(),
x + 1.0,
getNumberOfTrials() - x);
}
return ret;
}
示例4: cdf
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
public double cdf(double x) {
if (x <= 0) {
return 0;
} else if (x >= 1) {
return 1;
} else {
try {
return Beta.regularizedBeta(x, alpha, beta);
} catch (MathException e) {
// AR - throwing exceptions deep in numerical code causes trouble. Catching runtime
// exceptions is bad. Better to return NaN and let the calling code deal with it.
return Double.NaN;
// throw MathRuntimeException.createIllegalArgumentException(
// "Couldn't calculate beta cdf for alpha = " + alpha + ", beta = " + beta + ": " +e.getMessage());
}
}
}
示例5: getDescendingCumulativeProbabilityAt
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
@Override
public Double getDescendingCumulativeProbabilityAt(double x) throws MathException {
int k = (int) x;
if (k > n) {
return 0.0;
} else if (k < 0) {
return 1.0;
}
Double result = pCache.get(k);
if (result == null) {
// adapted from http://commons.apache.org/proper/commons-math/apidocs/src-html/org/apache/commons/math3/distribution/BinomialDistribution.html#line.130
result = Beta.regularizedBeta(p, x + 1.0, n - x);
addDescendingCumulativePToCache(k, result);
}
return result;
}
示例6: cumulativeProbability
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* For this distribution, X, this method returns P(X < <code>x</code>).
*
* @param x the value at which the CDF is evaluated.
* @return CDF evaluted at <code>x</code>.
* @throws MathException if the cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
@Override
public double cumulativeProbability(double x) throws MathException {
double ret;
if (x == 0.0) {
ret = 0.5;
} else {
double t =
Beta.regularizedBeta(
degreesOfFreedom / (degreesOfFreedom + (x * x)),
0.5 * degreesOfFreedom,
0.5);
if (x < 0.0) {
ret = 0.5 * t;
} else {
ret = 1.0 - 0.5 * t;
}
}
return ret;
}
示例7: cumulativeProbability
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* For this distribution, X, this method returns P(X < x).
* <p/>
* The implementation of this method is based on:
* <ul>
* <li>
* <a href="http://mathworld.wolfram.com/F-Distribution.html">
* F-Distribution</a>, equation (4).</li>
* </ul>
*
* @param x the value at which the CDF is evaluated.
* @return CDF for this distribution.
* @throws MathException if the cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
@Override
public double cumulativeProbability(double x) throws MathException {
double ret;
if (x <= 0.0) {
ret = 0.0;
} else {
double n = numeratorDegreesOfFreedom;
double m = denominatorDegreesOfFreedom;
ret = Beta.regularizedBeta((n * x) / (m + n * x),
0.5 * n,
0.5 * m);
}
return ret;
}
示例8: cumulativeProbability
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* For this distribution, X, this method returns P(X < <code>x</code>).
* @param x the value at which the CDF is evaluated.
* @return CDF evaluted at <code>x</code>.
* @throws MathException if the cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException{
double ret;
if (x == 0.0) {
ret = 0.5;
} else {
double t =
Beta.regularizedBeta(
getDegreesOfFreedom() / (getDegreesOfFreedom() + (x * x)),
0.5 * getDegreesOfFreedom(),
0.5);
if (x < 0.0) {
ret = 0.5 * t;
} else {
ret = 1.0 - 0.5 * t;
}
}
return ret;
}
示例9: cumulativeProbability
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* For this distribution, X, this method returns {@code P(X < x}).
*
* @param x Value at which the CDF is evaluated.
* @return CDF evaluated at {@code x}.
* @throws MathException if the cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException{
double ret;
if (x == 0) {
ret = 0.5;
} else {
double t =
Beta.regularizedBeta(
degreesOfFreedom / (degreesOfFreedom + (x * x)),
0.5 * degreesOfFreedom,
0.5);
if (x < 0.0) {
ret = 0.5 * t;
} else {
ret = 1.0 - 0.5 * t;
}
}
return ret;
}
示例10: cumulativeProbability
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* For this distribution, X, this method returns P(X < <code>x</code>).
* @param x the value at which the CDF is evaluated.
* @return CDF evaluted at <code>x</code>.
* @throws MathException if the cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException{
double ret;
if (x == 0.0) {
ret = 0.5;
} else {
double t =
Beta.regularizedBeta(
degreesOfFreedom / (degreesOfFreedom + (x * x)),
0.5 * degreesOfFreedom,
0.5);
if (x < 0.0) {
ret = 0.5 * t;
} else {
ret = 1.0 - 0.5 * t;
}
}
return ret;
}
示例11: cumulativeProbability
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* For this distribution, X, this method returns P(X < <code>x</code>).
* @param x the value at which the CDF is evaluated.
* @return CDF evaluted at <code>x</code>.
* @throws MathException if the cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException{
double ret;
if (x == 0.0) {
ret = 0.5;
} else {
double t =
Beta.regularizedBeta(
getDegreesOfFreedom() / (getDegreesOfFreedom() + (x * x)),
0.5 * getDegreesOfFreedom(),
0.5);
if (x < 0.0) {
ret = 0.5 * t;
} else {
ret = 1.0 - 0.5 * t;
}
}
return ret;
}
示例12: cumulativeProbability
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* For this distribution, X, this method returns P(X ≤ x).
* @param x the value at which the PDF is evaluated.
* @return PDF for this distribution.
* @throws MathException if the cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
@Override
public double cumulativeProbability(int x) throws MathException {
double ret;
if (x < 0) {
ret = 0.0;
} else if (x >= getNumberOfTrials()) {
ret = 1.0;
} else {
ret =
1.0 - Beta.regularizedBeta(
getProbabilityOfSuccess(),
x + 1.0,
getNumberOfTrials() - x);
}
return ret;
}
示例13: cumulativeProbability
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* For this distribution, X, this method returns P(X < <code>x</code>).
*
* @param x the value at which the CDF is evaluated.
* @return CDF evaluted at <code>x</code>.
* @throws MathException if the cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException {
double ret;
if (x == 0.0) {
ret = 0.5;
} else {
double t =
Beta.regularizedBeta(
degreesOfFreedom / (degreesOfFreedom + (x * x)),
0.5 * degreesOfFreedom,
0.5);
if (x < 0.0) {
ret = 0.5 * t;
} else {
ret = 1.0 - 0.5 * t;
}
}
return ret;
}
示例14: evaluate
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* @param x x
* @return the value of the function
* @throws IllegalArgumentException If $x < 0$ or $x > 1$
*/
@Override
public Double evaluate(final Double x) {
Validate.isTrue(x >= 0 && x <= 1, "x must be in the range 0 to 1");
try {
return Beta.regularizedBeta(x, _a, _b, _eps, _maxIter);
} catch (final org.apache.commons.math.MathException e) {
throw new MathException(e);
}
}
示例15: cumulativeProbability
import org.apache.commons.math.special.Beta; //导入依赖的package包/类
/**
* For this distribution, X, this method returns P(X ≤ x).
* @param x the value at which the PDF is evaluated
* @return PDF for this distribution
* @throws MathException if the cumulative probability can not be computed
* due to convergence or other numerical errors
*/
public double cumulativeProbability(int x) throws MathException {
double ret;
if (x < 0) {
ret = 0.0;
} else {
ret = Beta.regularizedBeta(getProbabilityOfSuccess(),
getNumberOfSuccesses(), x + 1);
}
return ret;
}