Documented some runtime exceptions.
PR: 29013 git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141231 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
da64b62f7e
commit
f4e161390d
|
@ -24,7 +24,7 @@ import org.apache.commons.math.analysis.UnivariateRealSolverUtils;
|
|||
* implementations for some of the methods that do not vary from distribution
|
||||
* to distribution.
|
||||
*
|
||||
* @version $Revision: 1.20 $ $Date: 2004/04/08 20:45:59 $
|
||||
* @version $Revision: 1.21 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public abstract class AbstractContinuousDistribution
|
||||
implements ContinuousDistribution {
|
||||
|
@ -44,7 +44,7 @@ public abstract class AbstractContinuousDistribution
|
|||
* @param x0 the lower bound
|
||||
* @param x1 the upper bound
|
||||
* @return the cumulative probability.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
public double cumulativeProbability(double x0, double x1)
|
||||
|
@ -58,8 +58,10 @@ public abstract class AbstractContinuousDistribution
|
|||
*
|
||||
* @param p the desired probability
|
||||
* @return x, such that P(X < x) = <code>p</code>
|
||||
* @exception MathException if the inverse cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
* @throws MathException if the inverse cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
* @throws IllegalArgumentException if <code>p</code> is not a valid
|
||||
* probability.
|
||||
*/
|
||||
public double inverseCumulativeProbability(final double p)
|
||||
throws MathException {
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.math.MathException;
|
|||
* implementations for some of the methods that do not vary from distribution
|
||||
* to distribution.
|
||||
*
|
||||
* @version $Revision: 1.14 $ $Date: 2004/05/11 02:19:08 $
|
||||
* @version $Revision: 1.15 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public abstract class AbstractDiscreteDistribution
|
||||
implements DiscreteDistribution {
|
||||
|
@ -40,9 +40,9 @@ public abstract class AbstractDiscreteDistribution
|
|||
* @param x0 the inclusive, lower bound
|
||||
* @param x1 the inclusive, upper bound
|
||||
* @return the cumulative probability.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
* @exception IllegalArgumentException if x0 > x1
|
||||
* @throws IllegalArgumentException if x0 > x1
|
||||
*/
|
||||
public double cumulativeProbability(int x0, int x1) throws MathException {
|
||||
if (x0 > x1) {
|
||||
|
@ -58,9 +58,9 @@ public abstract class AbstractDiscreteDistribution
|
|||
*
|
||||
* @param p the desired probability
|
||||
* @return the largest x such that P(X ≤ x) <= p
|
||||
* @exception MathException if the inverse cumulative probability can not be
|
||||
* @throws MathException if the inverse cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
* @exception IllegalArgumentException if p < 0 or p >= 1
|
||||
* @throws IllegalArgumentException if p < 0 or p >= 1
|
||||
*/
|
||||
public int inverseCumulativeProbability(final double p) throws MathException{
|
||||
if (p < 0.0 || p >= 1.0) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math.util.MathUtils;
|
|||
/**
|
||||
* The default implementation of {@link BinomialDistribution}.
|
||||
*
|
||||
* @version $Revision: 1.13 $ $Date: 2004/04/27 04:37:58 $
|
||||
* @version $Revision: 1.14 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public class BinomialDistributionImpl
|
||||
extends AbstractDiscreteDistribution
|
||||
|
@ -67,6 +67,8 @@ public class BinomialDistributionImpl
|
|||
/**
|
||||
* Change the number of trials for this distribution.
|
||||
* @param trials the new number of trials.
|
||||
* @throws IllegalArgumentException if <code>trials</code> is not a valid
|
||||
* number of trials.
|
||||
*/
|
||||
public void setNumberOfTrials(int trials) {
|
||||
if (trials < 0) {
|
||||
|
@ -78,6 +80,8 @@ public class BinomialDistributionImpl
|
|||
/**
|
||||
* Change the probability of success for this distribution.
|
||||
* @param p the new probability of success.
|
||||
* @throws IllegalArgumentException if <code>p</code> is not a valid
|
||||
* probability.
|
||||
*/
|
||||
public void setProbabilityOfSuccess(double p) {
|
||||
if (p < 0.0 || p > 1.0) {
|
||||
|
@ -114,7 +118,7 @@ public class BinomialDistributionImpl
|
|||
* For this disbution, X, this method returns P(X ≤ x).
|
||||
* @param x the value at which the PDF is evaluated.
|
||||
* @return PDF for this distribution.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
public double cumulativeProbability(int x) throws MathException {
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math.MathException;
|
|||
/**
|
||||
* The default implementation of {@link ChiSquaredDistribution}
|
||||
*
|
||||
* @version $Revision: 1.15 $ $Date: 2004/04/08 20:45:59 $
|
||||
* @version $Revision: 1.16 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public class ChiSquaredDistributionImpl
|
||||
extends AbstractContinuousDistribution
|
||||
|
@ -61,7 +61,7 @@ public class ChiSquaredDistributionImpl
|
|||
* For this disbution, X, this method returns P(X < x).
|
||||
* @param x the value at which the CDF is evaluated.
|
||||
* @return CDF for this distribution.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
public double cumulativeProbability(double x) throws MathException {
|
||||
|
|
|
@ -20,14 +20,14 @@ import org.apache.commons.math.MathException;
|
|||
/**
|
||||
* Base interface for various continuous distributions.
|
||||
*
|
||||
* @version $Revision: 1.13 $ $Date: 2004/04/08 20:45:59 $
|
||||
* @version $Revision: 1.14 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public interface ContinuousDistribution {
|
||||
/**
|
||||
* For this disbution, X, this method returns P(X < x).
|
||||
* @param x the value at which the CDF is evaluated.
|
||||
* @return CDF for this distribution.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
double cumulativeProbability(double x) throws MathException;
|
||||
|
@ -37,7 +37,7 @@ public interface ContinuousDistribution {
|
|||
* @param x0 the lower bound
|
||||
* @param x1 the upper bound
|
||||
* @return the cumulative probability.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
double cumulativeProbability(double x0, double x1) throws MathException;
|
||||
|
@ -46,7 +46,7 @@ public interface ContinuousDistribution {
|
|||
* For this disbution, X, this method returns x such that P(X < x) = p.
|
||||
* @param p the cumulative probability.
|
||||
* @return x.
|
||||
* @exception MathException if the inverse cumulative probability can not be
|
||||
* @throws MathException if the inverse cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
double inverseCumulativeProbability(double p) throws MathException;
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.apache.commons.math.MathException;
|
|||
/**
|
||||
* Base interface for various discrete distributions.
|
||||
*
|
||||
* @version $Revision: 1.13 $ $Date: 2004/05/11 02:19:08 $
|
||||
* @version $Revision: 1.14 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public interface DiscreteDistribution {
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ public interface DiscreteDistribution {
|
|||
* 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.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
double cumulativeProbability(int x) throws MathException;
|
||||
|
@ -44,9 +44,9 @@ public interface DiscreteDistribution {
|
|||
* @param x0 the inclusive, lower bound
|
||||
* @param x1 the inclusive, upper bound
|
||||
* @return the cumulative probability.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
* @exception IllegalArgumentException if x0 > x1
|
||||
* @throws IllegalArgumentException if x0 > x1
|
||||
*/
|
||||
double cumulativeProbability(int x0, int x1) throws MathException;
|
||||
|
||||
|
@ -54,7 +54,7 @@ public interface DiscreteDistribution {
|
|||
* For this distribution, X, this method returns the largest x such that P(X ≤ x) <= p.
|
||||
* @param p the cumulative probability.
|
||||
* @return x.
|
||||
* @exception MathException if the inverse cumulative probability can not be
|
||||
* @throws MathException if the inverse cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
int inverseCumulativeProbability(double p) throws MathException;
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.math.MathException;
|
|||
/**
|
||||
* The default implementation of {@link ExponentialDistribution}
|
||||
*
|
||||
* @version $Revision: 1.14 $ $Date: 2004/04/08 20:45:59 $
|
||||
* @version $Revision: 1.15 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public class ExponentialDistributionImpl
|
||||
implements ExponentialDistribution, Serializable {
|
||||
|
@ -42,6 +42,7 @@ public class ExponentialDistributionImpl
|
|||
/**
|
||||
* Modify the mean.
|
||||
* @param mean the new mean.
|
||||
* @throws IllegalArgumentException if <code>mean</code> is not positive.
|
||||
*/
|
||||
public void setMean(double mean) {
|
||||
if (mean <= 0.0) {
|
||||
|
@ -70,7 +71,7 @@ public class ExponentialDistributionImpl
|
|||
*
|
||||
* @param x the value at which the CDF is evaluated.
|
||||
* @return CDF for this distribution.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
public double cumulativeProbability(double x) throws MathException{
|
||||
|
@ -89,7 +90,7 @@ public class ExponentialDistributionImpl
|
|||
*
|
||||
* @param p the desired probability
|
||||
* @return x, such that P(X < x) = <code>p</code>
|
||||
* @exception MathException if the inverse cumulative probability can not be
|
||||
* @throws MathException if the inverse cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
public double inverseCumulativeProbability(double p) throws MathException{
|
||||
|
@ -111,7 +112,7 @@ public class ExponentialDistributionImpl
|
|||
* @param x0 the lower bound
|
||||
* @param x1 the upper bound
|
||||
* @return the cumulative probability.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
public double cumulativeProbability(double x0, double x1) throws MathException{
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math.special.Beta;
|
|||
* Default implementation of
|
||||
* {@link org.apache.commons.math.distribution.FDistribution}.
|
||||
*
|
||||
* @version $Revision: 1.15 $ $Date: 2004/04/08 20:45:59 $
|
||||
* @version $Revision: 1.16 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public class FDistributionImpl
|
||||
extends AbstractContinuousDistribution
|
||||
|
@ -60,7 +60,7 @@ public class FDistributionImpl
|
|||
*
|
||||
* @param x the value at which the CDF is evaluated.
|
||||
* @return CDF for this distribution.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
public double cumulativeProbability(double x) throws MathException {
|
||||
|
@ -120,6 +120,8 @@ public class FDistributionImpl
|
|||
/**
|
||||
* Modify the numerator degrees of freedom.
|
||||
* @param degreesOfFreedom the new numerator degrees of freedom.
|
||||
* @throws IllegalArgumentException if <code>degreesOfFreedom</code> is not
|
||||
* positive.
|
||||
*/
|
||||
public void setNumeratorDegreesOfFreedom(double degreesOfFreedom) {
|
||||
if (degreesOfFreedom <= 0.0) {
|
||||
|
@ -140,6 +142,8 @@ public class FDistributionImpl
|
|||
/**
|
||||
* Modify the denominator degrees of freedom.
|
||||
* @param degreesOfFreedom the new denominator degrees of freedom.
|
||||
* @throws IllegalArgumentException if <code>degreesOfFreedom</code> is not
|
||||
* positive.
|
||||
*/
|
||||
public void setDenominatorDegreesOfFreedom(double degreesOfFreedom) {
|
||||
if (degreesOfFreedom <= 0.0) {
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.math.special.Gamma;
|
|||
/**
|
||||
* The default implementation of {@link GammaDistribution}
|
||||
*
|
||||
* @version $Revision: 1.18 $ $Date: 2004/04/08 20:45:59 $
|
||||
* @version $Revision: 1.19 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public class GammaDistributionImpl extends AbstractContinuousDistribution
|
||||
implements GammaDistribution, Serializable {
|
||||
|
@ -59,7 +59,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
|
|||
*
|
||||
* @param x the value at which the CDF is evaluated.
|
||||
* @return CDF for this distribution.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
public double cumulativeProbability(double x) throws MathException{
|
||||
|
@ -77,6 +77,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
|
|||
/**
|
||||
* Modify the shape parameter, alpha.
|
||||
* @param alpha the new shape parameter.
|
||||
* @throws IllegalArgumentException if <code>alpha</code> is not positive.
|
||||
*/
|
||||
public void setAlpha(double alpha) {
|
||||
if (alpha <= 0.0) {
|
||||
|
@ -96,6 +97,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
|
|||
/**
|
||||
* Modify the scale parameter, beta.
|
||||
* @param beta the new scale parameter.
|
||||
* @throws IllegalArgumentException if <code>beta</code> is not positive.
|
||||
*/
|
||||
public void setBeta(double beta) {
|
||||
if (beta <= 0.0) {
|
||||
|
@ -120,9 +122,9 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
|
|||
* @param p the desired probability for the critical value
|
||||
* @return domain value lower bound, i.e.
|
||||
* P(X < <i>lower bound</i>) < <code>p</code>
|
||||
* TODO: try to improve on this estimate
|
||||
*/
|
||||
protected double getDomainLowerBound(double p) {
|
||||
// TODO: try to improve on this estimate
|
||||
return Double.MIN_VALUE;
|
||||
}
|
||||
|
||||
|
@ -134,9 +136,9 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
|
|||
* @param p the desired probability for the critical value
|
||||
* @return domain value upper bound, i.e.
|
||||
* P(X < <i>upper bound</i>) > <code>p</code>
|
||||
* TODO: try to improve on this estimate
|
||||
*/
|
||||
protected double getDomainUpperBound(double p) {
|
||||
// TODO: try to improve on this estimate
|
||||
// NOTE: gamma is skewed to the left
|
||||
// NOTE: therefore, P(X < μ) > .5
|
||||
|
||||
|
@ -160,9 +162,9 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
|
|||
*
|
||||
* @param p the desired probability for the critical value
|
||||
* @return initial domain value
|
||||
* TODO: try to improve on this estimate
|
||||
*/
|
||||
protected double getInitialDomain(double p) {
|
||||
// TODO: try to improve on this estimate
|
||||
// Gamma is skewed to the left, therefore, P(X < μ) > .5
|
||||
|
||||
double ret;
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math.util.MathUtils;
|
|||
/**
|
||||
* The default implementation of {@link HypergeometricDistribution}.
|
||||
*
|
||||
* @version $Revision: 1.12 $ $Date: 2004/05/11 02:07:58 $
|
||||
* @version $Revision: 1.13 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public class HypergeometricDistributionImpl extends AbstractDiscreteDistribution
|
||||
implements HypergeometricDistribution, Serializable
|
||||
|
@ -66,7 +66,7 @@ public class HypergeometricDistributionImpl extends AbstractDiscreteDistribution
|
|||
* For this disbution, X, this method returns P(X ≤ x).
|
||||
* @param x the value at which the PDF is evaluated.
|
||||
* @return PDF for this distribution.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
public double cumulativeProbability(int x) throws MathException{
|
||||
|
@ -218,6 +218,7 @@ public class HypergeometricDistributionImpl extends AbstractDiscreteDistribution
|
|||
/**
|
||||
* Modify the number of successes.
|
||||
* @param num the new number of successes.
|
||||
* @throws IllegalArgumentException if <code>num</code> is negative.
|
||||
*/
|
||||
public void setNumberOfSuccesses(int num) {
|
||||
if(num < 0){
|
||||
|
@ -230,6 +231,7 @@ public class HypergeometricDistributionImpl extends AbstractDiscreteDistribution
|
|||
/**
|
||||
* Modify the population size.
|
||||
* @param size the new population size.
|
||||
* @throws IllegalArgumentException if <code>size</code> is not positive.
|
||||
*/
|
||||
public void setPopulationSize(int size) {
|
||||
if(size <= 0){
|
||||
|
@ -242,6 +244,7 @@ public class HypergeometricDistributionImpl extends AbstractDiscreteDistribution
|
|||
/**
|
||||
* Modify the sample size.
|
||||
* @param size the new sample size.
|
||||
* @throws IllegalArgumentException if <code>size</code> is negative.
|
||||
*/
|
||||
public void setSampleSize(int size) {
|
||||
if (size < 0) {
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math.special.Erf;
|
|||
* using method {@link #setCdfAlgorithm}. The deafault is the Cody algorithm
|
||||
* {@link org.apache.commons.math.distribution.NormalCDFPreciseAlgorithm}
|
||||
*
|
||||
* @version $Revision: 1.8 $ $Date: 2004/05/05 19:59:11 $
|
||||
* @version $Revision: 1.9 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public class NormalDistributionImpl extends AbstractContinuousDistribution
|
||||
implements NormalDistribution, Serializable {
|
||||
|
@ -82,6 +82,7 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
|
|||
/**
|
||||
* Modify the standard deviation.
|
||||
* @param sd standard deviation for this distribution
|
||||
* @throws IllegalArgumentException if <code>sd</code> is not positive.
|
||||
*/
|
||||
public void setStandardDeviation(double sd) {
|
||||
if (sd <= 0.0) {
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math.special.Beta;
|
|||
* Default implementation of
|
||||
* {@link org.apache.commons.math.distribution.TDistribution}.
|
||||
*
|
||||
* @version $Revision: 1.15 $ $Date: 2004/04/08 20:45:59 $
|
||||
* @version $Revision: 1.16 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public class TDistributionImpl
|
||||
extends AbstractContinuousDistribution
|
||||
|
@ -65,7 +65,7 @@ public class TDistributionImpl
|
|||
* 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>.
|
||||
* @exception MathException if the cumulative probability can not be
|
||||
* @throws MathException if the cumulative probability can not be
|
||||
* computed due to convergence or other numerical errors.
|
||||
*/
|
||||
public double cumulativeProbability(double x) throws MathException{
|
||||
|
|
|
@ -18,7 +18,7 @@ package org.apache.commons.math.linear;
|
|||
|
||||
/**
|
||||
* Interface defining a real-valued matrix with basic algebraic operations
|
||||
* @version $Revision: 1.16 $ $Date: 2004/04/27 04:37:58 $
|
||||
* @version $Revision: 1.17 $ $Date: 2004/05/19 14:16:32 $
|
||||
*/
|
||||
public interface RealMatrix {
|
||||
|
||||
|
@ -34,7 +34,7 @@ public interface RealMatrix {
|
|||
*
|
||||
* @param m matrix to be added
|
||||
* @return this + m
|
||||
* @exception IllegalArgumentException if m is not the same size as this
|
||||
* @throws IllegalArgumentException if m is not the same size as this
|
||||
*/
|
||||
RealMatrix add(RealMatrix m) throws IllegalArgumentException;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public interface RealMatrix {
|
|||
*
|
||||
* @param m matrix to be subtracted
|
||||
* @return this + m
|
||||
* @exception IllegalArgumentException if m is not the same size as this
|
||||
* @throws IllegalArgumentException if m is not the same size as this
|
||||
*/
|
||||
RealMatrix subtract(RealMatrix m) throws IllegalArgumentException;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import java.io.Serializable;
|
|||
* explicitly invoke <code>LUDecompose()</code> to recompute the decomposition
|
||||
* before using any of the methods above.
|
||||
*
|
||||
* @version $Revision: 1.19 $ $Date: 2004/04/27 04:37:58 $
|
||||
* @version $Revision: 1.20 $ $Date: 2004/05/19 14:16:32 $
|
||||
*/
|
||||
public class RealMatrixImpl implements RealMatrix, Serializable {
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
|
|||
*
|
||||
* @param m matrix to be added
|
||||
* @return this + m
|
||||
* @exception IllegalArgumentException if m is not the same size as this
|
||||
* @throws IllegalArgumentException if m is not the same size as this
|
||||
*/
|
||||
public RealMatrix add(RealMatrix m) throws IllegalArgumentException {
|
||||
if (this.getColumnDimension() != m.getColumnDimension() ||
|
||||
|
@ -144,7 +144,7 @@ public class RealMatrixImpl implements RealMatrix, Serializable {
|
|||
*
|
||||
* @param m matrix to be subtracted
|
||||
* @return this + m
|
||||
* @exception IllegalArgumentException if m is not the same size as *this
|
||||
* @throws IllegalArgumentException if m is not the same size as *this
|
||||
*/
|
||||
public RealMatrix subtract(RealMatrix m) throws IllegalArgumentException {
|
||||
if (this.getColumnDimension() != m.getColumnDimension() ||
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.apache.commons.collections.bag.TreeBag;
|
|||
* The values are ordered using the default (natural order), unless a <code>Comparator</code>
|
||||
* is supplied in the constructor.
|
||||
*
|
||||
* @version $Revision: 1.19 $ $Date: 2004/04/24 18:51:01 $
|
||||
* @version $Revision: 1.20 $ $Date: 2004/05/19 14:16:32 $
|
||||
*/
|
||||
public class Frequency implements Serializable {
|
||||
|
||||
|
@ -81,6 +81,7 @@ public class Frequency implements Serializable {
|
|||
/**
|
||||
* Adds 1 to the frequency count for v
|
||||
* @param v the value to add.
|
||||
* @throws IllegalArgumentException if <code>v</code> is not comparable.
|
||||
*/
|
||||
public void addValue(Object v) {
|
||||
try {
|
||||
|
@ -147,7 +148,7 @@ public class Frequency implements Serializable {
|
|||
long result = 0;
|
||||
try {
|
||||
result = freqTable.getCount(v);
|
||||
} catch (Exception ex) {
|
||||
} catch (ClassCastException ex) {
|
||||
// ignore and return 0 -- ClassCastException will be thrown if value is not comparable
|
||||
}
|
||||
return result;
|
||||
|
@ -162,7 +163,7 @@ public class Frequency implements Serializable {
|
|||
long result = 0;
|
||||
try {
|
||||
result = freqTable.getCount(new Long(v));
|
||||
} catch (Exception ex) {
|
||||
} catch (ClassCastException ex) {
|
||||
// ignore and return 0 -- ClassCastException will be thrown if value is not comparable
|
||||
}
|
||||
return result;
|
||||
|
@ -177,7 +178,7 @@ public class Frequency implements Serializable {
|
|||
long result = 0;
|
||||
try {
|
||||
result = freqTable.getCount(new Long(v));
|
||||
} catch (Exception ex) {
|
||||
} catch (ClassCastException ex) {
|
||||
// ignore and return 0 -- ClassCastException will be thrown if value is not comparable
|
||||
}
|
||||
return result;
|
||||
|
@ -192,7 +193,7 @@ public class Frequency implements Serializable {
|
|||
long result = 0;
|
||||
try {
|
||||
result = freqTable.getCount(new Character(v));
|
||||
} catch (Exception ex) {
|
||||
} catch (ClassCastException ex) {
|
||||
// ignore and return 0 -- ClassCastException will be thrown if value is not comparable
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.apache.commons.math.distribution.ChiSquaredDistribution;
|
|||
/**
|
||||
* Implements Chi-Square test statistics defined in the {@link ChiSquareTest} interface.
|
||||
*
|
||||
* @version $Revision: 1.1 $ $Date: 2004/05/03 03:02:25 $
|
||||
* @version $Revision: 1.2 $ $Date: 2004/05/19 14:16:32 $
|
||||
*/
|
||||
public class ChiSquareTestImpl implements ChiSquareTest, Serializable {
|
||||
|
||||
|
@ -194,11 +194,11 @@ public class ChiSquareTestImpl implements ChiSquareTest, Serializable {
|
|||
|
||||
/**
|
||||
* Returns true iff input array is rectangular.
|
||||
* Throws NullPointerException if input array is null
|
||||
* Throws ArrayIndexOutOfBoundsException if input array is empty
|
||||
*
|
||||
* @param in array to be tested
|
||||
* @return true if the array is rectangular
|
||||
* @throws NullPointerException if input array is null
|
||||
* @throws ArrayIndexOutOfBoundsException if input array is empty
|
||||
*/
|
||||
private boolean isRectangular(long[][] in) {
|
||||
for (int i = 1; i < in.length; i++) {
|
||||
|
@ -211,11 +211,11 @@ public class ChiSquareTestImpl implements ChiSquareTest, Serializable {
|
|||
|
||||
/**
|
||||
* Returns true iff all entries of the input array are > 0.
|
||||
* Throws NullPointerException if input array is null.
|
||||
* Returns true if the array is non-null, but empty
|
||||
*
|
||||
* @param in array to be tested
|
||||
* @return true if all entries of the array are positive
|
||||
* @throws NullPointerException if input array is null
|
||||
*/
|
||||
private boolean isPositive(double[] in) {
|
||||
for (int i = 0; i < in.length; i ++) {
|
||||
|
@ -228,11 +228,11 @@ public class ChiSquareTestImpl implements ChiSquareTest, Serializable {
|
|||
|
||||
/**
|
||||
* Returns true iff all entries of the input array are >= 0.
|
||||
* Throws NullPointerException if input array is null.
|
||||
* Returns true if the array is non-null, but empty
|
||||
*
|
||||
* @param in array to be tested
|
||||
* @return true if all entries of the array are non-negative
|
||||
* @throws NullPointerException if input array is null
|
||||
*/
|
||||
private boolean isNonNegative(double[] in) {
|
||||
for (int i = 0; i < in.length; i ++) {
|
||||
|
@ -245,11 +245,11 @@ public class ChiSquareTestImpl implements ChiSquareTest, Serializable {
|
|||
|
||||
/**
|
||||
* Returns true iff all entries of the input array are > 0.
|
||||
* Throws NullPointerException if input array is null.
|
||||
* Returns true if the array is non-null, but empty
|
||||
*
|
||||
* @param in array to be tested
|
||||
* @return true if all entries of the array are positive
|
||||
* @throws NullPointerException if input array is null
|
||||
*/
|
||||
private boolean isPositive(long[] in) {
|
||||
for (int i = 0; i < in.length; i ++) {
|
||||
|
@ -262,11 +262,11 @@ public class ChiSquareTestImpl implements ChiSquareTest, Serializable {
|
|||
|
||||
/**
|
||||
* Returns true iff all entries of the input array are >= 0.
|
||||
* Throws NullPointerException if input array is null.
|
||||
* Returns true if the array is non-null, but empty
|
||||
*
|
||||
* @param in array to be tested
|
||||
* @return true if all entries of the array are non-negative
|
||||
* @throws NullPointerException if input array is null
|
||||
*/
|
||||
private boolean isNonNegative(long[] in) {
|
||||
for (int i = 0; i < in.length; i ++) {
|
||||
|
@ -279,11 +279,11 @@ public class ChiSquareTestImpl implements ChiSquareTest, Serializable {
|
|||
|
||||
/**
|
||||
* Returns true iff all entries of (all subarrays of) the input array are > 0.
|
||||
* Throws NullPointerException if input array is null.
|
||||
* Returns true if the array is non-null, but empty
|
||||
*
|
||||
* @param in array to be tested
|
||||
* @return true if all entries of the array are positive
|
||||
* @throws NullPointerException if input array is null
|
||||
*/
|
||||
private boolean isPositive(long[][] in) {
|
||||
for (int i = 0; i < in.length; i ++) {
|
||||
|
@ -298,11 +298,11 @@ public class ChiSquareTestImpl implements ChiSquareTest, Serializable {
|
|||
|
||||
/**
|
||||
* Returns true iff all entries of (all subarrays of) the input array are >= 0.
|
||||
* Throws NullPointerException if input array is null.
|
||||
* Returns true if the array is non-null, but empty
|
||||
*
|
||||
* @param in array to be tested
|
||||
* @return true if all entries of the array are non-negative
|
||||
* @throws NullPointerException if input array is null
|
||||
*/
|
||||
private boolean isNonNegative(long[][] in) {
|
||||
for (int i = 0; i < in.length; i ++) {
|
||||
|
|
|
@ -49,7 +49,7 @@ import org.apache.commons.math.distribution.TDistribution;
|
|||
* the necessary computations to return the requested statistic.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @version $Revision: 1.2 $ $Date: 2004/04/27 16:42:34 $
|
||||
* @version $Revision: 1.3 $ $Date: 2004/05/19 14:16:32 $
|
||||
*/
|
||||
public class BivariateRegression implements Serializable {
|
||||
|
||||
|
@ -388,7 +388,7 @@ public class BivariateRegression implements Serializable {
|
|||
*
|
||||
* @return half-width of 95% confidence interval for the slope estimate
|
||||
*
|
||||
* @exception MathException if the confidence interval can not be computed.
|
||||
* @throws MathException if the confidence interval can not be computed.
|
||||
*/
|
||||
public double getSlopeConfidenceInterval() throws MathException {
|
||||
return getSlopeConfidenceInterval(0.05d);
|
||||
|
@ -423,7 +423,7 @@ public class BivariateRegression implements Serializable {
|
|||
*
|
||||
* @param alpha the desired significance level
|
||||
* @return half-width of 95% confidence interval for the slope estimate
|
||||
* @exception MathException if the confidence interval can not be computed.
|
||||
* @throws MathException if the confidence interval can not be computed.
|
||||
*/
|
||||
public double getSlopeConfidenceInterval(double alpha)
|
||||
throws MathException {
|
||||
|
@ -453,7 +453,7 @@ public class BivariateRegression implements Serializable {
|
|||
* <code>Double.NaN</code>.
|
||||
*
|
||||
* @return significance level for slope/correlation
|
||||
* @exception MathException if the significance level can not be computed.
|
||||
* @throws MathException if the significance level can not be computed.
|
||||
*/
|
||||
public double getSignificance() throws MathException {
|
||||
return (
|
||||
|
|
|
@ -23,7 +23,7 @@ import org.apache.commons.discovery.tools.DiscoverClass;
|
|||
/**
|
||||
* Abstract factory class for univariate statistical summaries.
|
||||
*
|
||||
* @version $Revision: 1.3 $ $Date: 2004/05/03 14:32:25 $
|
||||
* @version $Revision: 1.4 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public abstract class DescriptiveStatistics implements Serializable, StatisticalSummary {
|
||||
|
||||
|
@ -32,11 +32,11 @@ public abstract class DescriptiveStatistics implements Serializable, Statistical
|
|||
* @param cls the type of <code>DescriptiveStatistics</code> object to
|
||||
* create.
|
||||
* @return a new factory.
|
||||
* @exception InstantiationException is thrown if the object can not be
|
||||
* @throws InstantiationException is thrown if the object can not be
|
||||
* created.
|
||||
* @exception IllegalAccessException is thrown if the type's default
|
||||
* @throws IllegalAccessException is thrown if the type's default
|
||||
* constructor is not accessible.
|
||||
* @exception ClassNotFoundException if the named
|
||||
* @throws ClassNotFoundException if the named
|
||||
* <code>DescriptiveStatistics</code> type can not be found.
|
||||
*/
|
||||
public static DescriptiveStatistics newInstance(String cls) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
|
||||
|
@ -48,9 +48,9 @@ public abstract class DescriptiveStatistics implements Serializable, Statistical
|
|||
* @param cls the type of <code>DescriptiveStatistics</code> object to
|
||||
* create.
|
||||
* @return a new factory.
|
||||
* @exception InstantiationException is thrown if the object can not be
|
||||
* @throws InstantiationException is thrown if the object can not be
|
||||
* created.
|
||||
* @exception IllegalAccessException is thrown if the type's default
|
||||
* @throws IllegalAccessException is thrown if the type's default
|
||||
* constructor is not accessible.
|
||||
*/
|
||||
public static DescriptiveStatistics newInstance(Class cls) throws InstantiationException, IllegalAccessException {
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.commons.discovery.tools.DiscoverClass;
|
|||
/**
|
||||
* Abstract factory class for univariate statistical summaries.
|
||||
*
|
||||
* @version $Revision: 1.4 $ $Date: 2004/05/18 04:19:53 $
|
||||
* @version $Revision: 1.5 $ $Date: 2004/05/19 14:16:31 $
|
||||
*/
|
||||
public abstract class SummaryStatistics implements Serializable, StatisticalSummary {
|
||||
|
||||
|
@ -31,11 +31,11 @@ public abstract class SummaryStatistics implements Serializable, StatisticalSumm
|
|||
* @param cls the type of <code>SummaryStatistics</code> object to
|
||||
* create.
|
||||
* @return a new factory.
|
||||
* @exception InstantiationException is thrown if the object can not be
|
||||
* @throws InstantiationException is thrown if the object can not be
|
||||
* created.
|
||||
* @exception IllegalAccessException is thrown if the type's default
|
||||
* @throws IllegalAccessException is thrown if the type's default
|
||||
* constructor is not accessible.
|
||||
* @exception ClassNotFoundException if the named
|
||||
* @throws ClassNotFoundException if the named
|
||||
* <code>SummaryStatistics</code> type can not be found.
|
||||
*/
|
||||
public static SummaryStatistics newInstance(String cls) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
|
||||
|
@ -47,9 +47,9 @@ public abstract class SummaryStatistics implements Serializable, StatisticalSumm
|
|||
* @param cls the type of <code>SummaryStatistics</code> object to
|
||||
* create.
|
||||
* @return a new factory.
|
||||
* @exception InstantiationException is thrown if the object can not be
|
||||
* @throws InstantiationException is thrown if the object can not be
|
||||
* created.
|
||||
* @exception IllegalAccessException is thrown if the type's default
|
||||
* @throws IllegalAccessException is thrown if the type's default
|
||||
* constructor is not accessible.
|
||||
*/
|
||||
public static SummaryStatistics newInstance(Class cls) throws InstantiationException, IllegalAccessException {
|
||||
|
|
|
@ -28,7 +28,7 @@ import org.apache.commons.math.stat.univariate.AbstractUnivariateStatistic;
|
|||
* follows the first estimation procedure presented
|
||||
* <a href="http://www.itl.nist.gov/div898/handbook/prc/section2/prc252.htm">here.</a>
|
||||
*
|
||||
* @version $Revision: 1.18 $ $Date: 2004/04/27 16:42:33 $
|
||||
* @version $Revision: 1.19 $ $Date: 2004/05/19 14:16:32 $
|
||||
*/
|
||||
public class Percentile extends AbstractUnivariateStatistic implements Serializable {
|
||||
|
||||
|
@ -112,6 +112,8 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa
|
|||
* @param length the number of array elements to include
|
||||
* @return the result of the evaluation or Double.NaN
|
||||
* if the array is empty
|
||||
* @throws IllegalArgumentException if <code>p</code> is not a valid
|
||||
* quantile.
|
||||
*/
|
||||
public double evaluate(
|
||||
final double[] values,
|
||||
|
|
|
@ -50,7 +50,7 @@ import java.io.Serializable;
|
|||
* internal storage array is swapped.
|
||||
* </p>
|
||||
*
|
||||
* @version $Revision: 1.13 $ $Date: 2004/04/27 16:42:34 $
|
||||
* @version $Revision: 1.14 $ $Date: 2004/05/19 14:16:32 $
|
||||
*/
|
||||
public class ContractableDoubleArray extends ExpandableDoubleArray implements Serializable {
|
||||
|
||||
|
@ -248,6 +248,8 @@ public class ContractableDoubleArray extends ExpandableDoubleArray implements Se
|
|||
*
|
||||
* @param expansionFactor factor to be checked
|
||||
* @param contractionCritera critera to be checked
|
||||
* @throws IllegalArgumentException if the contractionCriteria is less than
|
||||
* the expansionCriteria.
|
||||
*/
|
||||
protected void checkContractExpand(
|
||||
float contractionCritera,
|
||||
|
|
|
@ -22,7 +22,7 @@ package org.apache.commons.math.util;
|
|||
* Collections API by allowing a user to select from a number of
|
||||
* array implementations with support for various storage mechanisms
|
||||
* such as automatic expansion, contraction, and array "rolling".
|
||||
* @version $Revision: 1.9 $ $Date: 2004/02/21 21:35:16 $
|
||||
* @version $Revision: 1.10 $ $Date: 2004/05/19 14:16:32 $
|
||||
*/
|
||||
public interface DoubleArray {
|
||||
|
||||
|
@ -40,7 +40,8 @@ public interface DoubleArray {
|
|||
*
|
||||
* @param index index to fetch a value from
|
||||
* @return value stored at the specified index
|
||||
*
|
||||
* @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than
|
||||
* zero or is greater than <code>getNumElements() - 1</code>.
|
||||
*/
|
||||
double getElement(int index);
|
||||
|
||||
|
@ -50,6 +51,8 @@ public interface DoubleArray {
|
|||
* index beyond the current capacity.
|
||||
* @param index index to store a value in
|
||||
* @param value value to store at the specified index
|
||||
* @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than
|
||||
* zero or is greater than <code>getNumElements() - 1</code>.
|
||||
*/
|
||||
void setElement(int index, double value);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ import java.io.Serializable;
|
|||
* expand the array 10 times - first from 2 -> 4. then 4 -> 8, 8 -> 16,
|
||||
* and so on until we reach 4096 which is sufficient to hold 3546 elements.
|
||||
* </p>
|
||||
* @version $Revision: 1.14 $ $Date: 2004/04/27 16:42:34 $
|
||||
* @version $Revision: 1.15 $ $Date: 2004/05/19 14:16:32 $
|
||||
*/
|
||||
public class ExpandableDoubleArray implements Serializable, DoubleArray {
|
||||
|
||||
|
@ -140,6 +140,8 @@ public class ExpandableDoubleArray implements Serializable, DoubleArray {
|
|||
* The expansion factor will affect the next expansion of this array.
|
||||
*
|
||||
* @param expansionFactor the expansion factor of this array
|
||||
* @throws IllegalArgumentException if <code>expansionFactor</code> is less
|
||||
* than or equal to 1.0
|
||||
*/
|
||||
public void setExpansionFactor(float expansionFactor) {
|
||||
|
||||
|
@ -158,6 +160,8 @@ public class ExpandableDoubleArray implements Serializable, DoubleArray {
|
|||
/**
|
||||
* Sets the initial capacity
|
||||
* @param initialCapacity of the array
|
||||
* @throws IllegalArgumentException if <code>initialCapacity</code> is not
|
||||
* positive.
|
||||
*/
|
||||
public void setInitialCapacity(int initialCapacity) {
|
||||
if (initialCapacity > 0) {
|
||||
|
@ -204,6 +208,7 @@ public class ExpandableDoubleArray implements Serializable, DoubleArray {
|
|||
* array as needed.
|
||||
*
|
||||
* @param i a new number of elements
|
||||
* @throws IllegalArgumentException if <code>i</code> is negative.
|
||||
*/
|
||||
public synchronized void setNumElements(int i) {
|
||||
|
||||
|
@ -229,6 +234,8 @@ public class ExpandableDoubleArray implements Serializable, DoubleArray {
|
|||
*
|
||||
* @param index index to fetch a value from
|
||||
* @return value stored at the specified index
|
||||
* @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than
|
||||
* zero or is greater than <code>getNumElements() - 1</code>.
|
||||
*/
|
||||
public double getElement(int index) {
|
||||
double value = Double.NaN;
|
||||
|
@ -254,6 +261,8 @@ public class ExpandableDoubleArray implements Serializable, DoubleArray {
|
|||
*
|
||||
* @param index index to store a value in
|
||||
* @param value value to store at the specified index
|
||||
* @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than
|
||||
* zero.
|
||||
*/
|
||||
public synchronized void setElement(int index, double value) {
|
||||
|
||||
|
@ -362,6 +371,8 @@ public class ExpandableDoubleArray implements Serializable, DoubleArray {
|
|||
* elements from the front of the array.
|
||||
*
|
||||
* @param i number of elements to discard from the front of the array.
|
||||
* @throws IllegalArgumentException if <code>i</code> is negative of is
|
||||
* greater than <code>getNumElements()</code>.
|
||||
*/
|
||||
public synchronized void discardFrontElements(int i) {
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ import java.io.Serializable;
|
|||
* "fixed" in memory, this implementation will never allocate, or copy
|
||||
* the internal storage array to a new array instance.
|
||||
* </p>
|
||||
* @version $Revision: 1.15 $ $Date: 2004/04/27 16:42:34 $
|
||||
* @version $Revision: 1.16 $ $Date: 2004/05/19 14:16:32 $
|
||||
*/
|
||||
public class FixedDoubleArray implements DoubleArray, Serializable {
|
||||
|
||||
|
@ -127,6 +127,8 @@ public class FixedDoubleArray implements DoubleArray, Serializable {
|
|||
* array will throw an ArrayIndexOutOfBoundsException.
|
||||
*
|
||||
* @see org.apache.commons.math.util.DoubleArray#getElement(int)
|
||||
* @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than
|
||||
* zero or is greater than <code>getNumElements() - 1</code>.
|
||||
*/
|
||||
public double getElement(int index) {
|
||||
if (index > (size - 1)) {
|
||||
|
@ -166,6 +168,8 @@ public class FixedDoubleArray implements DoubleArray, Serializable {
|
|||
* </p>
|
||||
*
|
||||
* @see org.apache.commons.math.util.DoubleArray#setElement(int, double)
|
||||
* @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than
|
||||
* zero or is greater than <code>getNumElements() - 1</code>.
|
||||
*/
|
||||
public void setElement(int index, double value) {
|
||||
if (index > (size - 1)) {
|
||||
|
@ -183,6 +187,7 @@ public class FixedDoubleArray implements DoubleArray, Serializable {
|
|||
* of elements
|
||||
*
|
||||
* @see org.apache.commons.math.util.DoubleArray#addElement(double)
|
||||
* @throws ArrayIndexOutOfBoundsException if array is already at capacity.
|
||||
*/
|
||||
public void addElement(double value) {
|
||||
if (size < internalArray.length) {
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.commons.math.util;
|
|||
/**
|
||||
* Some useful additions to the built-in functions in {@link Math}.
|
||||
*
|
||||
* @version $Revision: 1.16 $ $Date: 2004/05/09 04:36:08 $
|
||||
* @version $Revision: 1.17 $ $Date: 2004/05/19 14:16:32 $
|
||||
*/
|
||||
public final class MathUtils {
|
||||
|
||||
|
@ -241,6 +241,9 @@ public final class MathUtils {
|
|||
* @param n the size of the set
|
||||
* @param k the size of the subsets to be counted
|
||||
* @return <code>n choose k</code>
|
||||
* @throws IllegalArgumentException if preconditions are not met.
|
||||
* @throws ArithmeticException if the result is too large to be represented
|
||||
* by a long integer.
|
||||
*/
|
||||
public static long binomialCoefficient(final int n, final int k) {
|
||||
if (n < k) {
|
||||
|
@ -285,6 +288,7 @@ public final class MathUtils {
|
|||
* @param n the size of the set
|
||||
* @param k the size of the subsets to be counted
|
||||
* @return <code>n choose k</code>
|
||||
* @throws IllegalArgumentException if preconditions are not met.
|
||||
*/
|
||||
public static double binomialCoefficientDouble(final int n, final int k) {
|
||||
return Math.floor(Math.exp(binomialCoefficientLog(n, k)) + 0.5);
|
||||
|
@ -305,6 +309,7 @@ public final class MathUtils {
|
|||
* @param n the size of the set
|
||||
* @param k the size of the subsets to be counted
|
||||
* @return <code>n choose k</code>
|
||||
* @throws IllegalArgumentException if preconditions are not met.
|
||||
*/
|
||||
public static double binomialCoefficientLog(final int n, final int k) {
|
||||
if (n < k) {
|
||||
|
@ -355,6 +360,8 @@ public final class MathUtils {
|
|||
*
|
||||
* @param n argument
|
||||
* @return <code>n!</code>
|
||||
* @throws ArithmeticException if the result is too large to be represented
|
||||
* by a long integer.
|
||||
*/
|
||||
public static long factorial(final int n) {
|
||||
long result = Math.round(factorialDouble(n));
|
||||
|
@ -402,6 +409,7 @@ public final class MathUtils {
|
|||
*
|
||||
* @param n argument
|
||||
* @return <code>n!</code>
|
||||
* @throws IllegalArgumentException if preconditions are not met.
|
||||
*/
|
||||
public static double factorialLog(final int n) {
|
||||
if (n <= 0) {
|
||||
|
|
Loading…
Reference in New Issue