Restored backward compatibility in distributions classes.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_X@1054524 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7218e827a4
commit
79c2fc7a52
|
@ -228,17 +228,4 @@ public abstract class AbstractContinuousDistribution
|
||||||
return solverAbsoluteAccuracy;
|
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();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,18 +33,6 @@ public abstract class AbstractDistribution
|
||||||
/** Serializable version identifier */
|
/** Serializable version identifier */
|
||||||
private static final long serialVersionUID = -38038050983108802L;
|
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.
|
* Default constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -78,106 +66,4 @@ public abstract class AbstractDistribution
|
||||||
}
|
}
|
||||||
return cumulativeProbability(x1) - cumulativeProbability(x0);
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,20 +293,6 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
|
||||||
*/
|
*/
|
||||||
protected abstract int getDomainUpperBound(double p);
|
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
|
* Use this method to get information about whether the lower bound
|
||||||
* of the support is inclusive or not. For discrete support,
|
* of the support is inclusive or not. For discrete support,
|
||||||
|
@ -314,7 +300,6 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
|
||||||
*
|
*
|
||||||
* @return true (always but at Integer.MIN_VALUE because of the nature of discrete support)
|
* @return true (always but at Integer.MIN_VALUE because of the nature of discrete support)
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public boolean isSupportLowerBoundInclusive() {
|
public boolean isSupportLowerBoundInclusive() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -326,7 +311,6 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
|
||||||
*
|
*
|
||||||
* @return true (always but at Integer.MAX_VALUE because of the nature of discrete support)
|
* @return true (always but at Integer.MAX_VALUE because of the nature of discrete support)
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
public boolean isSupportUpperBoundInclusive() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class BetaDistributionImpl
|
||||||
extends AbstractContinuousDistribution implements BetaDistribution {
|
extends AbstractContinuousDistribution implements BetaDistribution {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default inverse cumulative probability accurac
|
* Default inverse cumulative probability accuracy
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
|
public static final double DEFAULT_INVERSE_ABSOLUTE_ACCURACY = 1e-9;
|
||||||
|
@ -92,7 +92,6 @@ public class BetaDistributionImpl
|
||||||
public void setAlpha(double alpha) {
|
public void setAlpha(double alpha) {
|
||||||
this.alpha = alpha;
|
this.alpha = alpha;
|
||||||
z = Double.NaN;
|
z = Double.NaN;
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
@ -107,7 +106,6 @@ public class BetaDistributionImpl
|
||||||
public void setBeta(double beta) {
|
public void setBeta(double beta) {
|
||||||
this.beta = beta;
|
this.beta = beta;
|
||||||
z = Double.NaN;
|
z = Double.NaN;
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
|
@ -227,75 +225,60 @@ public class BetaDistributionImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the lower bound of the support for this distribution.
|
||||||
*
|
* The support of the Beta distribution is always [0, 1], regardless
|
||||||
* The lower bound of the support is always 0 no matter the parameters.
|
* of the parameters, so this method always returns 0.
|
||||||
*
|
*
|
||||||
* @return lower bound of the support (always 0)
|
* @return lower bound of the support (always 0)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportLowerBound() {
|
public double getSupportLowerBound() {
|
||||||
return 0;
|
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 lower bound of the support (always 1)
|
||||||
*
|
* @since 2.2
|
||||||
* @return upper bound of the support (always 1)
|
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportUpperBound() {
|
public double getSupportUpperBound() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the mean.
|
||||||
*
|
*
|
||||||
* For first shape parameter <code>s1</code> and
|
* For first shape parameter <code>s1</code> and
|
||||||
* second shape parameter <code>s2</code>, the mean is
|
* second shape parameter <code>s2</code>, the mean is
|
||||||
* <code>s1 / (s1 + s2)</code>
|
* <code>s1 / (s1 + s2)</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the mean
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalMean() {
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
final double a = getAlpha();
|
final double a = getAlpha();
|
||||||
return a / (a + getBeta());
|
return a / (a + getBeta());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the variance.
|
||||||
*
|
*
|
||||||
* For first shape parameter <code>s1</code> and
|
* For first shape parameter <code>s1</code> and
|
||||||
* second shape parameter <code>s2</code>,
|
* second shape parameter <code>s2</code>,
|
||||||
* the variance is
|
* the variance is
|
||||||
* <code>[ s1 * s2 ] / [ (s1 + s2)^2 * (s1 + s2 + 1) ]</code>
|
* <code>[ s1 * s2 ] / [ (s1 + s2)^2 * (s1 + s2 + 1) ]</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
final double a = getAlpha();
|
final double a = getAlpha();
|
||||||
final double b = getBeta();
|
final double b = getBeta();
|
||||||
final double alphabetasum = a + b;
|
final double alphabetasum = a + b;
|
||||||
return (a * b) / ((alphabetasum * alphabetasum) * (alphabetasum + 1));
|
return (a * b) / ((alphabetasum * alphabetasum) * (alphabetasum + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportLowerBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,6 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setNumberOfTrials(int trials) {
|
public void setNumberOfTrials(int trials) {
|
||||||
setNumberOfTrialsInternal(trials);
|
setNumberOfTrialsInternal(trials);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,7 +111,6 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setProbabilityOfSuccess(double p) {
|
public void setProbabilityOfSuccess(double p) {
|
||||||
setProbabilityOfSuccessInternal(p);
|
setProbabilityOfSuccessInternal(p);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -226,55 +224,55 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@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
|
* The lower bound of the support is always 0 no matter the number of trials
|
||||||
* and probability parameter.
|
* and probability parameter.
|
||||||
*
|
*
|
||||||
* @return lower bound of the support (always 0)
|
* @return lower bound of the support (always 0)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public int getSupportLowerBound() {
|
public int getSupportLowerBound() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the upper bound of the support for the distribution.
|
||||||
*
|
*
|
||||||
* The upper bound of the support is the number of trials.
|
* The upper bound of the support is the number of trials.
|
||||||
*
|
*
|
||||||
* @return upper bound of the support (equal to number of trials)
|
* @return upper bound of the support (equal to number of trials)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public int getSupportUpperBound() {
|
public int getSupportUpperBound() {
|
||||||
return getNumberOfTrials();
|
return getNumberOfTrials();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the mean.
|
||||||
*
|
*
|
||||||
* For <code>n</code> number of trials and
|
* For <code>n</code> number of trials and
|
||||||
* probability parameter <code>p</code>, the mean is
|
* probability parameter <code>p</code>, the mean is
|
||||||
* <code>n * p</code>
|
* <code>n * p</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the mean
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalMean() {
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
return (double)getNumberOfTrials() * getProbabilityOfSuccess();
|
return (double)getNumberOfTrials() * getProbabilityOfSuccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the variance.
|
||||||
*
|
*
|
||||||
* For <code>n</code> number of trials and
|
* For <code>n</code> number of trials and
|
||||||
* probability parameter <code>p</code>, the variance is
|
* probability parameter <code>p</code>, the variance is
|
||||||
* <code>n * p * (1 - p)</code>
|
* <code>n * p * (1 - p)</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
final double p = getProbabilityOfSuccess();
|
final double p = getProbabilityOfSuccess();
|
||||||
return (double)getNumberOfTrials() * p * (1 - p);
|
return (double)getNumberOfTrials() * p * (1 - p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
|
||||||
/**
|
/**
|
||||||
* For this distribution, X, this method returns P(X < <code>x</code>).
|
* For this distribution, X, this method returns P(X < <code>x</code>).
|
||||||
* @param x the value at which the CDF is evaluated.
|
* @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) {
|
public double cumulativeProbability(double x) {
|
||||||
return 0.5 + (FastMath.atan((x - median) / scale) / FastMath.PI);
|
return 0.5 + (FastMath.atan((x - median) / scale) / FastMath.PI);
|
||||||
|
@ -157,7 +157,6 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setMedian(double median) {
|
public void setMedian(double median) {
|
||||||
setMedianInternal(median);
|
setMedianInternal(median);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,7 +176,6 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setScale(double s) {
|
public void setScale(double s) {
|
||||||
setScaleInternal(s);
|
setScaleInternal(s);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,68 +271,50 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the lower bound of the support for this distribution.
|
||||||
*
|
* The lower bound of the support of the Cauchy distribution is always
|
||||||
* The lower bound of the support is always negative infinity no matter
|
* negative infinity, regardless of the parameters.
|
||||||
* the parameters.
|
|
||||||
*
|
*
|
||||||
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
|
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportLowerBound() {
|
public double getSupportLowerBound() {
|
||||||
return Double.NEGATIVE_INFINITY;
|
return Double.NEGATIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the upper bound of the support for this distribution.
|
||||||
*
|
* The upper bound of the support of the Cauchy distribution is always
|
||||||
* The upper bound of the support is always positive infinity no matter
|
* positive infinity, regardless of the parameters.
|
||||||
* the parameters.
|
|
||||||
*
|
*
|
||||||
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportUpperBound() {
|
public double getSupportUpperBound() {
|
||||||
return Double.POSITIVE_INFINITY;
|
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)
|
* @return mean (always Double.NaN)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalMean() {
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
return Double.NaN;
|
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)
|
* @return variance (always Double.NaN)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
return Double.NaN;
|
return Double.NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportLowerBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,6 @@ public class ChiSquaredDistributionImpl
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setDegreesOfFreedom(double degreesOfFreedom) {
|
public void setDegreesOfFreedom(double degreesOfFreedom) {
|
||||||
setDegreesOfFreedomInternal(degreesOfFreedom);
|
setDegreesOfFreedomInternal(degreesOfFreedom);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Modify the degrees of freedom.
|
* 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
|
* The lower bound of the support is always 0 no matter the
|
||||||
* degrees of freedom.
|
* degrees of freedom.
|
||||||
*
|
*
|
||||||
* @return lower bound of the support (always 0)
|
* @return lower bound of the support (always 0)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportLowerBound() {
|
public double getSupportLowerBound() {
|
||||||
return 0;
|
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
|
* The upper bound of the support is always positive infinity no matter the
|
||||||
* degrees of freedom.
|
* degrees of freedom.
|
||||||
*
|
*
|
||||||
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportUpperBound() {
|
public double getSupportUpperBound() {
|
||||||
return Double.POSITIVE_INFINITY;
|
return Double.POSITIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the mean of the distribution.
|
||||||
*
|
*
|
||||||
* For <code>k</code> degrees of freedom, the mean is
|
* For <code>k</code> degrees of freedom, the mean is
|
||||||
* <code>k</code>
|
* <code>k</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the mean
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalMean() {
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
return getDegreesOfFreedom();
|
return getDegreesOfFreedom();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the variance of the distribution.
|
||||||
*
|
*
|
||||||
* For <code>k</code> degrees of freedom, the variance is
|
* For <code>k</code> degrees of freedom, the variance is
|
||||||
* <code>2 * k</code>
|
* <code>2 * k</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
return 2*getDegreesOfFreedom();
|
return 2*getDegreesOfFreedom();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportLowerBoundInclusive() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,58 +53,4 @@ public interface Distribution {
|
||||||
*/
|
*/
|
||||||
double cumulativeProbability(double x0, double x1) throws MathException;
|
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();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,6 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setMean(double mean) {
|
public void setMean(double mean) {
|
||||||
setMeanInternal(mean);
|
setMeanInternal(mean);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Modify the mean.
|
* Modify the mean.
|
||||||
|
@ -204,7 +203,6 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
|
||||||
* @return domain value lower bound, i.e.
|
* @return domain value lower bound, i.e.
|
||||||
* P(X < <i>lower bound</i>) < <code>p</code>
|
* P(X < <i>lower bound</i>) < <code>p</code>
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
protected double getDomainLowerBound(double p) {
|
protected double getDomainLowerBound(double p) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +215,6 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
|
||||||
* @return domain value upper bound, i.e.
|
* @return domain value upper bound, i.e.
|
||||||
* P(X < <i>upper bound</i>) > <code>p</code>
|
* P(X < <i>upper bound</i>) > <code>p</code>
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
protected double getDomainUpperBound(double p) {
|
protected double getDomainUpperBound(double p) {
|
||||||
// NOTE: exponential is skewed to the left
|
// NOTE: exponential is skewed to the left
|
||||||
// NOTE: therefore, P(X < μ) > .5
|
// NOTE: therefore, P(X < μ) > .5
|
||||||
|
@ -266,70 +263,55 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@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)
|
* @return lower bound of the support (always 0)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportLowerBound() {
|
public double getSupportLowerBound() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the upper bound of the support for the distribution.
|
||||||
*
|
*
|
||||||
* The upper bound of the support is always positive infinity
|
* The upper bound of the support is always positive infinity,
|
||||||
* no matter the mean parameter.
|
* regardless of the mean.
|
||||||
*
|
*
|
||||||
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportUpperBound() {
|
public double getSupportUpperBound() {
|
||||||
return Double.POSITIVE_INFINITY;
|
return Double.POSITIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the mean of the distribution.
|
||||||
*
|
*
|
||||||
* For mean parameter <code>k</code>, the mean is
|
* For mean parameter <code>k</code>, the mean is
|
||||||
* <code>k</code>
|
* <code>k</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the mean
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalMean() {
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
return getMean();
|
return getMean();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the variance of the distribution.
|
||||||
*
|
*
|
||||||
* For mean parameter <code>k</code>, the variance is
|
* For mean parameter <code>k</code>, the variance is
|
||||||
* <code>k^2</code>
|
* <code>k^2</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
final double m = getMean();
|
final double m = getMean();
|
||||||
return m * m;
|
return m * m;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportLowerBoundInclusive() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,6 @@ public class FDistributionImpl
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setNumeratorDegreesOfFreedom(double degreesOfFreedom) {
|
public void setNumeratorDegreesOfFreedom(double degreesOfFreedom) {
|
||||||
setNumeratorDegreesOfFreedomInternal(degreesOfFreedom);
|
setNumeratorDegreesOfFreedomInternal(degreesOfFreedom);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,7 +243,6 @@ public class FDistributionImpl
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setDenominatorDegreesOfFreedom(double degreesOfFreedom) {
|
public void setDenominatorDegreesOfFreedom(double degreesOfFreedom) {
|
||||||
setDenominatorDegreesOfFreedomInternal(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)
|
* @return lower bound of the support (always 0)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportLowerBound() {
|
public double getSupportLowerBound() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the upper bound of the support for the distribution.
|
||||||
*
|
*
|
||||||
* The upper bound of the support is always positive infinity
|
* The upper bound of the support is always positive infinity,
|
||||||
* no matter the parameters.
|
* regardless of the parameters.
|
||||||
*
|
*
|
||||||
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportUpperBound() {
|
public double getSupportUpperBound() {
|
||||||
return Double.POSITIVE_INFINITY;
|
return Double.POSITIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the mean of the distribution.
|
||||||
*
|
*
|
||||||
* For denominator degrees of freedom parameter <code>b</code>,
|
* For denominator degrees of freedom parameter <code>b</code>,
|
||||||
* the mean is
|
* the mean is
|
||||||
|
@ -316,10 +314,10 @@ public class FDistributionImpl
|
||||||
* <li>else <code>undefined</code>
|
* <li>else <code>undefined</code>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the mean
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalMean() {
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
final double denominatorDF = getDenominatorDegreesOfFreedom();
|
final double denominatorDF = getDenominatorDegreesOfFreedom();
|
||||||
|
|
||||||
if (denominatorDF > 2) {
|
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>
|
* For numerator degrees of freedom parameter <code>a</code>
|
||||||
* and denominator degrees of freedom parameter <code>b</code>,
|
* and denominator degrees of freedom parameter <code>b</code>,
|
||||||
|
@ -343,10 +341,10 @@ public class FDistributionImpl
|
||||||
* <li>else <code>undefined</code>
|
* <li>else <code>undefined</code>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
final double denominatorDF = getDenominatorDegreesOfFreedom();
|
final double denominatorDF = getDenominatorDegreesOfFreedom();
|
||||||
|
|
||||||
if (denominatorDF > 4) {
|
if (denominatorDF > 4) {
|
||||||
|
@ -359,20 +357,4 @@ public class FDistributionImpl
|
||||||
|
|
||||||
return Double.NaN;
|
return Double.NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportLowerBoundInclusive() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,7 +137,6 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setAlpha(double alpha) {
|
public void setAlpha(double alpha) {
|
||||||
setAlphaInternal(alpha);
|
setAlphaInternal(alpha);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,7 +170,6 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setBeta(double newBeta) {
|
public void setBeta(double newBeta) {
|
||||||
setBetaInternal(newBeta);
|
setBetaInternal(newBeta);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -302,72 +300,56 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@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)
|
* @return lower bound of the support (always 0)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportLowerBound() {
|
public double getSupportLowerBound() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the upper bound of the support for the distribution.
|
||||||
*
|
*
|
||||||
* The upper bound of the support is always positive infinity
|
* The upper bound of the support is always positive infinity,
|
||||||
* no matter the parameters.
|
* regardless of the parameters.
|
||||||
*
|
*
|
||||||
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportUpperBound() {
|
public double getSupportUpperBound() {
|
||||||
return Double.POSITIVE_INFINITY;
|
return Double.POSITIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the mean.
|
||||||
*
|
*
|
||||||
* For shape parameter <code>alpha</code> and scale
|
* For shape parameter <code>alpha</code> and scale
|
||||||
* parameter <code>beta</code>, the mean is
|
* parameter <code>beta</code>, the mean is
|
||||||
* <code>alpha * beta</code>
|
* <code>alpha * beta</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the mean
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalMean() {
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
return getAlpha() * getBeta();
|
return getAlpha() * getBeta();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the variance.
|
||||||
*
|
*
|
||||||
* For shape parameter <code>alpha</code> and scale
|
* For shape parameter <code>alpha</code> and scale
|
||||||
* parameter <code>beta</code>, the variance is
|
* parameter <code>beta</code>, the variance is
|
||||||
* <code>alpha * beta^2</code>
|
* <code>alpha * beta^2</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
final double b = getBeta();
|
final double b = getBeta();
|
||||||
return getAlpha() * b * b;
|
return getAlpha() * b * b;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportLowerBoundInclusive() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,6 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setNumberOfSuccesses(int num) {
|
public void setNumberOfSuccesses(int num) {
|
||||||
setNumberOfSuccessesInternal(num);
|
setNumberOfSuccessesInternal(num);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,7 +267,6 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setPopulationSize(int size) {
|
public void setPopulationSize(int size) {
|
||||||
setPopulationSizeInternal(size);
|
setPopulationSizeInternal(size);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -295,7 +293,6 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setSampleSize(int size) {
|
public void setSampleSize(int size) {
|
||||||
setSampleSizeInternal(size);
|
setSampleSizeInternal(size);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Modify the sample size.
|
* Modify the sample size.
|
||||||
|
@ -358,7 +355,7 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the lower bound for the support for the distribution.
|
||||||
*
|
*
|
||||||
* For population size <code>N</code>,
|
* For population size <code>N</code>,
|
||||||
* number of successes <code>m</code>, and
|
* number of successes <code>m</code>, and
|
||||||
|
@ -367,15 +364,15 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
|
||||||
* <code>max(0, n + m - N)</code>
|
* <code>max(0, n + m - N)</code>
|
||||||
*
|
*
|
||||||
* @return lower bound of the support
|
* @return lower bound of the support
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public int getSupportLowerBound() {
|
public int getSupportLowerBound() {
|
||||||
return FastMath.max(0,
|
return FastMath.max(0,
|
||||||
getSampleSize() + getNumberOfSuccesses() - getPopulationSize());
|
getSampleSize() + getNumberOfSuccesses() - getPopulationSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the upper bound for the support of the distribution.
|
||||||
*
|
*
|
||||||
* For number of successes <code>m</code> and
|
* For number of successes <code>m</code> and
|
||||||
* sample size <code>n</code>,
|
* sample size <code>n</code>,
|
||||||
|
@ -383,39 +380,39 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
|
||||||
* <code>min(m, n)</code>
|
* <code>min(m, n)</code>
|
||||||
*
|
*
|
||||||
* @return upper bound of the support
|
* @return upper bound of the support
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public int getSupportUpperBound() {
|
public int getSupportUpperBound() {
|
||||||
return FastMath.min(getNumberOfSuccesses(), getSampleSize());
|
return FastMath.min(getNumberOfSuccesses(), getSampleSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the mean.
|
||||||
*
|
*
|
||||||
* For population size <code>N</code>,
|
* For population size <code>N</code>,
|
||||||
* number of successes <code>m</code>, and
|
* number of successes <code>m</code>, and
|
||||||
* sample size <code>n</code>, the mean is
|
* sample size <code>n</code>, the mean is
|
||||||
* <code>n * m / N</code>
|
* <code>n * m / N</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the mean
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
protected double getNumericalMean() {
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
return (double)(getSampleSize() * getNumberOfSuccesses()) / (double)getPopulationSize();
|
return (double)(getSampleSize() * getNumberOfSuccesses()) / (double)getPopulationSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the variance.
|
||||||
*
|
*
|
||||||
* For population size <code>N</code>,
|
* For population size <code>N</code>,
|
||||||
* number of successes <code>m</code>, and
|
* number of successes <code>m</code>, and
|
||||||
* sample size <code>n</code>, the variance is
|
* sample size <code>n</code>, the variance is
|
||||||
* <code>[ n * m * (N - n) * (N - m) ] / [ N^2 * (N - 1) ]</code>
|
* <code>[ n * m * (N - n) * (N - m) ] / [ N^2 * (N - 1) ]</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
final double N = getPopulationSize();
|
final double N = getPopulationSize();
|
||||||
final double m = getNumberOfSuccesses();
|
final double m = getNumberOfSuccesses();
|
||||||
final double n = getSampleSize();
|
final double n = getSampleSize();
|
||||||
|
|
|
@ -104,7 +104,6 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setMean(double mean) {
|
public void setMean(double mean) {
|
||||||
setMeanInternal(mean);
|
setMeanInternal(mean);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,7 +131,6 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setStandardDeviation(double sd) {
|
public void setStandardDeviation(double sd) {
|
||||||
setStandardDeviationInternal(sd);
|
setStandardDeviationInternal(sd);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -310,70 +308,42 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the lower bound of the support for the distribution.
|
||||||
*
|
*
|
||||||
* The lower bound of the support is always negative infinity
|
* The lower bound of the support is always negative infinity
|
||||||
* no matter the parameters.
|
* no matter the parameters.
|
||||||
*
|
*
|
||||||
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
|
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportLowerBound() {
|
public double getSupportLowerBound() {
|
||||||
return Double.NEGATIVE_INFINITY;
|
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
|
* The upper bound of the support is always positive infinity
|
||||||
* no matter the parameters.
|
* no matter the parameters.
|
||||||
*
|
*
|
||||||
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportUpperBound() {
|
public double getSupportUpperBound() {
|
||||||
return Double.POSITIVE_INFINITY;
|
return Double.POSITIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the variance.
|
||||||
*
|
|
||||||
* For mean parameter <code>mu</code>, the mean is <code>mu</code>
|
|
||||||
*
|
|
||||||
* @return {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
return getMean();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
*
|
||||||
* For standard deviation parameter <code>s</code>,
|
* For standard deviation parameter <code>s</code>,
|
||||||
* the variance is <code>s^2</code>
|
* the variance is <code>s^2</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
final double s = getStandardDeviation();
|
final double s = getStandardDeviation();
|
||||||
return s * s;
|
return s * s;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportLowerBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,6 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setNumberOfSuccesses(int successes) {
|
public void setNumberOfSuccesses(int successes) {
|
||||||
setNumberOfSuccessesInternal(successes);
|
setNumberOfSuccessesInternal(successes);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,7 +107,6 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setProbabilityOfSuccess(double p) {
|
public void setProbabilityOfSuccess(double p) {
|
||||||
setProbabilityOfSuccessInternal(p);
|
setProbabilityOfSuccessInternal(p);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,70 +215,62 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@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 no matter the parameters.
|
||||||
*
|
*
|
||||||
* @return lower bound of the support (always 0)
|
* @return lower bound of the support (always 0)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public int getSupportLowerBound() {
|
public int getSupportLowerBound() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the upper bound of the support for the distribution.
|
||||||
*
|
*
|
||||||
* The upper bound of the support is always positive infinity
|
* 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
|
* by <code>Integer.MAX_VALUE</code> together with
|
||||||
* {@link #isSupportUpperBoundInclusive()} being <code>false</code>
|
* {@link #isSupportUpperBoundInclusive()} being <code>false</code>
|
||||||
*
|
*
|
||||||
* @return upper bound of the support (always <code>Integer.MAX_VALUE</code> for positive infinity)
|
* @return upper bound of the support (always <code>Integer.MAX_VALUE</code> for positive infinity)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public int getSupportUpperBound() {
|
public int getSupportUpperBound() {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the mean.
|
||||||
*
|
*
|
||||||
* For number of successes <code>r</code> and
|
* For number of successes <code>r</code> and
|
||||||
* probability of success <code>p</code>, the mean is
|
* probability of success <code>p</code>, the mean is
|
||||||
* <code>( r * p ) / ( 1 - p )</code>
|
* <code>( r * p ) / ( 1 - p )</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the mean
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalMean() {
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
final double p = getProbabilityOfSuccess();
|
final double p = getProbabilityOfSuccess();
|
||||||
final double r = getNumberOfSuccesses();
|
final double r = getNumberOfSuccesses();
|
||||||
return ( r * p ) / ( 1 - p );
|
return ( r * p ) / ( 1 - p );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the variance.
|
||||||
*
|
*
|
||||||
* For number of successes <code>r</code> and
|
* For number of successes <code>r</code> and
|
||||||
* probability of success <code>p</code>, the mean is
|
* probability of success <code>p</code>, the mean is
|
||||||
* <code>( r * p ) / ( 1 - p )^2</code>
|
* <code>( r * p ) / ( 1 - p )^2</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
final double p = getProbabilityOfSuccess();
|
final double p = getProbabilityOfSuccess();
|
||||||
final double r = getNumberOfSuccesses();
|
final double r = getNumberOfSuccesses();
|
||||||
final double pInv = 1 - p;
|
final double pInv = 1 - p;
|
||||||
return ( r * p ) / (pInv * pInv);
|
return ( r * p ) / (pInv * pInv);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,6 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setMean(double p) {
|
public void setMean(double p) {
|
||||||
setNormalAndMeanInternal(normal, p);
|
setNormalAndMeanInternal(normal, p);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Set the Poisson mean for the distribution. The mean value must be
|
* Set the Poisson mean for the distribution. The mean value must be
|
||||||
|
@ -303,19 +302,19 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@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 no matter the mean parameter.
|
||||||
*
|
*
|
||||||
* @return lower bound of the support (always 0)
|
* @return lower bound of the support (always 0)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public int getSupportLowerBound() {
|
public int getSupportLowerBound() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the upper bound of the support for the distribution.
|
||||||
*
|
*
|
||||||
* The upper bound of the support is positive infinity,
|
* The upper bound of the support is positive infinity,
|
||||||
* regardless of the parameter values. There is no integer infinity,
|
* regardless of the parameter values. There is no integer infinity,
|
||||||
|
@ -323,41 +322,22 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
|
||||||
* {@link #isSupportUpperBoundInclusive()} returns <code>true</code>.
|
* {@link #isSupportUpperBoundInclusive()} returns <code>true</code>.
|
||||||
*
|
*
|
||||||
* @return upper bound of the support (always <code>Integer.MAX_VALUE</code> for positive infinity)
|
* @return upper bound of the support (always <code>Integer.MAX_VALUE</code> for positive infinity)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public int getSupportUpperBound() {
|
public int getSupportUpperBound() {
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the variance of the distribution.
|
||||||
*
|
|
||||||
* For mean parameter <code>p</code>, the mean is <code>p</code>
|
|
||||||
*
|
|
||||||
* @return {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
return getMean();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
*
|
||||||
* For mean parameter <code>p</code>, the variance is <code>p</code>
|
* For mean parameter <code>p</code>, the variance is <code>p</code>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
return getMean();
|
return getMean();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,6 @@ public class TDistributionImpl
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setDegreesOfFreedom(double degreesOfFreedom) {
|
public void setDegreesOfFreedom(double degreesOfFreedom) {
|
||||||
setDegreesOfFreedomInternal(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
|
* The lower bound of the support is always negative infinity
|
||||||
* no matter the parameters.
|
* no matter the parameters.
|
||||||
*
|
*
|
||||||
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
|
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportLowerBound() {
|
public double getSupportLowerBound() {
|
||||||
return Double.NEGATIVE_INFINITY;
|
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
|
* The upper bound of the support is always positive infinity
|
||||||
* no matter the parameters.
|
* no matter the parameters.
|
||||||
*
|
*
|
||||||
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportUpperBound() {
|
public double getSupportUpperBound() {
|
||||||
return Double.POSITIVE_INFINITY;
|
return Double.POSITIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the mean.
|
||||||
*
|
*
|
||||||
* For degrees of freedom parameter df, the mean is
|
* For degrees of freedom parameter df, the mean is
|
||||||
* <ul>
|
* <ul>
|
||||||
|
@ -261,10 +260,10 @@ public class TDistributionImpl
|
||||||
* <li>else <code>undefined</code></li>
|
* <li>else <code>undefined</code></li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the mean
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalMean() {
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
final double df = getDegreesOfFreedom();
|
final double df = getDegreesOfFreedom();
|
||||||
|
|
||||||
if (df > 1) {
|
if (df > 1) {
|
||||||
|
@ -275,7 +274,7 @@ public class TDistributionImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the variance.
|
||||||
*
|
*
|
||||||
* For degrees of freedom parameter df, the variance is
|
* For degrees of freedom parameter df, the variance is
|
||||||
* <ul>
|
* <ul>
|
||||||
|
@ -284,10 +283,10 @@ public class TDistributionImpl
|
||||||
* <li>else <code>undefined</code></li>
|
* <li>else <code>undefined</code></li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
final double df = getDegreesOfFreedom();
|
final double df = getDegreesOfFreedom();
|
||||||
|
|
||||||
if (df > 2) {
|
if (df > 2) {
|
||||||
|
@ -301,19 +300,4 @@ public class TDistributionImpl
|
||||||
return Double.NaN;
|
return Double.NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportLowerBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,18 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
|
||||||
/** Inverse cumulative probability accuracy */
|
/** Inverse cumulative probability accuracy */
|
||||||
private final double solverAbsoluteAccuracy;
|
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
|
* Creates weibull distribution with the given shape and scale and a
|
||||||
* location equal to zero.
|
* location equal to zero.
|
||||||
|
@ -81,7 +93,7 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
|
||||||
/**
|
/**
|
||||||
* For this distribution, X, this method returns P(X < <code>x</code>).
|
* For this distribution, X, this method returns P(X < <code>x</code>).
|
||||||
* @param x the value at which the CDF is evaluated.
|
* @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) {
|
public double cumulativeProbability(double x) {
|
||||||
double ret;
|
double ret;
|
||||||
|
@ -264,39 +276,39 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@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 no matter the parameters.
|
||||||
*
|
*
|
||||||
* @return lower bound of the support (always 0)
|
* @return lower bound of the support (always 0)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportLowerBound() {
|
public double getSupportLowerBound() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the upper bound of the support for the distribution.
|
||||||
*
|
*
|
||||||
* The upper bound of the support is always positive infinity
|
* The upper bound of the support is always positive infinity
|
||||||
* no matter the parameters.
|
* no matter the parameters.
|
||||||
*
|
*
|
||||||
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public double getSupportUpperBound() {
|
public double getSupportUpperBound() {
|
||||||
return Double.POSITIVE_INFINITY;
|
return Double.POSITIVE_INFINITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Calculates the mean.
|
||||||
*
|
*
|
||||||
* The mean is <code>scale * Gamma(1 + (1 / shape))</code>
|
* The mean is <code>scale * Gamma(1 + (1 / shape))</code>
|
||||||
* where <code>Gamma(...)</code> is the Gamma-function
|
* where <code>Gamma(...)</code> is the Gamma-function
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the mean
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
protected double calculateNumericalMean() {
|
protected double calculateNumericalMean() {
|
||||||
final double sh = getShape();
|
final double sh = getShape();
|
||||||
final double sc = getScale();
|
final double sc = getScale();
|
||||||
|
@ -305,16 +317,16 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Calculates the variance.
|
||||||
*
|
*
|
||||||
* The variance is
|
* The variance is
|
||||||
* <code>scale^2 * Gamma(1 + (2 / shape)) - mean^2</code>
|
* <code>scale^2 * Gamma(1 + (2 / shape)) - mean^2</code>
|
||||||
* where <code>Gamma(...)</code> is the Gamma-function
|
* where <code>Gamma(...)</code> is the Gamma-function
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
private double calculateNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
final double sh = getShape();
|
final double sh = getShape();
|
||||||
final double sc = getScale();
|
final double sc = getScale();
|
||||||
final double mn = getNumericalMean();
|
final double mn = getNumericalMean();
|
||||||
|
@ -325,18 +337,42 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the mean of the distribution.
|
||||||
|
*
|
||||||
|
* @return the mean or Double.NaN if it's not defined
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
public double getNumericalMean() {
|
||||||
public boolean isSupportLowerBoundInclusive() {
|
if (!numericalMeanIsCalculated) {
|
||||||
return true;
|
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 double getNumericalVariance() {
|
||||||
public boolean isSupportUpperBoundInclusive() {
|
if (!numericalVarianceIsCalculated) {
|
||||||
return false;
|
numericalVariance = calculateNumericalVariance();
|
||||||
|
numericalVarianceIsCalculated = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return numericalVariance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invalidates the cached mean and variance.
|
||||||
|
*/
|
||||||
|
private void invalidateParameterDependentMoments() {
|
||||||
|
numericalMeanIsCalculated = false;
|
||||||
|
numericalVarianceIsCalculated = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,6 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setNumberOfElements(final int n) {
|
public void setNumberOfElements(final int n) {
|
||||||
setNumberOfElementsInternal(n);
|
setNumberOfElementsInternal(n);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Set the number of elements (e.g. corpus size) for the distribution.
|
* Set the number of elements (e.g. corpus size) for the distribution.
|
||||||
|
@ -116,7 +115,6 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setExponent(final double s) {
|
public void setExponent(final double s) {
|
||||||
setExponentInternal(s);
|
setExponentInternal(s);
|
||||||
invalidateParameterDependentMoments();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -215,31 +213,31 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the lower bound of the support for the distribution.
|
||||||
*
|
*
|
||||||
* The lower bound of the support is always 1 no matter the parameters.
|
* The lower bound of the support is always 1 no matter the parameters.
|
||||||
*
|
*
|
||||||
* @return lower bound of the support (always 1)
|
* @return lower bound of the support (always 1)
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public int getSupportLowerBound() {
|
public int getSupportLowerBound() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the upper bound of the support for the distribution.
|
||||||
*
|
*
|
||||||
* The upper bound of the support is the number of elements
|
* The upper bound of the support is the number of elements
|
||||||
*
|
*
|
||||||
* @return upper bound of the support
|
* @return upper bound of the support
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public int getSupportUpperBound() {
|
public int getSupportUpperBound() {
|
||||||
return getNumberOfElements();
|
return getNumberOfElements();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the mean.
|
||||||
*
|
*
|
||||||
* For number of elements N and exponent s, the mean is
|
* For number of elements N and exponent s, the mean is
|
||||||
* <code>Hs1 / Hs</code> where
|
* <code>Hs1 / Hs</code> where
|
||||||
|
@ -248,10 +246,10 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
|
||||||
* <li><code>Hs = generalizedHarmonic(N, s)</code></li>
|
* <li><code>Hs = generalizedHarmonic(N, s)</code></li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the mean
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
protected double getNumericalMean() {
|
||||||
protected double calculateNumericalMean() {
|
|
||||||
final int N = getNumberOfElements();
|
final int N = getNumberOfElements();
|
||||||
final double s = getExponent();
|
final double s = getExponent();
|
||||||
|
|
||||||
|
@ -262,7 +260,7 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* Returns the variance.
|
||||||
*
|
*
|
||||||
* For number of elements N and exponent s, the mean is
|
* For number of elements N and exponent s, the mean is
|
||||||
* <code>(Hs2 / Hs) - (Hs1^2 / Hs^2)</code> where
|
* <code>(Hs2 / Hs) - (Hs1^2 / Hs^2)</code> where
|
||||||
|
@ -272,10 +270,10 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
|
||||||
* <li><code>Hs = generalizedHarmonic(N, s)</code></li>
|
* <li><code>Hs = generalizedHarmonic(N, s)</code></li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @return {@inheritDoc}
|
* @return the variance
|
||||||
|
* @since 2.2
|
||||||
*/
|
*/
|
||||||
@Override
|
protected double getNumericalVariance() {
|
||||||
protected double calculateNumericalVariance() {
|
|
||||||
final int N = getNumberOfElements();
|
final int N = getNumberOfElements();
|
||||||
final double s = getExponent();
|
final double s = getExponent();
|
||||||
|
|
||||||
|
|
|
@ -290,7 +290,7 @@ public class BetaDistributionTest extends TestCase {
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
BetaDistribution dist;
|
BetaDistributionImpl dist;
|
||||||
|
|
||||||
dist = new BetaDistributionImpl(1, 1);
|
dist = new BetaDistributionImpl(1, 1);
|
||||||
assertEquals(dist.getNumericalMean(), 0.5, tol);
|
assertEquals(dist.getNumericalMean(), 0.5, tol);
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class BinomialDistributionTest extends IntegerDistributionAbstractTest {
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
BinomialDistribution dist;
|
BinomialDistributionImpl dist;
|
||||||
|
|
||||||
dist = new BinomialDistributionImpl(10, 0.5);
|
dist = new BinomialDistributionImpl(10, 0.5);
|
||||||
assertEquals(dist.getNumericalMean(), 10d * 0.5d, tol);
|
assertEquals(dist.getNumericalMean(), 10d * 0.5d, tol);
|
||||||
|
|
|
@ -115,7 +115,7 @@ public class CauchyDistributionTest extends ContinuousDistributionAbstractTest
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
CauchyDistribution dist;
|
CauchyDistributionImpl dist;
|
||||||
|
|
||||||
dist = new CauchyDistributionImpl(10.2, 0.15);
|
dist = new CauchyDistributionImpl(10.2, 0.15);
|
||||||
assertTrue(Double.isNaN(dist.getNumericalMean()));
|
assertTrue(Double.isNaN(dist.getNumericalMean()));
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class ChiSquareDistributionTest extends ContinuousDistributionAbstractTes
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
ChiSquaredDistribution dist;
|
ChiSquaredDistributionImpl dist;
|
||||||
|
|
||||||
dist = new ChiSquaredDistributionImpl(1500);
|
dist = new ChiSquaredDistributionImpl(1500);
|
||||||
assertEquals(dist.getNumericalMean(), 1500, tol);
|
assertEquals(dist.getNumericalMean(), 1500, tol);
|
||||||
|
|
|
@ -124,7 +124,7 @@ public class ExponentialDistributionTest extends ContinuousDistributionAbstractT
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
ExponentialDistribution dist;
|
ExponentialDistributionImpl dist;
|
||||||
|
|
||||||
dist = new ExponentialDistributionImpl(11d);
|
dist = new ExponentialDistributionImpl(11d);
|
||||||
assertEquals(dist.getNumericalMean(), 11d, tol);
|
assertEquals(dist.getNumericalMean(), 11d, tol);
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class FDistributionTest extends ContinuousDistributionAbstractTest {
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
FDistribution dist;
|
FDistributionImpl dist;
|
||||||
|
|
||||||
dist = new FDistributionImpl(1, 2);
|
dist = new FDistributionImpl(1, 2);
|
||||||
assertTrue(Double.isNaN(dist.getNumericalMean()));
|
assertTrue(Double.isNaN(dist.getNumericalMean()));
|
||||||
|
|
|
@ -155,7 +155,7 @@ public class GammaDistributionTest extends ContinuousDistributionAbstractTest {
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
GammaDistribution dist;
|
GammaDistributionImpl dist;
|
||||||
|
|
||||||
dist = new GammaDistributionImpl(1, 2);
|
dist = new GammaDistributionImpl(1, 2);
|
||||||
assertEquals(dist.getNumericalMean(), 2, tol);
|
assertEquals(dist.getNumericalMean(), 2, tol);
|
||||||
|
|
|
@ -214,7 +214,7 @@ public class HypergeometricDistributionTest extends IntegerDistributionAbstractT
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
HypergeometricDistribution dist;
|
HypergeometricDistributionImpl dist;
|
||||||
|
|
||||||
dist = new HypergeometricDistributionImpl(1500, 40, 100);
|
dist = new HypergeometricDistributionImpl(1500, 40, 100);
|
||||||
assertEquals(dist.getNumericalMean(), 40d * 100d / 1500d, tol);
|
assertEquals(dist.getNumericalMean(), 40d * 100d / 1500d, tol);
|
||||||
|
|
|
@ -206,20 +206,17 @@ public class NormalDistributionTest extends ContinuousDistributionAbstractTest
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
NormalDistribution dist;
|
NormalDistributionImpl dist;
|
||||||
|
|
||||||
dist = new NormalDistributionImpl(0, 1);
|
dist = new NormalDistributionImpl(0, 1);
|
||||||
assertEquals(dist.getNumericalMean(), 0, tol);
|
|
||||||
assertEquals(dist.getNumericalVariance(), 1, tol);
|
assertEquals(dist.getNumericalVariance(), 1, tol);
|
||||||
|
|
||||||
dist.setMean(2.2);
|
dist.setMean(2.2);
|
||||||
dist.setStandardDeviation(1.4);
|
dist.setStandardDeviation(1.4);
|
||||||
assertEquals(dist.getNumericalMean(), 2.2, tol);
|
|
||||||
assertEquals(dist.getNumericalVariance(), 1.4 * 1.4, tol);
|
assertEquals(dist.getNumericalVariance(), 1.4 * 1.4, tol);
|
||||||
|
|
||||||
dist.setMean(-2000.9);
|
dist.setMean(-2000.9);
|
||||||
dist.setStandardDeviation(10.4);
|
dist.setStandardDeviation(10.4);
|
||||||
assertEquals(dist.getNumericalMean(), -2000.9, tol);
|
|
||||||
assertEquals(dist.getNumericalVariance(), 10.4 * 10.4, tol);
|
assertEquals(dist.getNumericalVariance(), 10.4 * 10.4, tol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class PascalDistributionTest extends IntegerDistributionAbstractTest {
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
PascalDistribution dist;
|
PascalDistributionImpl dist;
|
||||||
|
|
||||||
dist = new PascalDistributionImpl(10, 0.5);
|
dist = new PascalDistributionImpl(10, 0.5);
|
||||||
assertEquals(dist.getNumericalMean(), ( 10d * 0.5d ) / 0.5d, tol);
|
assertEquals(dist.getNumericalMean(), ( 10d * 0.5d ) / 0.5d, tol);
|
||||||
|
|
|
@ -220,14 +220,12 @@ public class PoissonDistributionTest extends IntegerDistributionAbstractTest {
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
PoissonDistribution dist;
|
PoissonDistributionImpl dist;
|
||||||
|
|
||||||
dist = new PoissonDistributionImpl(1);
|
dist = new PoissonDistributionImpl(1);
|
||||||
assertEquals(dist.getNumericalMean(), 1, tol);
|
|
||||||
assertEquals(dist.getNumericalVariance(), 1, tol);
|
assertEquals(dist.getNumericalVariance(), 1, tol);
|
||||||
|
|
||||||
dist.setMean(11.23);
|
dist.setMean(11.23);
|
||||||
assertEquals(dist.getNumericalMean(), 11.23, tol);
|
|
||||||
assertEquals(dist.getNumericalVariance(), 11.23, tol);
|
assertEquals(dist.getNumericalVariance(), 11.23, tol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class TDistributionTest extends ContinuousDistributionAbstractTest {
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
TDistribution dist;
|
TDistributionImpl dist;
|
||||||
|
|
||||||
dist = new TDistributionImpl(1);
|
dist = new TDistributionImpl(1);
|
||||||
assertTrue(Double.isNaN(dist.getNumericalMean()));
|
assertTrue(Double.isNaN(dist.getNumericalMean()));
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class WeibullDistributionTest extends ContinuousDistributionAbstractTest
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
WeibullDistribution dist;
|
WeibullDistributionImpl dist;
|
||||||
|
|
||||||
dist = new WeibullDistributionImpl(2.5, 3.5);
|
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)))
|
// In R: 3.5*gamma(1+(1/2.5)) (or emperically: mean(rweibull(10000, 2.5, 3.5)))
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class ZipfDistributionTest extends IntegerDistributionAbstractTest {
|
||||||
|
|
||||||
public void testMomonts() {
|
public void testMomonts() {
|
||||||
final double tol = 1e-9;
|
final double tol = 1e-9;
|
||||||
ZipfDistribution dist;
|
ZipfDistributionImpl dist;
|
||||||
|
|
||||||
dist = new ZipfDistributionImpl(2, 0.5);
|
dist = new ZipfDistributionImpl(2, 0.5);
|
||||||
assertEquals(dist.getNumericalMean(), FastMath.sqrt(2), tol);
|
assertEquals(dist.getNumericalMean(), FastMath.sqrt(2), tol);
|
||||||
|
|
Loading…
Reference in New Issue