This is a multifile commit, it covers checkstyle errors in javadoc etc.

PR: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=20936
Submitted by:	brent@worden.org


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@140936 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark R. Diggory 2003-06-21 02:21:49 +00:00
parent d3f4480aff
commit b84e9460b5
14 changed files with 157 additions and 151 deletions

View File

@ -54,16 +54,14 @@
package org.apache.commons.math; package org.apache.commons.math;
/** /**
* <p>
* Provides a generic means to evaluate continued fractions. Subclasses simply * Provides a generic means to evaluate continued fractions. Subclasses simply
* provided the a and b coefficients to evaluate the continued fraction. * provided the a and b coefficients to evaluate the continued fraction.
* </p>
* *
* <p> * References:
* Reference:<br/> * <ul>
* <a href="http://mathworld.wolfram.com/ContinuedFraction.html"> * <li><a href="http://mathworld.wolfram.com/ContinuedFraction.html">
* Continued Fraction</a> * Continued Fraction</a></li>
* </p> * </ul>
* *
* @author Brent Worden * @author Brent Worden
*/ */
@ -126,11 +124,8 @@ public abstract class ContinuedFraction {
} }
/** /**
* <p>
* Evaluates the continued fraction at the value x. * Evaluates the continued fraction at the value x.
* </p>
* *
* <p>
* The implementation of this method is based on: * The implementation of this method is based on:
* <ul> * <ul>
* <li>O. E-gecio-glu, C . K. Koc, J. Rifa i Coma, * <li>O. E-gecio-glu, C . K. Koc, J. Rifa i Coma,
@ -138,7 +133,6 @@ public abstract class ContinuedFraction {
* Fast Computation of Continued Fractions</a>, Computers Math. Applic., * Fast Computation of Continued Fractions</a>, Computers Math. Applic.,
* 21(2--3), 1991, 167--169.</li> * 21(2--3), 1991, 167--169.</li>
* </ul> * </ul>
* </p>
* *
* @param x the evaluation point. * @param x the evaluation point.
* @param epsilon maximum error allowed. * @param epsilon maximum error allowed.
@ -188,11 +182,11 @@ public abstract class ContinuedFraction {
f[1][1] = (a[1][0] * an[0][1]) + (a[1][1] * an[1][1]); f[1][1] = (a[1][0] * an[0][1]) + (a[1][1] * an[1][1]);
// determine if we're close enough // determine if we're close enough
if(Math.abs((f[0][0] * f[1][1]) - (f[1][0] * f[0][1])) < if (Math.abs((f[0][0] * f[1][1]) - (f[1][0] * f[0][1])) <
Math.abs(epsilon * f[1][0] * f[1][1])){ Math.abs(epsilon * f[1][0] * f[1][1])) {
ret = f[0][0] / f[1][0]; ret = f[0][0] / f[1][0];
} else { } else {
if(n >= maxIterations){ if (n >= maxIterations) {
throw new ConvergenceException( throw new ConvergenceException(
"Continued fraction convergents failed to converge."); "Continued fraction convergents failed to converge.");
} }

View File

@ -94,7 +94,7 @@ public abstract class AbstractContinuousDistribution
* @return x, such that P(X &lt; x) = <code>p</code> * @return x, such that P(X &lt; x) = <code>p</code>
*/ */
public double inverseCummulativeProbability(final double p) { public double inverseCummulativeProbability(final double p) {
if (p < 0.0 || p > 1.0){ if (p < 0.0 || p > 1.0) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"p must be between 0.0 and 1.0, inclusive."); "p must be between 0.0 and 1.0, inclusive.");
} }

View File

