Java Code Examples for org.apache.commons.math.special.Beta#regularizedBeta()

The following examples show how to use org.apache.commons.math.special.Beta#regularizedBeta() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Cardumen_0054_s.java    From coming with MIT License 6 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &lt; <code>x</code>).
 * @param x the value at which the CDF is evaluated.
 * @return CDF evaluated 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;
}
 
Example 2
Source File: BinomialDistributionImpl.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &le; 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;
}
 
Example 3
Source File: TDistributionImpl.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &lt; <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;
}
 
Example 4
Source File: BinomialDistributionImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * For this distribution, {@code X}, this method returns {@code P(X <= x)}.
 *
 * @param x 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 >= numberOfTrials) {
        ret = 1.0;
    } else {
        ret = 1.0 - Beta.regularizedBeta(getProbabilityOfSuccess(),
                x + 1.0, numberOfTrials - x);
    }
    return ret;
}
 
Example 5
Source File: PascalDistributionImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &le; 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 {
        ret = Beta.regularizedBeta(probabilityOfSuccess,
            numberOfSuccesses, x + 1);
    }
    return ret;
}
 
Example 6
Source File: BinomialDistributionImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &le; 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;
}
 
Example 7
Source File: BetaDistributionImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public double cumulativeProbability(double x) throws MathException {
    if (x <= 0) {
        return 0;
    } else if (x >= 1) {
        return 1;
    } else {
        return Beta.regularizedBeta(x, alpha, beta);
    }
}
 
Example 8
Source File: PascalDistributionImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &le; 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 {
        ret = Beta.regularizedBeta(getProbabilityOfSuccess(),
            getNumberOfSuccesses(), x + 1);
    }
    return ret;
}
 
Example 9
Source File: BetaDistributionImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/** {@inheritDoc} */
public double cumulativeProbability(double x) throws MathException {
    if (x <= 0) {
        return 0;
    } else if (x >= 1) {
        return 1;
    } else {
        return Beta.regularizedBeta(x, alpha, beta);
    }
}
 
Example 10
Source File: BetaDistribution.java    From beast-mcmc with GNU Lesser General Public License v2.1 5 votes vote down vote up
public double cumulativeProbability(double x) throws MathException {
    if (x <= 0) {
        return 0;
    } else if (x >= 1) {
        return 1;
    } else {
        return Beta.regularizedBeta(x, alpha, beta);
    }
}
 
Example 11
Source File: PascalDistributionImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &le; 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 {
        ret = Beta.regularizedBeta(getProbabilityOfSuccess(),
            getNumberOfSuccesses(), x + 1);
    }
    return ret;
}
 
Example 12
Source File: PascalDistributionImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &le; 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 {
        ret = Beta.regularizedBeta(probabilityOfSuccess,
            numberOfSuccesses, x + 1);
    }
    return ret;
}
 
Example 13
Source File: BinomialDistributionImpl.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * For this distribution, {@code X}, this method returns {@code P(X <= x)}.
 *
 * @param x 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 >= numberOfTrials) {
        ret = 1.0;
    } else {
        ret = 1.0 - Beta.regularizedBeta(getProbabilityOfSuccess(),
                x + 1.0, numberOfTrials - x);
    }
    return ret;
}
 
Example 14
Source File: FDistributionImpl.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &lt; x).
 * 
 * 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.
 */
public double cumulativeProbability(double x) throws MathException {
    double ret;
    if (x <= 0.0) {
        ret = 0.0;
    } else {
        double n = getNumeratorDegreesOfFreedom();
        double m = getDenominatorDegreesOfFreedom();
        
        ret = Beta.regularizedBeta((n * x) / (m + n * x),
            0.5 * n,
            0.5 * m);
    }
    return ret;
}
 
Example 15
Source File: Cardumen_0067_s.java    From coming with MIT License 3 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &lt; x).
 * 
 * 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.
 */
public double cumulativeProbability(double x) throws MathException {
    double ret;
    if (x <= 0.0) {
        ret = 0.0;
    } else {
        double n = getNumeratorDegreesOfFreedom();
        double m = getDenominatorDegreesOfFreedom();
        
        ret = Beta.regularizedBeta((n * x) / (m + n * x),
            0.5 * n,
            0.5 * m);
    }
    return ret;
}
 
Example 16
Source File: JGenProg2017_0075_t.java    From coming with MIT License 3 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &lt; x).
 * 
 * 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.
 */
public double cumulativeProbability(double x) throws MathException {
    double ret;
    if (x <= 0.0) {
        ret = 0.0;
    } else {
        double n = getNumeratorDegreesOfFreedom();
        double m = getDenominatorDegreesOfFreedom();
        
        ret = Beta.regularizedBeta((n * x) / (m + n * x),
            0.5 * n,
            0.5 * m);
    }
    return ret;
}
 
Example 17
Source File: FDistributionImpl.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &lt; x).
 *
 * 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.
 */
public double cumulativeProbability(double x) throws MathException {
    double ret;
    if (x <= 0.0) {
        ret = 0.0;
    } else {
        double n = getNumeratorDegreesOfFreedom();
        double m = getDenominatorDegreesOfFreedom();

        ret = Beta.regularizedBeta((n * x) / (m + n * x),
            0.5 * n,
            0.5 * m);
    }
    return ret;
}
 
Example 18
Source File: FDistributionImpl.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * For this disbution, X, this method returns P(X &lt; x).
 * 
 * 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.
 */
public double cumulativeProbability(double x) throws MathException {
    double ret;
    if (x <= 0.0) {
        ret = 0.0;
    } else {
        double n = getNumeratorDegreesOfFreedom();
        double m = getDenominatorDegreesOfFreedom();
        
        ret = Beta.regularizedBeta((n * x) / (m + n * x),
            0.5 * n,
            0.5 * m);
    }
    return ret;
}
 
Example 19
Source File: JGenProg2017_00140_s.java    From coming with MIT License 3 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &lt; x).
 * 
 * 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.
 */
public double cumulativeProbability(double x) throws MathException {
    double ret;
    if (x <= 0.0) {
        ret = 0.0;
    } else {
        double n = getNumeratorDegreesOfFreedom();
        double m = getDenominatorDegreesOfFreedom();
        
        ret = Beta.regularizedBeta((n * x) / (m + n * x),
            0.5 * n,
            0.5 * m);
    }
    return ret;
}
 
Example 20
Source File: Cardumen_00279_s.java    From coming with MIT License 3 votes vote down vote up
/**
 * For this distribution, X, this method returns P(X &lt; x).
 * 
 * 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.
 */
public double cumulativeProbability(double x) throws MathException {
    double ret;
    if (x <= 0.0) {
        ret = 0.0;
    } else {
        double n = getNumeratorDegreesOfFreedom();
        double m = getDenominatorDegreesOfFreedom();
        
        ret = Beta.regularizedBeta((n * x) / (m + n * x),
            0.5 * n,
            0.5 * m);
    }
    return ret;
}