You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2011/01/03 05:59:19 UTC
svn commit: r1054524 - in /commons/proper/math/branches/MATH_2_X/src:
main/java/org/apache/commons/math/distribution/
test/java/org/apache/commons/math/distribution/
Author: psteitz
Date: Mon Jan 3 04:59:18 2011
New Revision: 1054524
URL: http://svn.apache.org/viewvc?rev=1054524&view=rev
Log:
Restored backward compatibility in distributions classes.
Modified:
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/Distribution.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/BetaDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/BinomialDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ChiSquareDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/FDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/GammaDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/HypergeometricDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/TDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java
commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ZipfDistributionTest.java
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java Mon Jan 3 04:59:18 2011
@@ -228,17 +228,4 @@ public abstract class AbstractContinuous
return solverAbsoluteAccuracy;
}
- /**
- * Access the lower bound of the support.
- *
- * @return lower bound of the support (might be Double.NEGATIVE_INFINITY)
- */
- public abstract double getSupportLowerBound();
-
- /**
- * Access the upper bound of the support.
- *
- * @return upper bound of the support (might be Double.POSITIVE_INFINITY)
- */
- public abstract double getSupportUpperBound();
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java Mon Jan 3 04:59:18 2011
@@ -33,18 +33,6 @@ public abstract class AbstractDistributi
/** Serializable version identifier */
private static final long serialVersionUID = -38038050983108802L;
- /** Cached numerical mean */
- private double numericalMean = Double.NaN;
-
- /** Whether or not the numerical mean has been calculated */
- private boolean numericalMeanIsCalculated = false;
-
- /** Cached numerical variance */
- private double numericalVariance = Double.NaN;
-
- /** Whether or not the numerical variance has been calculated */
- private boolean numericalVarianceIsCalculated = false;
-
/**
* Default constructor.
*/
@@ -78,106 +66,4 @@ public abstract class AbstractDistributi
}
return cumulativeProbability(x1) - cumulativeProbability(x0);
}
-
- /**
- * This method invalidates cached moments when parameters change.
- * Usually it is called from a sub-class when the distribution
- * gets its parameters updated.
- *
- * @deprecated as of 2.2 (sub-classes will become immutable in 3.0)
- */
- @Deprecated
- protected void invalidateParameterDependentMoments() {
- numericalMeanIsCalculated = false;
- numericalVarianceIsCalculated = false;
- }
-
- /**
- * Use this method to actually calculate the mean for the
- * specific distribution. Use {@link #getNumericalMean()}
- * (which implements caching) to actually get the mean.
- *
- * @return the mean or Double.NaN if it's not defined
- */
- protected abstract double calculateNumericalMean();
-
- /**
- * Use this method to get the numerical value of the mean of this
- * distribution.
- *
- * @return the mean or Double.NaN if it's not defined
- */
- public double getNumericalMean() {
- if (!numericalMeanIsCalculated) {
- numericalMean = calculateNumericalMean();
- numericalMeanIsCalculated = true;
- }
-
- return numericalMean;
- }
-
- /**
- * Use this method to actually calculate the variance for the
- * specific distribution. Use {@link #getNumericalVariance()}
- * (which implements caching) to actually get the variance.
- *
- * @return the variance or Double.NaN if it's not defined
- */
- protected abstract double calculateNumericalVariance();
-
- /**
- * Use this method to get the numerical value of the variance of this
- * distribution.
- *
- * @return the variance (possibly Double.POSITIVE_INFINITY as
- * for certain cases in {@link TDistributionImpl}) or
- * Double.NaN if it's not defined
- */
- public double getNumericalVariance() {
- if (!numericalVarianceIsCalculated) {
- numericalVariance = calculateNumericalVariance();
- numericalVarianceIsCalculated = true;
- }
-
- return numericalVariance;
- }
-
- /**
- * Use this method to get information about whether the lower bound
- * of the support is inclusive or not.
- *
- * @return whether the lower bound of the support is inclusive or not
- */
- public abstract boolean isSupportLowerBoundInclusive();
-
- /**
- * Use this method to get information about whether the upper bound
- * of the support is inclusive or not.
- *
- * @return whether the upper bound of the support is inclusive or not
- */
- public abstract boolean isSupportUpperBoundInclusive();
-
- /**
- * Use this method to get information about whether the support is connected,
- * i.e. whether all values between the lower and upper bound of the support
- * is included in the support.
- *
- * For {@link AbstractIntegerDistribution} the support is discrete, so
- * if this is true, then the support is
- * {lower bound, lower bound + 1, ..., upper bound}.
- *
- * For {@link AbstractContinuousDistribution} the support is continuous, so
- * if this is true, then the support is the interval
- * [lower bound, upper bound]
- * where the limits are inclusive or not according to
- * {@link #isSupportLowerBoundInclusive()} and {@link #isSupportUpperBoundInclusive()}
- * (in the example both are true). If both are false, then the support is the interval
- * (lower bound, upper bound)
- *
- * @return whether the support limits given by subclassed methods are connected or not
- */
- public boolean isSupportConnected() {
- return true;
- }
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java Mon Jan 3 04:59:18 2011
@@ -294,27 +294,12 @@ public abstract class AbstractIntegerDis
protected abstract int getDomainUpperBound(double p);
/**
- * Access the lower bound of the support.
- *
- * @return lower bound of the support (Integer.MIN_VALUE for negative infinity)
- */
- public abstract int getSupportLowerBound();
-
- /**
- * Access the upper bound of the support.
- *
- * @return upper bound of the support (Integer.MAX_VALUE for positive infinity)
- */
- public abstract int getSupportUpperBound();
-
- /**
* Use this method to get information about whether the lower bound
* of the support is inclusive or not. For discrete support,
* only true here is meaningful.
*
* @return true (always but at Integer.MIN_VALUE because of the nature of discrete support)
*/
- @Override
public boolean isSupportLowerBoundInclusive() {
return true;
}
@@ -326,7 +311,6 @@ public abstract class AbstractIntegerDis
*
* @return true (always but at Integer.MAX_VALUE because of the nature of discrete support)
*/
- @Override
public boolean isSupportUpperBoundInclusive() {
return true;
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -39,7 +39,7 @@ public class BetaDistributionImpl
extends AbstractContinuousDistribution implements BetaDistribution {
/**
- * Default inverse cumulative probability accurac
+ * Default inverse cumulative probability accuracy
* @since 2.1
*/
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
@@ -92,7 +92,6 @@ public class BetaDistributionImpl
public void setAlpha(double alpha) {
this.alpha = alpha;
z = Double.NaN;
- invalidateParameterDependentMoments();
}
/** {@inheritDoc} */
@@ -107,7 +106,6 @@ public class BetaDistributionImpl
public void setBeta(double beta) {
this.beta = beta;
z = Double.NaN;
- invalidateParameterDependentMoments();
}
/** {@inheritDoc} */
@@ -227,75 +225,60 @@ public class BetaDistributionImpl
}
/**
- * {@inheritDoc}
- *
- * The lower bound of the support is always 0 no matter the parameters.
+ * Returns the lower bound of the support for this distribution.
+ * The support of the Beta distribution is always [0, 1], regardless
+ * of the parameters, so this method always returns 0.
*
* @return lower bound of the support (always 0)
+ * @since 2.2
*/
- @Override
public double getSupportLowerBound() {
return 0;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for this distribution.
+ * The support of the Beta distribution is always [0, 1], regardless
+ * of the parameters, so this method always returns 1.
*
- * The upper bound of the support is always 1 no matter the parameters.
- *
- * @return upper bound of the support (always 1)
+ * @return lower bound of the support (always 1)
+ * @since 2.2
*/
- @Override
public double getSupportUpperBound() {
return 1;
}
/**
- * {@inheritDoc}
+ * Returns the mean.
*
* For first shape parameter <code>s1</code> and
* second shape parameter <code>s2</code>, the mean is
* <code>s1 / (s1 + s2)</code>
*
- * @return {@inheritDoc}
+ * @return the mean
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalMean() {
+ public double getNumericalMean() {
final double a = getAlpha();
return a / (a + getBeta());
}
/**
- * {@inheritDoc}
+ * Returns the variance.
*
* For first shape parameter <code>s1</code> and
* second shape parameter <code>s2</code>,
* the variance is
* <code>[ s1 * s2 ] / [ (s1 + s2)^2 * (s1 + s2 + 1) ]</code>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
final double a = getAlpha();
final double b = getBeta();
final double alphabetasum = a + b;
return (a * b) / ((alphabetasum * alphabetasum) * (alphabetasum + 1));
}
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportLowerBoundInclusive() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportUpperBoundInclusive() {
- return false;
- }
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -83,7 +83,6 @@ public class BinomialDistributionImpl ex
@Deprecated
public void setNumberOfTrials(int trials) {
setNumberOfTrialsInternal(trials);
- invalidateParameterDependentMoments();
}
/**
@@ -112,7 +111,6 @@ public class BinomialDistributionImpl ex
@Deprecated
public void setProbabilityOfSuccess(double p) {
setProbabilityOfSuccessInternal(p);
- invalidateParameterDependentMoments();
}
/**
@@ -226,55 +224,55 @@ public class BinomialDistributionImpl ex
}
/**
- * {@inheritDoc}
+ * Returns the lower bound of the support for the distribution.
*
* The lower bound of the support is always 0 no matter the number of trials
* and probability parameter.
*
* @return lower bound of the support (always 0)
+ * @since 2.2
*/
- @Override
public int getSupportLowerBound() {
return 0;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for the distribution.
*
* The upper bound of the support is the number of trials.
*
* @return upper bound of the support (equal to number of trials)
+ * @since 2.2
*/
- @Override
public int getSupportUpperBound() {
return getNumberOfTrials();
}
/**
- * {@inheritDoc}
+ * Returns the mean.
*
* For <code>n</code> number of trials and
* probability parameter <code>p</code>, the mean is
* <code>n * p</code>
*
- * @return {@inheritDoc}
+ * @return the mean
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalMean() {
+ public double getNumericalMean() {
return (double)getNumberOfTrials() * getProbabilityOfSuccess();
}
/**
- * {@inheritDoc}
+ * Returns the variance.
*
* For <code>n</code> number of trials and
* probability parameter <code>p</code>, the variance is
* <code>n * p * (1 - p)</code>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
final double p = getProbabilityOfSuccess();
return (double)getNumberOfTrials() * p * (1 - p);
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -86,7 +86,7 @@ public class CauchyDistributionImpl exte
/**
* For this distribution, X, this method returns P(X < <code>x</code>).
* @param x the value at which the CDF is evaluated.
- * @return CDF evaluted at <code>x</code>.
+ * @return CDF evaluated at <code>x</code>.
*/
public double cumulativeProbability(double x) {
return 0.5 + (FastMath.atan((x - median) / scale) / FastMath.PI);
@@ -157,7 +157,6 @@ public class CauchyDistributionImpl exte
@Deprecated
public void setMedian(double median) {
setMedianInternal(median);
- invalidateParameterDependentMoments();
}
/**
@@ -177,7 +176,6 @@ public class CauchyDistributionImpl exte
@Deprecated
public void setScale(double s) {
setScaleInternal(s);
- invalidateParameterDependentMoments();
}
/**
@@ -273,68 +271,50 @@ public class CauchyDistributionImpl exte
}
/**
- * {@inheritDoc}
- *
- * The lower bound of the support is always negative infinity no matter
- * the parameters.
+ * Returns the lower bound of the support for this distribution.
+ * The lower bound of the support of the Cauchy distribution is always
+ * negative infinity, regardless of the parameters.
*
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
+ * @since 2.2
*/
- @Override
public double getSupportLowerBound() {
return Double.NEGATIVE_INFINITY;
}
/**
- * {@inheritDoc}
- *
- * The upper bound of the support is always positive infinity no matter
- * the parameters.
+ * Returns the upper bound of the support for this distribution.
+ * The upper bound of the support of the Cauchy distribution is always
+ * positive infinity, regardless of the parameters.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
+ * @since 2.2
*/
- @Override
public double getSupportUpperBound() {
return Double.POSITIVE_INFINITY;
}
/**
- * {@inheritDoc}
+ * Returns the mean.
*
- * The mean is always undefined no matter the parameters.
+ * The mean is always undefined, regardless of the parameters.
*
* @return mean (always Double.NaN)
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalMean() {
+ public double getNumericalMean() {
return Double.NaN;
}
/**
- * {@inheritDoc}
+ * Returns the variance.
*
- * The variance is always undefined no matter the parameters.
+ * The variance is always undefined, regardless of the parameters.
*
* @return variance (always Double.NaN)
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
return Double.NaN;
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportLowerBoundInclusive() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportUpperBoundInclusive() {
- return false;
- }
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -91,7 +91,6 @@ public class ChiSquaredDistributionImpl
@Deprecated
public void setDegreesOfFreedom(double degreesOfFreedom) {
setDegreesOfFreedomInternal(degreesOfFreedom);
- invalidateParameterDependentMoments();
}
/**
* Modify the degrees of freedom.
@@ -272,70 +271,54 @@ public class ChiSquaredDistributionImpl
}
/**
- * {@inheritDoc}
+ * Returns the lower bound of the support for the distribution.
*
* The lower bound of the support is always 0 no matter the
* degrees of freedom.
*
* @return lower bound of the support (always 0)
+ * @since 2.2
*/
- @Override
public double getSupportLowerBound() {
return 0;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound for the support for the distribution.
*
* The upper bound of the support is always positive infinity no matter the
* degrees of freedom.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
+ * @since 2.2
*/
- @Override
public double getSupportUpperBound() {
return Double.POSITIVE_INFINITY;
}
/**
- * {@inheritDoc}
+ * Returns the mean of the distribution.
*
* For <code>k</code> degrees of freedom, the mean is
* <code>k</code>
*
- * @return {@inheritDoc}
+ * @return the mean
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalMean() {
+ public double getNumericalMean() {
return getDegreesOfFreedom();
}
/**
- * {@inheritDoc}
+ * Returns the variance of the distribution.
*
* For <code>k</code> degrees of freedom, the variance is
* <code>2 * k</code>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
return 2*getDegreesOfFreedom();
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportLowerBoundInclusive() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportUpperBoundInclusive() {
- return false;
- }
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/Distribution.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/Distribution.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/Distribution.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/Distribution.java Mon Jan 3 04:59:18 2011
@@ -53,58 +53,4 @@ public interface Distribution {
*/
double cumulativeProbability(double x0, double x1) throws MathException;
- /**
- * Use this method to get the numerical value of the mean of this
- * distribution.
- *
- * @return the mean or Double.NaN if it's not defined
- */
- double getNumericalMean();
-
- /**
- * Use this method to get the numerical value of the variance of this
- * distribution.
- *
- * @return the variance (possibly Double.POSITIVE_INFINITY as
- * for certain cases in {@link TDistributionImpl}) or
- * Double.NaN if it's not defined
- */
- double getNumericalVariance();
-
- /**
- * Use this method to get information about whether the lower bound
- * of the support is inclusive or not.
- *
- * @return whether the lower bound of the support is inclusive or not
- */
- boolean isSupportLowerBoundInclusive();
-
- /**
- * Use this method to get information about whether the upper bound
- * of the support is inclusive or not.
- *
- * @return whether the upper bound of the support is inclusive or not
- */
- boolean isSupportUpperBoundInclusive();
-
- /**
- * Use this method to get information about whether the support is connected,
- * i.e. whether all values between the lower and upper bound of the support
- * is included in the support.
- *
- * For {@link AbstractIntegerDistribution} the support is discrete, so
- * if this is true, then the support is
- * {lower bound, lower bound + 1, ..., upper bound}.
- *
- * For {@link AbstractContinuousDistribution} the support is continuous, so
- * if this is true, then the support is the interval
- * [lower bound, upper bound]
- * where the limits are inclusive or not according to
- * {@link #isSupportLowerBoundInclusive()} and {@link #isSupportUpperBoundInclusive()}
- * (in the example both are true). If both are false, then the support is the interval
- * (lower bound, upper bound)
- *
- * @return whether the support limits given by subclassed methods are connected or not
- */
- boolean isSupportConnected();
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -76,7 +76,6 @@ public class ExponentialDistributionImpl
@Deprecated
public void setMean(double mean) {
setMeanInternal(mean);
- invalidateParameterDependentMoments();
}
/**
* Modify the mean.
@@ -204,7 +203,6 @@ public class ExponentialDistributionImpl
* @return domain value lower bound, i.e.
* P(X < <i>lower bound</i>) < <code>p</code>
*/
- @Override
protected double getDomainLowerBound(double p) {
return 0;
}
@@ -217,7 +215,6 @@ public class ExponentialDistributionImpl
* @return domain value upper bound, i.e.
* P(X < <i>upper bound</i>) > <code>p</code>
*/
- @Override
protected double getDomainUpperBound(double p) {
// NOTE: exponential is skewed to the left
// NOTE: therefore, P(X < μ) > .5
@@ -266,70 +263,55 @@ public class ExponentialDistributionImpl
}
/**
- * {@inheritDoc}
+ * Returns the lower bound of the support for the distribution.
*
- * The lower bound of the support is always 0 no matter the mean parameter.
+ * The lower bound of the support is always 0, regardless of the mean.
*
* @return lower bound of the support (always 0)
+ * @since 2.2
*/
- @Override
public double getSupportLowerBound() {
return 0;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for the distribution.
*
- * The upper bound of the support is always positive infinity
- * no matter the mean parameter.
+ * The upper bound of the support is always positive infinity,
+ * regardless of the mean.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
+ * @since 2.2
*/
- @Override
public double getSupportUpperBound() {
return Double.POSITIVE_INFINITY;
}
/**
- * {@inheritDoc}
+ * Returns the mean of the distribution.
*
* For mean parameter <code>k</code>, the mean is
* <code>k</code>
*
- * @return {@inheritDoc}
+ * @return the mean
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalMean() {
+ public double getNumericalMean() {
return getMean();
}
/**
- * {@inheritDoc}
+ * Returns the variance of the distribution.
*
* For mean parameter <code>k</code>, the variance is
* <code>k^2</code>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
final double m = getMean();
return m * m;
}
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportLowerBoundInclusive() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportUpperBoundInclusive() {
- return false;
- }
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -209,7 +209,6 @@ public class FDistributionImpl
@Deprecated
public void setNumeratorDegreesOfFreedom(double degreesOfFreedom) {
setNumeratorDegreesOfFreedomInternal(degreesOfFreedom);
- invalidateParameterDependentMoments();
}
/**
@@ -244,7 +243,6 @@ public class FDistributionImpl
@Deprecated
public void setDenominatorDegreesOfFreedom(double degreesOfFreedom) {
setDenominatorDegreesOfFreedomInternal(degreesOfFreedom);
- invalidateParameterDependentMoments();
}
/**
@@ -282,32 +280,32 @@ public class FDistributionImpl
}
/**
- * {@inheritDoc}
+ * Returns the lower bound of the support for the distribution.
*
- * The lower bound of the support is always 0 no matter the parameters.
+ * The lower bound of the support is always 0, regardless of the parameters.
*
* @return lower bound of the support (always 0)
+ * @since 2.2
*/
- @Override
public double getSupportLowerBound() {
return 0;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for the distribution.
*
- * The upper bound of the support is always positive infinity
- * no matter the parameters.
+ * The upper bound of the support is always positive infinity,
+ * regardless of the parameters.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
+ * @since 2.2
*/
- @Override
public double getSupportUpperBound() {
return Double.POSITIVE_INFINITY;
}
/**
- * {@inheritDoc}
+ * Returns the mean of the distribution.
*
* For denominator degrees of freedom parameter <code>b</code>,
* the mean is
@@ -316,10 +314,10 @@ public class FDistributionImpl
* <li>else <code>undefined</code>
* </ul>
*
- * @return {@inheritDoc}
+ * @return the mean
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalMean() {
+ public double getNumericalMean() {
final double denominatorDF = getDenominatorDegreesOfFreedom();
if (denominatorDF > 2) {
@@ -330,7 +328,7 @@ public class FDistributionImpl
}
/**
- * {@inheritDoc}
+ * Returns the variance of the distribution.
*
* For numerator degrees of freedom parameter <code>a</code>
* and denominator degrees of freedom parameter <code>b</code>,
@@ -343,10 +341,10 @@ public class FDistributionImpl
* <li>else <code>undefined</code>
* </ul>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
final double denominatorDF = getDenominatorDegreesOfFreedom();
if (denominatorDF > 4) {
@@ -359,20 +357,4 @@ public class FDistributionImpl
return Double.NaN;
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportLowerBoundInclusive() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportUpperBoundInclusive() {
- return false;
- }
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -137,7 +137,6 @@ public class GammaDistributionImpl exten
@Deprecated
public void setAlpha(double alpha) {
setAlphaInternal(alpha);
- invalidateParameterDependentMoments();
}
/**
@@ -171,7 +170,6 @@ public class GammaDistributionImpl exten
@Deprecated
public void setBeta(double newBeta) {
setBetaInternal(newBeta);
- invalidateParameterDependentMoments();
}
/**
@@ -302,72 +300,56 @@ public class GammaDistributionImpl exten
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for the distribution.
*
- * The lower bound of the support is always 0 no matter the parameters.
+ * The lower bound of the support is always 0, regardless of the parameters.
*
* @return lower bound of the support (always 0)
+ * @since 2.2
*/
- @Override
public double getSupportLowerBound() {
return 0;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for the distribution.
*
- * The upper bound of the support is always positive infinity
- * no matter the parameters.
+ * The upper bound of the support is always positive infinity,
+ * regardless of the parameters.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
+ * @since 2.2
*/
- @Override
public double getSupportUpperBound() {
return Double.POSITIVE_INFINITY;
}
/**
- * {@inheritDoc}
+ * Returns the mean.
*
* For shape parameter <code>alpha</code> and scale
* parameter <code>beta</code>, the mean is
* <code>alpha * beta</code>
*
- * @return {@inheritDoc}
+ * @return the mean
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalMean() {
+ public double getNumericalMean() {
return getAlpha() * getBeta();
}
/**
- * {@inheritDoc}
+ * Returns the variance.
*
* For shape parameter <code>alpha</code> and scale
* parameter <code>beta</code>, the variance is
* <code>alpha * beta^2</code>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
final double b = getBeta();
return getAlpha() * b * b;
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportLowerBoundInclusive() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportUpperBoundInclusive() {
- return false;
- }
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -241,7 +241,6 @@ public class HypergeometricDistributionI
@Deprecated
public void setNumberOfSuccesses(int num) {
setNumberOfSuccessesInternal(num);
- invalidateParameterDependentMoments();
}
/**
@@ -268,7 +267,6 @@ public class HypergeometricDistributionI
@Deprecated
public void setPopulationSize(int size) {
setPopulationSizeInternal(size);
- invalidateParameterDependentMoments();
}
/**
@@ -295,7 +293,6 @@ public class HypergeometricDistributionI
@Deprecated
public void setSampleSize(int size) {
setSampleSizeInternal(size);
- invalidateParameterDependentMoments();
}
/**
* Modify the sample size.
@@ -358,7 +355,7 @@ public class HypergeometricDistributionI
}
/**
- * {@inheritDoc}
+ * Returns the lower bound for the support for the distribution.
*
* For population size <code>N</code>,
* number of successes <code>m</code>, and
@@ -367,15 +364,15 @@ public class HypergeometricDistributionI
* <code>max(0, n + m - N)</code>
*
* @return lower bound of the support
+ * @since 2.2
*/
- @Override
public int getSupportLowerBound() {
return FastMath.max(0,
getSampleSize() + getNumberOfSuccesses() - getPopulationSize());
}
/**
- * {@inheritDoc}
+ * Returns the upper bound for the support of the distribution.
*
* For number of successes <code>m</code> and
* sample size <code>n</code>,
@@ -383,39 +380,39 @@ public class HypergeometricDistributionI
* <code>min(m, n)</code>
*
* @return upper bound of the support
+ * @since 2.2
*/
- @Override
public int getSupportUpperBound() {
return FastMath.min(getNumberOfSuccesses(), getSampleSize());
}
/**
- * {@inheritDoc}
+ * Returns the mean.
*
* For population size <code>N</code>,
* number of successes <code>m</code>, and
* sample size <code>n</code>, the mean is
* <code>n * m / N</code>
*
- * @return {@inheritDoc}
+ * @return the mean
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalMean() {
+ protected double getNumericalMean() {
return (double)(getSampleSize() * getNumberOfSuccesses()) / (double)getPopulationSize();
}
/**
- * {@inheritDoc}
+ * Returns the variance.
*
* For population size <code>N</code>,
* number of successes <code>m</code>, and
* sample size <code>n</code>, the variance is
* <code>[ n * m * (N - n) * (N - m) ] / [ N^2 * (N - 1) ]</code>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
final double N = getPopulationSize();
final double m = getNumberOfSuccesses();
final double n = getSampleSize();
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -104,7 +104,6 @@ public class NormalDistributionImpl exte
@Deprecated
public void setMean(double mean) {
setMeanInternal(mean);
- invalidateParameterDependentMoments();
}
/**
@@ -132,7 +131,6 @@ public class NormalDistributionImpl exte
@Deprecated
public void setStandardDeviation(double sd) {
setStandardDeviationInternal(sd);
- invalidateParameterDependentMoments();
}
/**
@@ -310,70 +308,42 @@ public class NormalDistributionImpl exte
}
/**
- * {@inheritDoc}
+ * Returns the lower bound of the support for the distribution.
*
* The lower bound of the support is always negative infinity
* no matter the parameters.
*
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
+ * @since 2.2
*/
- @Override
public double getSupportLowerBound() {
return Double.NEGATIVE_INFINITY;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for the distribution.
*
* The upper bound of the support is always positive infinity
* no matter the parameters.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
+ * @since 2.2
*/
- @Override
public double getSupportUpperBound() {
return Double.POSITIVE_INFINITY;
}
/**
- * {@inheritDoc}
- *
- * For mean parameter <code>mu</code>, the mean is <code>mu</code>
- *
- * @return {@inheritDoc}
- */
- @Override
- protected double calculateNumericalMean() {
- return getMean();
- }
-
- /**
- * {@inheritDoc}
+ * Returns the variance.
*
* For standard deviation parameter <code>s</code>,
* the variance is <code>s^2</code>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
final double s = getStandardDeviation();
return s * s;
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportLowerBoundInclusive() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportUpperBoundInclusive() {
- return false;
- }
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -80,7 +80,6 @@ public class PascalDistributionImpl exte
@Deprecated
public void setNumberOfSuccesses(int successes) {
setNumberOfSuccessesInternal(successes);
- invalidateParameterDependentMoments();
}
/**
@@ -108,7 +107,6 @@ public class PascalDistributionImpl exte
@Deprecated
public void setProbabilityOfSuccess(double p) {
setProbabilityOfSuccessInternal(p);
- invalidateParameterDependentMoments();
}
/**
@@ -217,70 +215,62 @@ public class PascalDistributionImpl exte
}
/**
- * {@inheritDoc}
+ * Returns the lower bound of the support for the distribution.
*
* The lower bound of the support is always 0 no matter the parameters.
*
* @return lower bound of the support (always 0)
+ * @since 2.2
*/
- @Override
public int getSupportLowerBound() {
return 0;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for the distribution.
*
* The upper bound of the support is always positive infinity
- * no matter the parameters. Positive infinity is symbolised
+ * no matter the parameters. Positive infinity is represented
* by <code>Integer.MAX_VALUE</code> together with
* {@link #isSupportUpperBoundInclusive()} being <code>false</code>
*
* @return upper bound of the support (always <code>Integer.MAX_VALUE</code> for positive infinity)
+ * @since 2.2
*/
- @Override
public int getSupportUpperBound() {
return Integer.MAX_VALUE;
}
/**
- * {@inheritDoc}
+ * Returns the mean.
*
* For number of successes <code>r</code> and
* probability of success <code>p</code>, the mean is
* <code>( r * p ) / ( 1 - p )</code>
*
- * @return {@inheritDoc}
+ * @return the mean
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalMean() {
+ public double getNumericalMean() {
final double p = getProbabilityOfSuccess();
final double r = getNumberOfSuccesses();
return ( r * p ) / ( 1 - p );
}
/**
- * {@inheritDoc}
+ * Returns the variance.
*
* For number of successes <code>r</code> and
* probability of success <code>p</code>, the mean is
* <code>( r * p ) / ( 1 - p )^2</code>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
final double p = getProbabilityOfSuccess();
final double r = getNumberOfSuccesses();
final double pInv = 1 - p;
return ( r * p ) / (pInv * pInv);
}
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportUpperBoundInclusive() {
- return false;
- }
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -157,7 +157,6 @@ public class PoissonDistributionImpl ext
@Deprecated
public void setMean(double p) {
setNormalAndMeanInternal(normal, p);
- invalidateParameterDependentMoments();
}
/**
* Set the Poisson mean for the distribution. The mean value must be
@@ -303,19 +302,19 @@ public class PoissonDistributionImpl ext
}
/**
- * {@inheritDoc}
+ * Returns the lower bound of the support for the distribution.
*
* The lower bound of the support is always 0 no matter the mean parameter.
*
* @return lower bound of the support (always 0)
+ * @since 2.2
*/
- @Override
public int getSupportLowerBound() {
return 0;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for the distribution.
*
* The upper bound of the support is positive infinity,
* regardless of the parameter values. There is no integer infinity,
@@ -323,41 +322,22 @@ public class PoissonDistributionImpl ext
* {@link #isSupportUpperBoundInclusive()} returns <code>true</code>.
*
* @return upper bound of the support (always <code>Integer.MAX_VALUE</code> for positive infinity)
+ * @since 2.2
*/
- @Override
public int getSupportUpperBound() {
return Integer.MAX_VALUE;
}
/**
- * {@inheritDoc}
- *
- * For mean parameter <code>p</code>, the mean is <code>p</code>
- *
- * @return {@inheritDoc}
- */
- @Override
- protected double calculateNumericalMean() {
- return getMean();
- }
-
- /**
- * {@inheritDoc}
+ * Returns the variance of the distribution.
*
* For mean parameter <code>p</code>, the variance is <code>p</code>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
return getMean();
}
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportUpperBoundInclusive() {
- return true;
- }
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -81,7 +81,6 @@ public class TDistributionImpl
@Deprecated
public void setDegreesOfFreedom(double degreesOfFreedom) {
setDegreesOfFreedomInternal(degreesOfFreedom);
- invalidateParameterDependentMoments();
}
/**
@@ -227,33 +226,33 @@ public class TDistributionImpl
}
/**
- * {@inheritDoc}
+ * Returns the lower bound of the support for the distribution.
*
* The lower bound of the support is always negative infinity
* no matter the parameters.
*
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
+ * @since 2.2
*/
- @Override
public double getSupportLowerBound() {
return Double.NEGATIVE_INFINITY;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for the distribution.
*
* The upper bound of the support is always positive infinity
* no matter the parameters.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
+ * @since 2.2
*/
- @Override
public double getSupportUpperBound() {
return Double.POSITIVE_INFINITY;
}
/**
- * {@inheritDoc}
+ * Returns the mean.
*
* For degrees of freedom parameter df, the mean is
* <ul>
@@ -261,10 +260,10 @@ public class TDistributionImpl
* <li>else <code>undefined</code></li>
* </ul>
*
- * @return {@inheritDoc}
+ * @return the mean
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalMean() {
+ public double getNumericalMean() {
final double df = getDegreesOfFreedom();
if (df > 1) {
@@ -275,7 +274,7 @@ public class TDistributionImpl
}
/**
- * {@inheritDoc}
+ * Returns the variance.
*
* For degrees of freedom parameter df, the variance is
* <ul>
@@ -284,10 +283,10 @@ public class TDistributionImpl
* <li>else <code>undefined</code></li>
* </ul>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ public double getNumericalVariance() {
final double df = getDegreesOfFreedom();
if (df > 2) {
@@ -301,19 +300,4 @@ public class TDistributionImpl
return Double.NaN;
}
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportLowerBoundInclusive() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean isSupportUpperBoundInclusive() {
- return false;
- }
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/WeibullDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -52,6 +52,18 @@ public class WeibullDistributionImpl ext
/** Inverse cumulative probability accuracy */
private final double solverAbsoluteAccuracy;
+ /** Cached numerical mean */
+ private double numericalMean = Double.NaN;
+
+ /** Whether or not the numerical mean has been calculated */
+ private boolean numericalMeanIsCalculated = false;
+
+ /** Cached numerical variance */
+ private double numericalVariance = Double.NaN;
+
+ /** Whether or not the numerical variance has been calculated */
+ private boolean numericalVarianceIsCalculated = false;
+
/**
* Creates weibull distribution with the given shape and scale and a
* location equal to zero.
@@ -81,7 +93,7 @@ public class WeibullDistributionImpl ext
/**
* For this distribution, X, this method returns P(X < <code>x</code>).
* @param x the value at which the CDF is evaluated.
- * @return CDF evaluted at <code>x</code>.
+ * @return CDF evaluated at <code>x</code>.
*/
public double cumulativeProbability(double x) {
double ret;
@@ -264,39 +276,39 @@ public class WeibullDistributionImpl ext
}
/**
- * {@inheritDoc}
+ * Returns the lower bound of the support for the distribution.
*
* The lower bound of the support is always 0 no matter the parameters.
*
* @return lower bound of the support (always 0)
+ * @since 2.2
*/
- @Override
public double getSupportLowerBound() {
return 0;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for the distribution.
*
* The upper bound of the support is always positive infinity
* no matter the parameters.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
+ * @since 2.2
*/
- @Override
public double getSupportUpperBound() {
return Double.POSITIVE_INFINITY;
}
/**
- * {@inheritDoc}
+ * Calculates the mean.
*
* The mean is <code>scale * Gamma(1 + (1 / shape))</code>
* where <code>Gamma(...)</code> is the Gamma-function
*
- * @return {@inheritDoc}
+ * @return the mean
+ * @since 2.2
*/
- @Override
protected double calculateNumericalMean() {
final double sh = getShape();
final double sc = getScale();
@@ -305,16 +317,16 @@ public class WeibullDistributionImpl ext
}
/**
- * {@inheritDoc}
+ * Calculates the variance.
*
* The variance is
* <code>scale^2 * Gamma(1 + (2 / shape)) - mean^2</code>
* where <code>Gamma(...)</code> is the Gamma-function
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ private double calculateNumericalVariance() {
final double sh = getShape();
final double sc = getScale();
final double mn = getNumericalMean();
@@ -325,18 +337,42 @@ public class WeibullDistributionImpl ext
}
/**
- * {@inheritDoc}
+ * Returns the mean of the distribution.
+ *
+ * @return the mean or Double.NaN if it's not defined
+ * @since 2.2
*/
- @Override
- public boolean isSupportLowerBoundInclusive() {
- return true;
+ public double getNumericalMean() {
+ if (!numericalMeanIsCalculated) {
+ numericalMean = calculateNumericalMean();
+ numericalMeanIsCalculated = true;
+ }
+
+ return numericalMean;
}
/**
- * {@inheritDoc}
+ * Returns the variance of the distribution.
+ *
+ * @return the variance (possibly Double.POSITIVE_INFINITY as
+ * for certain cases in {@link TDistributionImpl}) or
+ * Double.NaN if it's not defined
+ * @since 2.2
*/
- @Override
- public boolean isSupportUpperBoundInclusive() {
- return false;
+ public double getNumericalVariance() {
+ if (!numericalVarianceIsCalculated) {
+ numericalVariance = calculateNumericalVariance();
+ numericalVarianceIsCalculated = true;
+ }
+
+ return numericalVariance;
+ }
+
+ /**
+ * Invalidates the cached mean and variance.
+ */
+ private void invalidateParameterDependentMoments() {
+ numericalMeanIsCalculated = false;
+ numericalVarianceIsCalculated = false;
}
}
Modified: commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java Mon Jan 3 04:59:18 2011
@@ -76,7 +76,6 @@ public class ZipfDistributionImpl extend
@Deprecated
public void setNumberOfElements(final int n) {
setNumberOfElementsInternal(n);
- invalidateParameterDependentMoments();
}
/**
* Set the number of elements (e.g. corpus size) for the distribution.
@@ -116,7 +115,6 @@ public class ZipfDistributionImpl extend
@Deprecated
public void setExponent(final double s) {
setExponentInternal(s);
- invalidateParameterDependentMoments();
}
/**
@@ -215,31 +213,31 @@ public class ZipfDistributionImpl extend
}
/**
- * {@inheritDoc}
+ * Returns the lower bound of the support for the distribution.
*
* The lower bound of the support is always 1 no matter the parameters.
*
* @return lower bound of the support (always 1)
+ * @since 2.2
*/
- @Override
public int getSupportLowerBound() {
return 1;
}
/**
- * {@inheritDoc}
+ * Returns the upper bound of the support for the distribution.
*
* The upper bound of the support is the number of elements
*
* @return upper bound of the support
+ * @since 2.2
*/
- @Override
public int getSupportUpperBound() {
return getNumberOfElements();
}
/**
- * {@inheritDoc}
+ * Returns the mean.
*
* For number of elements N and exponent s, the mean is
* <code>Hs1 / Hs</code> where
@@ -248,10 +246,10 @@ public class ZipfDistributionImpl extend
* <li><code>Hs = generalizedHarmonic(N, s)</code></li>
* </ul>
*
- * @return {@inheritDoc}
+ * @return the mean
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalMean() {
+ protected double getNumericalMean() {
final int N = getNumberOfElements();
final double s = getExponent();
@@ -262,7 +260,7 @@ public class ZipfDistributionImpl extend
}
/**
- * {@inheritDoc}
+ * Returns the variance.
*
* For number of elements N and exponent s, the mean is
* <code>(Hs2 / Hs) - (Hs1^2 / Hs^2)</code> where
@@ -272,10 +270,10 @@ public class ZipfDistributionImpl extend
* <li><code>Hs = generalizedHarmonic(N, s)</code></li>
* </ul>
*
- * @return {@inheritDoc}
+ * @return the variance
+ * @since 2.2
*/
- @Override
- protected double calculateNumericalVariance() {
+ protected double getNumericalVariance() {
final int N = getNumberOfElements();
final double s = getExponent();
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/BetaDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/BetaDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/BetaDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/BetaDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -290,7 +290,7 @@ public class BetaDistributionTest extend
public void testMomonts() {
final double tol = 1e-9;
- BetaDistribution dist;
+ BetaDistributionImpl dist;
dist = new BetaDistributionImpl(1, 1);
assertEquals(dist.getNumericalMean(), 0.5, tol);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/BinomialDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/BinomialDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/BinomialDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/BinomialDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -115,7 +115,7 @@ public class BinomialDistributionTest ex
public void testMomonts() {
final double tol = 1e-9;
- BinomialDistribution dist;
+ BinomialDistributionImpl dist;
dist = new BinomialDistributionImpl(10, 0.5);
assertEquals(dist.getNumericalMean(), 10d * 0.5d, tol);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/CauchyDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -115,7 +115,7 @@ public class CauchyDistributionTest exte
}
public void testMomonts() {
- CauchyDistribution dist;
+ CauchyDistributionImpl dist;
dist = new CauchyDistributionImpl(10.2, 0.15);
assertTrue(Double.isNaN(dist.getNumericalMean()));
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ChiSquareDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ChiSquareDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ChiSquareDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ChiSquareDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -134,7 +134,7 @@ public class ChiSquareDistributionTest e
public void testMomonts() {
final double tol = 1e-9;
- ChiSquaredDistribution dist;
+ ChiSquaredDistributionImpl dist;
dist = new ChiSquaredDistributionImpl(1500);
assertEquals(dist.getNumericalMean(), 1500, tol);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ExponentialDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -124,7 +124,7 @@ public class ExponentialDistributionTest
public void testMomonts() {
final double tol = 1e-9;
- ExponentialDistribution dist;
+ ExponentialDistributionImpl dist;
dist = new ExponentialDistributionImpl(11d);
assertEquals(dist.getNumericalMean(), 11d, tol);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/FDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/FDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/FDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/FDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -131,7 +131,7 @@ public class FDistributionTest extends C
public void testMomonts() {
final double tol = 1e-9;
- FDistribution dist;
+ FDistributionImpl dist;
dist = new FDistributionImpl(1, 2);
assertTrue(Double.isNaN(dist.getNumericalMean()));
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/GammaDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/GammaDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/GammaDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/GammaDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -155,7 +155,7 @@ public class GammaDistributionTest exten
public void testMomonts() {
final double tol = 1e-9;
- GammaDistribution dist;
+ GammaDistributionImpl dist;
dist = new GammaDistributionImpl(1, 2);
assertEquals(dist.getNumericalMean(), 2, tol);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/HypergeometricDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/HypergeometricDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/HypergeometricDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/HypergeometricDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -214,7 +214,7 @@ public class HypergeometricDistributionT
public void testMomonts() {
final double tol = 1e-9;
- HypergeometricDistribution dist;
+ HypergeometricDistributionImpl dist;
dist = new HypergeometricDistributionImpl(1500, 40, 100);
assertEquals(dist.getNumericalMean(), 40d * 100d / 1500d, tol);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/NormalDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -206,20 +206,17 @@ public class NormalDistributionTest exte
public void testMomonts() {
final double tol = 1e-9;
- NormalDistribution dist;
+ NormalDistributionImpl dist;
dist = new NormalDistributionImpl(0, 1);
- assertEquals(dist.getNumericalMean(), 0, tol);
assertEquals(dist.getNumericalVariance(), 1, tol);
dist.setMean(2.2);
dist.setStandardDeviation(1.4);
- assertEquals(dist.getNumericalMean(), 2.2, tol);
assertEquals(dist.getNumericalVariance(), 1.4 * 1.4, tol);
dist.setMean(-2000.9);
dist.setStandardDeviation(10.4);
- assertEquals(dist.getNumericalMean(), -2000.9, tol);
assertEquals(dist.getNumericalVariance(), 10.4 * 10.4, tol);
}
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PascalDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -122,7 +122,7 @@ public class PascalDistributionTest exte
public void testMomonts() {
final double tol = 1e-9;
- PascalDistribution dist;
+ PascalDistributionImpl dist;
dist = new PascalDistributionImpl(10, 0.5);
assertEquals(dist.getNumericalMean(), ( 10d * 0.5d ) / 0.5d, tol);
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/PoissonDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -220,14 +220,12 @@ public class PoissonDistributionTest ext
public void testMomonts() {
final double tol = 1e-9;
- PoissonDistribution dist;
+ PoissonDistributionImpl dist;
dist = new PoissonDistributionImpl(1);
- assertEquals(dist.getNumericalMean(), 1, tol);
assertEquals(dist.getNumericalVariance(), 1, tol);
dist.setMean(11.23);
- assertEquals(dist.getNumericalMean(), 11.23, tol);
assertEquals(dist.getNumericalVariance(), 11.23, tol);
}
}
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/TDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/TDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/TDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/TDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -118,7 +118,7 @@ public class TDistributionTest extends C
public void testMomonts() {
final double tol = 1e-9;
- TDistribution dist;
+ TDistributionImpl dist;
dist = new TDistributionImpl(1);
assertTrue(Double.isNaN(dist.getNumericalMean()));
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/WeibullDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -125,7 +125,7 @@ public class WeibullDistributionTest ext
public void testMomonts() {
final double tol = 1e-9;
- WeibullDistribution dist;
+ WeibullDistributionImpl dist;
dist = new WeibullDistributionImpl(2.5, 3.5);
// In R: 3.5*gamma(1+(1/2.5)) (or emperically: mean(rweibull(10000, 2.5, 3.5)))
Modified: commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ZipfDistributionTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ZipfDistributionTest.java?rev=1054524&r1=1054523&r2=1054524&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ZipfDistributionTest.java (original)
+++ commons/proper/math/branches/MATH_2_X/src/test/java/org/apache/commons/math/distribution/ZipfDistributionTest.java Mon Jan 3 04:59:18 2011
@@ -80,7 +80,7 @@ public class ZipfDistributionTest extend
public void testMomonts() {
final double tol = 1e-9;
- ZipfDistribution dist;
+ ZipfDistributionImpl dist;
dist = new ZipfDistributionImpl(2, 0.5);
assertEquals(dist.getNumericalMean(), FastMath.sqrt(2), tol);