@ -54,21 +54,16 @@
package org.apache.commons.math.stat.distribution; package org.apache.commons.math.stat.distribution;
/** /**
* <p> * The Chi-Squared Distribution.
* The Chi-Squared Distribution
* </p>
* *
* <p>
* Instances of ChiSquaredDistribution objects should be created using * Instances of ChiSquaredDistribution objects should be created using
* {@link DistributionFactory#createChiSquareDistribution(double)} * {@link DistributionFactory#createChiSquareDistribution(double)}.
* </p>
* *
* <p>
* References: * References:
* <ul> * <ul>
* <li><a href="http://mathworld.wolfram.com/Chi-SquaredDistribution.html"> * <li><a href="http://mathworld.wolfram.com/Chi-SquaredDistribution.html">
* Chi-Squared Distribution</a></li> * Chi-Squared Distribution</a></li>
* </p> * </ul>
* *
* @author Brent Worden * @author Brent Worden
*/ */

View File

@ -54,7 +54,6 @@
package org.apache.commons.math.stat.distribution; package org.apache.commons.math.stat.distribution;
/** /**
* <p>
* This factory provids the means to create common statistical distributions. * This factory provids the means to create common statistical distributions.
* The following distributions are supported: * The following distributions are supported:
* <ul> * <ul>
@ -63,16 +62,13 @@ package org.apache.commons.math.stat.distribution;
* <li>Gamma</li> * <li>Gamma</li>
* <li>Student's t</li> * <li>Student's t</li>
* </ul> * </ul>
* </p>
* *
* <p>
* Common usage:<pre> * Common usage:<pre>
* DistributionFactory factory = DistributionFactory.newInstance(); * DistributionFactory factory = DistributionFactory.newInstance();
* *
* // create a Chi-Square distribution with 5 degrees of freedom. * // create a Chi-Square distribution with 5 degrees of freedom.
* ChiSquaredDistribution chi = factory.createChiSquareDistribution(5.0); * ChiSquaredDistribution chi = factory.createChiSquareDistribution(5.0);
* </pre> * </pre>
* </p>
* *
* @author Brent Worden * @author Brent Worden
*/ */

View File

@ -54,21 +54,15 @@
package org.apache.commons.math.stat.distribution; package org.apache.commons.math.stat.distribution;
/** /**
* <p> * The Exponential Distribution.
* The Exponential Distribution
* </p>
* *
* <p>
* Instances of ExponentialDistribution objects should be created using * Instances of ExponentialDistribution objects should be created using
* {@link DistributionFactory#createExponentialDistribution(double)} * {@link DistributionFactory#createExponentialDistribution(double)}.
* </p>
* *
* <p>
* References: * References:
* <ul> * <ul>
* <li><a href="http://mathworld.wolfram.com/ExponentialDistribution.html"> * <li><a href="http://mathworld.wolfram.com/ExponentialDistribution.html">
* Exponential Distribution</a></li> * Exponential Distribution</a></li>
* </p>
* *
* @author Brent Worden * @author Brent Worden
*/ */

View File

@ -1,3 +1,56 @@
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.commons.math.stat.distribution; package org.apache.commons.math.stat.distribution;
/** /**
@ -6,65 +59,61 @@ package org.apache.commons.math.stat.distribution;
* @author Brent Worden * @author Brent Worden
*/ */
public class ExponentialDistributionImpl public class ExponentialDistributionImpl
implements ExponentialDistribution { implements ExponentialDistribution {
/** The mean of this distribution. */ /** The mean of this distribution. */
private double mean; private double mean;
/** /**
* Create a exponential distribution with the given mean. * Create a exponential distribution with the given mean.
* @param degreesOfFreedom degrees of freedom. * @param mean mean of this distribution.
*/ */
public ExponentialDistributionImpl(double mean) { public ExponentialDistributionImpl(double mean) {
super(); super();
setMean(mean); setMean(mean);
} }
/** /**
* Modify the mean. * Modify the mean.
* @param mean the new mean. * @param mean the new mean.
*/ */
public void setMean(double mean) { public void setMean(double mean) {
if(mean <= 0.0){ if (mean <= 0.0) {
throw new IllegalArgumentException("mean must be positive."); throw new IllegalArgumentException("mean must be positive.");
} }
this.mean = mean; this.mean = mean;
} }
/** /**
* Access the mean. * Access the mean.
* @return the mean. * @return the mean.
*/ */
public double getMean() { public double getMean() {
return mean; return mean;
} }
/** /**
* <p>
* For this disbution, X, this method returns P(X &lt; x). * For this disbution, X, this method returns P(X &lt; x).
* </p>
* *
* <p>
* The implementation of this method is based on: * The implementation of this method is based on:
* <ul> * <ul>
* <li> * <li>
* <a href="http://mathworld.wolfram.com/ExponentialDistribution.html"> * <a href="http://mathworld.wolfram.com/ExponentialDistribution.html">
* Exponential Distribution</a>, equation (1).</li> * Exponential Distribution</a>, equation (1).</li>
* </ul> * </ul>
* </p>
* *
* @param x the value at which the CDF is evaluated. * @param x the value at which the CDF is evaluated.
* @return CDF for this distribution. * @return CDF for this distribution.
*/ */
public double cummulativeProbability(double x) { public double cummulativeProbability(double x) {
double ret; double ret;
if(x <= 0.0){ if (x <= 0.0) {
ret = 0.0; ret = 0.0;
} else { } else {
ret = 1.0 - Math.exp(-x / getMean()); ret = 1.0 - Math.exp(-x / getMean());
} }
return ret; return ret;
} }
/** /**
* For this distribution, X, this method returns the critical point x, such * For this distribution, X, this method returns the critical point x, such
@ -73,12 +122,12 @@ public class ExponentialDistributionImpl
* @param p the desired probability * @param p the desired probability
* @return x, such that P(X &lt; x) = <code>p</code> * @return x, such that P(X &lt; x) = <code>p</code>
*/ */
public double inverseCummulativeProbability(double p){ public double inverseCummulativeProbability(double p) {
double ret; double ret;
if(p < 0.0 || p > 1.0){ if (p < 0.0 || p > 1.0) {
ret = Double.NaN; ret = Double.NaN;
} else if(p == 1.0){ } else if (p == 1.0) {
ret = Double.POSITIVE_INFINITY; ret = Double.POSITIVE_INFINITY;
} else { } else {
ret = -getMean() * Math.log(1.0 - p); ret = -getMean() * Math.log(1.0 - p);

View File

@ -54,20 +54,16 @@
package org.apache.commons.math.stat.distribution; package org.apache.commons.math.stat.distribution;
/** /**
* <p>
* F-Distribution. * F-Distribution.
* </p>
* *
* <p>
* Instances of FDistribution objects should be created using * Instances of FDistribution objects should be created using
* {@link DistributionFactory#createFDistribution(double,double)} * {@link DistributionFactory#createFDistribution(double,double)}.
* </p>
* *
* <p> * References:
* Reference:<br/> * <ul>
* <a href="http://mathworld.wolfram.com/F-Distribution.html"> * <li><a href="http://mathworld.wolfram.com/F-Distribution.html">
* F-Distribution</a> * F-Distribution</a></li>
* </p> * </ul>
* *
* @author Brent Worden * @author Brent Worden
*/ */

View File

@ -57,7 +57,7 @@ import org.apache.commons.math.special.Beta;
/** /**
* Default implementation of * Default implementation of
* {@link org.apache.commons.math.stat.distribution.TDistribution}. * {@link org.apache.commons.math.stat.distribution.FDistribution}.
* *
* @author Brent Worden * @author Brent Worden
*/ */
@ -73,35 +73,32 @@ public class FDistributionImpl
/** /**
* Create a F distribution using the given degrees of freedom. * Create a F distribution using the given degrees of freedom.
* @param numeratorDegreesOfFreedom the degrees of freedom. * @param numeratorDegreesOfFreedom the numerator degrees of freedom.
* @param denominatorDegreesOfFreedom * @param denominatorDegreesOfFreedom the denominator degrees of freedom.
*/ */
public FDistributionImpl(double numeratorDegreesOfFreedom, public FDistributionImpl(double numeratorDegreesOfFreedom,
double denominatorDegreesOfFreedom){ double denominatorDegreesOfFreedom) {
super(); super();
setNumeratorDegreesOfFreedom(numeratorDegreesOfFreedom); setNumeratorDegreesOfFreedom(numeratorDegreesOfFreedom);
setDenominatorDegreesOfFreedom(denominatorDegreesOfFreedom); setDenominatorDegreesOfFreedom(denominatorDegreesOfFreedom);
} }
/** /**
* <p>
* For this disbution, X, this method returns P(X &lt; x). * For this disbution, X, this method returns P(X &lt; x).
* </p>
* *
* <p>
* The implementation of this method is based on: * The implementation of this method is based on:
* <ul> * <ul>
* <li> * <li>
* <a href="http://mathworld.wolfram.com/F-Distribution.html"> * <a href="http://mathworld.wolfram.com/F-Distribution.html">
* F-Distribution</a>, equation (4).</li> * F-Distribution</a>, equation (4).</li>
* </p> * </ul>
* *
* @param x the value at which the CDF is evaluated. * @param x the value at which the CDF is evaluated.
* @return CDF for this distribution. * @return CDF for this distribution.
*/ */
public double cummulativeProbability(double x) { public double cummulativeProbability(double x) {
double ret; double ret;
if(x <= 0.0){ if (x <= 0.0) {
ret = 0.0; ret = 0.0;
} else { } else {
double n = getNumeratorDegreesOfFreedom(); double n = getNumeratorDegreesOfFreedom();
@ -123,7 +120,7 @@ public class FDistributionImpl
* @return domain value lower bound, i.e. * @return domain value lower bound, i.e.
* P(X &lt; <i>lower bound</i>) &lt; <code>p</code> * P(X &lt; <i>lower bound</i>) &lt; <code>p</code>
*/ */
protected double getDomainLowerBound(double p){ protected double getDomainLowerBound(double p) {
return 0.0; return 0.0;
} }
@ -136,7 +133,7 @@ public class FDistributionImpl
* @return domain value upper bound, i.e. * @return domain value upper bound, i.e.
* P(X &lt; <i>upper bound</i>) &gt; <code>p</code> * P(X &lt; <i>upper bound</i>) &gt; <code>p</code>
*/ */
protected double getDomainUpperBound(double p){ protected double getDomainUpperBound(double p) {
return Double.MAX_VALUE; return Double.MAX_VALUE;
} }
@ -148,16 +145,17 @@ public class FDistributionImpl
* @param p the desired probability for the critical value * @param p the desired probability for the critical value
* @return initial domain value * @return initial domain value
*/ */
protected double getInitialDomain(double p){ protected double getInitialDomain(double p) {
return getDenominatorDegreesOfFreedom() / (getDenominatorDegreesOfFreedom() - 2.0); return getDenominatorDegreesOfFreedom() /
(getDenominatorDegreesOfFreedom() - 2.0);
} }
/** /**
* Modify the numerator degrees of freedom. * Modify the numerator degrees of freedom.
* @param degreesOfFreedom the new numerator degrees of freedom. * @param degreesOfFreedom the new numerator degrees of freedom.
*/ */
public void setNumeratorDegreesOfFreedom(double degreesOfFreedom){ public void setNumeratorDegreesOfFreedom(double degreesOfFreedom) {
if(degreesOfFreedom <= 0.0){ if (degreesOfFreedom <= 0.0) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"degrees of freedom must be positive."); "degrees of freedom must be positive.");
} }
@ -168,7 +166,7 @@ public class FDistributionImpl
* Access the numerator degrees of freedom. * Access the numerator degrees of freedom.
* @return the numerator degrees of freedom. * @return the numerator degrees of freedom.
*/ */
public double getNumeratorDegreesOfFreedom(){ public double getNumeratorDegreesOfFreedom() {
return numeratorDegreesOfFreedom; return numeratorDegreesOfFreedom;
} }
@ -176,8 +174,8 @@ public class FDistributionImpl
* Modify the denominator degrees of freedom. * Modify the denominator degrees of freedom.
* @param degreesOfFreedom the new denominator degrees of freedom. * @param degreesOfFreedom the new denominator degrees of freedom.
*/ */
public void setDenominatorDegreesOfFreedom(double degreesOfFreedom){ public void setDenominatorDegreesOfFreedom(double degreesOfFreedom) {
if(degreesOfFreedom <= 0.0){ if (degreesOfFreedom <= 0.0) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"degrees of freedom must be positive."); "degrees of freedom must be positive.");
} }
@ -188,7 +186,7 @@ public class FDistributionImpl
* Access the denominator degrees of freedom. * Access the denominator degrees of freedom.
* @return the denominator degrees of freedom. * @return the denominator degrees of freedom.
*/ */
public double getDenominatorDegreesOfFreedom(){ public double getDenominatorDegreesOfFreedom() {
return denominatorDegreesOfFreedom; return denominatorDegreesOfFreedom;
} }
} }

View File

@ -54,21 +54,16 @@
package org.apache.commons.math.stat.distribution; package org.apache.commons.math.stat.distribution;
/** /**
* <p> * The Gamma Distribution.
* The Gamma Distribution
* </p>
* *
* <p>
* Instances of GammaDistribution objects should be created using * Instances of GammaDistribution objects should be created using
* {@link DistributionFactory#createGammaDistribution(double,double)} * {@link DistributionFactory#createGammaDistribution(double,double)}.
* </p>
* *
* <p>
* References: * References:
* <ul> * <ul>
* <li><a href="http://mathworld.wolfram.com/GammaDistribution.html"> * <li><a href="http://mathworld.wolfram.com/GammaDistribution.html">
* Gamma Distribution</a></li> * Gamma Distribution</a></li>
* </p> * </ul>
* *
* @author Brent Worden * @author Brent Worden
*/ */

View File

@ -81,11 +81,8 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
} }
/** /**
* <p>
* For this disbution, X, this method returns P(X &lt; x). * For this disbution, X, this method returns P(X &lt; x).
* </p>
* *
* <p>
* The implementation of this method is based on: * The implementation of this method is based on:
* <ul> * <ul>
* <li> * <li>
@ -94,7 +91,6 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
* <li>Casella, G., & Berger, R. (1990). <i>Statistical Inference</i>. * <li>Casella, G., & Berger, R. (1990). <i>Statistical Inference</i>.
* Belmont, CA: Duxbury Press.</li> * Belmont, CA: Duxbury Press.</li>
* </ul> * </ul>
* </p>
* *
* @param x the value at which the CDF is evaluated. * @param x the value at which the CDF is evaluated.
* @return CDF for this distribution. * @return CDF for this distribution.
@ -179,7 +175,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
double ret; double ret;
if(p < .5){ if (p < .5) {
// use mean // use mean
ret = getAlpha() * getBeta(); ret = getAlpha() * getBeta();
} else { } else {
@ -205,7 +201,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
double ret; double ret;
if(p < .5){ if (p < .5) {
// use 1/2 mean // use 1/2 mean
ret = getAlpha() * getBeta() * .5; ret = getAlpha() * getBeta() * .5;
} else { } else {

View File

@ -54,20 +54,16 @@
package org.apache.commons.math.stat.distribution; package org.apache.commons.math.stat.distribution;
/** /**
* <p>
* Student's t-Distribution. * Student's t-Distribution.
* </p>
* *
* <p>
* Instances of TDistribution objects should be created using * Instances of TDistribution objects should be created using
* {@link DistributionFactory#createTDistribution(double)} * {@link DistributionFactory#createTDistribution(double)}
* </p>
* *
* <p> * References:
* Reference:<br/> * <ul>
* <a href="http://mathworld.wolfram.com/Studentst-Distribution.html"> * <li><a href="http://mathworld.wolfram.com/Studentst-Distribution.html">
* Student's t-Distribution</a> * Student's t-Distribution</a></li>
* </p> * </ul>
* *
* @author Brent Worden * @author Brent Worden
*/ */

View File

@ -72,7 +72,7 @@ public class TDistributionImpl
* Create a t distribution using the given degrees of freedom. * Create a t distribution using the given degrees of freedom.
* @param degreesOfFreedom the degrees of freedom. * @param degreesOfFreedom the degrees of freedom.
*/ */
public TDistributionImpl(double degreesOfFreedom){ public TDistributionImpl(double degreesOfFreedom) {
super(); super();
setDegreesOfFreedom(degreesOfFreedom); setDegreesOfFreedom(degreesOfFreedom);
} }
@ -82,7 +82,7 @@ public class TDistributionImpl
* @param degreesOfFreedom the new degrees of freedom. * @param degreesOfFreedom the new degrees of freedom.
*/ */
public void setDegreesOfFreedom(double degreesOfFreedom) { public void setDegreesOfFreedom(double degreesOfFreedom) {
if(degreesOfFreedom <= 0.0){ if (degreesOfFreedom <= 0.0) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"degrees of freedom must be positive."); "degrees of freedom must be positive.");
} }
@ -104,14 +104,14 @@ public class TDistributionImpl
*/ */
public double cummulativeProbability(double x) { public double cummulativeProbability(double x) {
double ret; double ret;
if(x == 0.0){ if (x == 0.0) {
ret = 0.5; ret = 0.5;
} else { } else {
double t = Beta.regularizedBeta( double t = Beta.regularizedBeta(
getDegreesOfFreedom() / (getDegreesOfFreedom() + (x * x)), getDegreesOfFreedom() / (getDegreesOfFreedom() + (x * x)),
0.5 * getDegreesOfFreedom(), 0.5); 0.5 * getDegreesOfFreedom(), 0.5);
if(x < 0.0){ if (x < 0.0) {
ret = 0.5 * t; ret = 0.5 * t;
} else { } else {
ret = 1.0 - 0.5 * t; ret = 1.0 - 0.5 * t;
@ -130,7 +130,7 @@ public class TDistributionImpl
* @return domain value lower bound, i.e. * @return domain value lower bound, i.e.
* P(X &lt; <i>lower bound</i>) &lt; <code>p</code> * P(X &lt; <i>lower bound</i>) &lt; <code>p</code>
*/ */
protected double getDomainLowerBound(double p){ protected double getDomainLowerBound(double p) {
return -Double.MAX_VALUE; return -Double.MAX_VALUE;
} }
@ -143,7 +143,7 @@ public class TDistributionImpl
* @return domain value upper bound, i.e. * @return domain value upper bound, i.e.
* P(X &lt; <i>upper bound</i>) &gt; <code>p</code> * P(X &lt; <i>upper bound</i>) &gt; <code>p</code>
*/ */
protected double getDomainUpperBound(double p){ protected double getDomainUpperBound(double p) {
return Double.MAX_VALUE; return Double.MAX_VALUE;
} }
@ -155,7 +155,7 @@ public class TDistributionImpl
* @param p the desired probability for the critical value * @param p the desired probability for the critical value
* @return initial domain value * @return initial domain value
*/ */
protected double getInitialDomain(double p){ protected double getInitialDomain(double p) {
return 0.0; return 0.0;
} }
} }

View File

@ -73,9 +73,7 @@ public class Beta {
} }
/** /**
* <p>
* Returns the regularized beta function I(x, a, b). * Returns the regularized beta function I(x, a, b).
* </p>
* *
* @param x ??? * @param x ???
* @param a ??? * @param a ???
@ -87,39 +85,40 @@ public class Beta {
} }
/** /**
* <p>
* Returns the regularized beta function I(x, a, b). * Returns the regularized beta function I(x, a, b).
* </p>
* *
* @param x ??? * @param x ???
* @param a ??? * @param a ???
* @param b ??? * @param b ???
* @param epsilon When the absolute value of the nth item in the
* series is less than epsilon the approximation ceases
* to calculate further elements in the series.
* @return the regularized beta function I(x, a, b) * @return the regularized beta function I(x, a, b)
*/ */
public static double regularizedBeta(double x, double a, double b, double epsilon) { public static double regularizedBeta(double x, double a, double b,
double epsilon) {
return regularizedBeta(x, a, b, epsilon, Integer.MAX_VALUE); return regularizedBeta(x, a, b, epsilon, Integer.MAX_VALUE);
} }
/** /**
* <p>
* Returns the regularized beta function I(x, a, b). * Returns the regularized beta function I(x, a, b).
* </p>
* *
* @param x ??? * @param x ???
* @param a ??? * @param a ???
* @param b ??? * @param b ???
* @param maxIterations Maximum number of "iterations" to complete.
* @return the regularized beta function I(x, a, b) * @return the regularized beta function I(x, a, b)
*/ */
public static double regularizedBeta(double x, double a, double b, int maxIterations) { public static double regularizedBeta(double x, double a, double b,
int maxIterations) {
return regularizedBeta(x, a, b, DEFAULT_EPSILON, maxIterations); return regularizedBeta(x, a, b, DEFAULT_EPSILON, maxIterations);
} }
/** /**
* <p>
* Returns the regularized beta function I(x, a, b). * Returns the regularized beta function I(x, a, b).
* </p>
* *
* <p>
* The implementation of this method is based on: * The implementation of this method is based on:
* <ul> * <ul>
* <li> * <li>
@ -129,14 +128,19 @@ public class Beta {
* <a href="http://functions.wolfram.com/06.21.10.0001.01"> * <a href="http://functions.wolfram.com/06.21.10.0001.01">
* Regularized Beta Function</a>.</li> * Regularized Beta Function</a>.</li>
* </ul> * </ul>
* </p>
* *
* @param x ??? * @param x ???
* @param a ??? * @param a ???
* @param b ??? * @param b ???
* @param epsilon When the absolute value of the nth item in the
* series is less than epsilon the approximation ceases
* to calculate further elements in the series.
* @param maxIterations Maximum number of "iterations" to complete.
* @return the regularized beta function I(x, a, b) * @return the regularized beta function I(x, a, b)
*/ */
public static double regularizedBeta(double x, final double a, final double b, double epsilon, int maxIterations) { public static double regularizedBeta(double x, final double a,
final double b, double epsilon, int maxIterations) {
double ret; double ret;
if (Double.isNaN(x) || Double.isNaN(a) || Double.isNaN(b) || (x < 0) if (Double.isNaN(x) || Double.isNaN(a) || Double.isNaN(b) || (x < 0)
@ -155,8 +159,9 @@ public class Beta {
if (n % 2 == 0) { // even if (n % 2 == 0) { // even
m = (n - 2.0) / 2.0; m = (n - 2.0) / 2.0;
ret = ret =
- ((a + m) * (a + b + m) * x) -((a + m) * (a + b + m) * x)
/ ((a + (2 * m)) * (a + (2 * m) + 1.0)); / ((a + (2 * m))
* (a + (2 * m) + 1.0));
} else { } else {
m = (n - 1.0) / 2.0; m = (n - 1.0) / 2.0;
ret = ret =
@ -180,17 +185,17 @@ public class Beta {
} }
return ret; return ret;
} }
}; };
ret = Math.exp((a * Math.log(x)) + (b * Math.log(1.0 - x)) - Math.log(a) - logBeta(a, b, epsilon, maxIterations)) * fraction.evaluate(x, epsilon, maxIterations); ret = Math.exp((a * Math.log(x)) + (b * Math.log(1.0 - x))
- Math.log(a) - logBeta(a, b, epsilon, maxIterations))
* fraction.evaluate(x, epsilon, maxIterations);
} }
return ret; return ret;
} }
/** /**
* <p>
* Returns the natural logarithm of the beta function B(a, b). * Returns the natural logarithm of the beta function B(a, b).
* </p>
* *
* @param a ??? * @param a ???
* @param b ??? * @param b ???
@ -201,23 +206,25 @@ public class Beta {
} }
/** /**
* <p>
* Returns the natural logarithm of the beta function B(a, b). * Returns the natural logarithm of the beta function B(a, b).
* </p>
* *
* <p>
* The implementation of this method is based on: * The implementation of this method is based on:
* <ul> * <ul>
* <li><a href="http://mathworld.wolfram.com/BetaFunction.html"> * <li><a href="http://mathworld.wolfram.com/BetaFunction.html">
* Beta Function</a>, equation (1).</li> * Beta Function</a>, equation (1).</li>
* </ul> * </ul>
* </p>
* *
* @param a ??? * @param a ???
* @param b ??? * @param b ???
* @param epsilon When the absolute value of the nth item in the
* series is less than epsilon the approximation ceases
* to calculate further elements in the series.
* @param maxIterations Maximum number of "iterations" to complete.
* @return log(B(a, b)) * @return log(B(a, b))
*/ */
public static double logBeta(double a, double b, double epsilon, int maxIterations) { public static double logBeta(double a, double b, double epsilon,
int maxIterations) {
double ret; double ret;
if (Double.isNaN(a) || Double.isNaN(b) || (a <= 0.0) || (b <= 0.0)) { if (Double.isNaN(a) || Double.isNaN(b) || (a <= 0.0) || (b <= 0.0)) {

View File

@ -94,9 +94,7 @@ public class Gamma {
} }
/** /**
* <p>
* Returns the regularized gamma function P(a, x). * Returns the regularized gamma function P(a, x).
* </p>
* *
* @param a ??? * @param a ???
* @param x ??? * @param x ???
@ -107,11 +105,8 @@ public class Gamma {
} }
/** /**
* <p>
* Returns the regularized gamma function P(a, x). * Returns the regularized gamma function P(a, x).
* </p>
* *
* <p>
* The implementation of this method is based on: * The implementation of this method is based on:
* <ul> * <ul>
* <li> * <li>
@ -125,7 +120,6 @@ public class Gamma {
* Confluent Hypergeometric Function of the First Kind</a>, equation (1). * Confluent Hypergeometric Function of the First Kind</a>, equation (1).
* </li> * </li>
* </ul> * </ul>
* </p>
* *
* @param a ??? * @param a ???
* @param x ??? * @param x ???
@ -173,11 +167,8 @@ public class Gamma {
} }
/** /**
* <p>
* Returns the natural logarithm of the gamma function &#915;(x). * Returns the natural logarithm of the gamma function &#915;(x).
* </p>
* *
* <p>
* The implementation of this method is based on: * The implementation of this method is based on:
* <ul> * <ul>
* <li><a href="http://mathworld.wolfram.com/GammaFunction.html"> * <li><a href="http://mathworld.wolfram.com/GammaFunction.html">
@ -188,7 +179,6 @@ public class Gamma {
* the computation of the convergent Lanczos complex Gamma approximation * the computation of the convergent Lanczos complex Gamma approximation
* </a></li> * </a></li>
* </ul> * </ul>
* </p>
* *
* @param x ??? * @param x ???
* @return log(&#915;(x)) * @return log(&#915;(x))