diff --git a/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolver.java b/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolver.java index 44d9079c6..b7d6f1f89 100644 --- a/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolver.java +++ b/src/main/java/org/apache/commons/math/analysis/solvers/UnivariateRealSolver.java @@ -98,7 +98,7 @@ public interface UnivariateRealSolver extends ConvergingAlgorithm { */ double solve(int maxEval, UnivariateRealFunction f, double min, double max) throws ConvergenceException, MathUserException; - + /** * Solve for a zero root in the given interval. *
A solver may require that the interval brackets a single zero root.
diff --git a/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java b/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
index b0550d2ff..15b65b971 100644
--- a/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
+++ b/src/main/java/org/apache/commons/math/distribution/AbstractContinuousDistribution.java
@@ -234,7 +234,7 @@ public abstract class AbstractContinuousDistribution
* @return lower bound of the support (might be Double.NEGATIVE_INFINITY)
*/
public abstract double getSupportLowerBound();
-
+
/**
* Access the upper bound of the support.
*
diff --git a/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java b/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java
index 11a4064c1..eca6be292 100644
--- a/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java
+++ b/src/main/java/org/apache/commons/math/distribution/AbstractDistribution.java
@@ -35,10 +35,10 @@ public abstract class AbstractDistribution
private double numericalMean = Double.NaN;
private boolean numericalMeanIsCalculated = false;
-
+
private double numericalVariance = Double.NaN;
private boolean numericalVarianceIsCalculated = false;
-
+
/**
* Default constructor.
*/
@@ -72,12 +72,12 @@ public abstract class AbstractDistribution
}
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
@@ -85,18 +85,18 @@ public abstract class AbstractDistribution
numericalMeanIsCalculated = false;
numericalVarianceIsCalculated = false;
}
-
+
/**
- * Use this method to actually calculate the mean for the
- * specific distribution. Use {@link #getNumericalMean()}
+ * 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
+ * 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
@@ -109,22 +109,22 @@ public abstract class AbstractDistribution
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.
+ * 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
+ * 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
+ * @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() {
@@ -132,40 +132,40 @@ public abstract class AbstractDistribution
numericalVariance = calculateNumericalVariance();
numericalVarianceIsCalculated = true;
}
-
+
return numericalVariance;
- }
-
+ }
+
/**
- * 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.
*
* @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
+ * 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();
-
+ public abstract boolean isSupportUpperBoundInclusive();
+
/**
- * Use this method to get information about whether the support is connected,
+ * 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
+ * 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()}
+ * 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)
*
diff --git a/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java b/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java
index 63bcdf8e8..03bd7da93 100644
--- a/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java
+++ b/src/main/java/org/apache/commons/math/distribution/AbstractIntegerDistribution.java
@@ -291,42 +291,42 @@ public abstract class AbstractIntegerDistribution extends AbstractDistribution
* P(X < upper bound) > 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,
* only true here is meaningful.
*
- * @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() {
return true;
}
-
+
/**
- * Use this method to get information about whether the upper bound
+ * Use this method to get information about whether the upper bound
* of the support is inclusive or not. For discrete support,
* only true here is meaningful.
*
- * @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() {
return true;
- }
+ }
}
diff --git a/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
index e67ef8b4d..3547d55b1 100644
--- a/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/BetaDistributionImpl.java
@@ -228,7 +228,7 @@ public class BetaDistributionImpl
/**
* {@inheritDoc}
- *
+ *
* The lower bound of the support is always 0 no matter the parameters.
*
* @return lower bound of the support (always 0)
@@ -240,7 +240,7 @@ public class BetaDistributionImpl
/**
* {@inheritDoc}
- *
+ *
* The upper bound of the support is always 1 no matter the parameters.
*
* @return upper bound of the support (always 1)
@@ -252,8 +252,8 @@ public class BetaDistributionImpl
/**
* {@inheritDoc}
- *
- * For first shape parameter s1
and
+ *
+ * For first shape parameter s1
and
* second shape parameter s2
, the mean is
* s1 / (s1 + s2)
*
@@ -267,9 +267,9 @@ public class BetaDistributionImpl
/**
* {@inheritDoc}
- *
- * For first shape parameter s1
and
- * second shape parameter s2
,
+ *
+ * For first shape parameter s1
and
+ * second shape parameter s2
,
* the variance is
* [ s1 * s2 ] / [ (s1 + s2)^2 * (s1 + s2 + 1) ]
*
@@ -278,7 +278,7 @@ public class BetaDistributionImpl
@Override
protected double calculateNumericalVariance() {
final double alpha = getAlpha();
- final double beta = getBeta();
+ final double beta = getBeta();
final double alphabetasum = alpha + beta;
return (alpha * beta) / ((alphabetasum * alphabetasum) * (alphabetasum + 1));
}
diff --git a/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
index 899734615..11fe7a6e7 100644
--- a/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/BinomialDistributionImpl.java
@@ -85,7 +85,7 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
setNumberOfTrialsInternal(trials);
invalidateParameterDependentMoments();
}
-
+
/**
* Change the number of trials for this distribution.
*
@@ -114,7 +114,7 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
setProbabilityOfSuccessInternal(p);
invalidateParameterDependentMoments();
}
-
+
/**
* Change the probability of success for this distribution.
*
@@ -227,8 +227,8 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
- * 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.
*
* @return lower bound of the support (always 0)
@@ -237,10 +237,10 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
public int getSupportLowerBound() {
return 0;
}
-
+
/**
* {@inheritDoc}
- *
+ *
* The upper bound of the support is the number of trials.
*
* @return upper bound of the support (equal to number of trials)
@@ -252,8 +252,8 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
- * For n
number of trials and
+ *
+ * For n
number of trials and
* probability parameter p
, the mean is
* n * p
*
@@ -266,8 +266,8 @@ public class BinomialDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
- * For n
number of trials and
+ *
+ * For n
number of trials and
* probability parameter p
, the variance is
* n * p * (1 - p)
*
diff --git a/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
index 4be6e3bd0..9d7617b06 100644
--- a/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/CauchyDistributionImpl.java
@@ -159,7 +159,7 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
setMedianInternal(median);
invalidateParameterDependentMoments();
}
-
+
/**
* Modify the median.
* @param newMedian for this distribution
@@ -179,7 +179,7 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
setScaleInternal(s);
invalidateParameterDependentMoments();
}
-
+
/**
* Modify the scale parameter.
* @param s scale parameter for this distribution
@@ -274,8 +274,8 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
- * The lower bound of the support is always negative infinity no matter
+ *
+ * The lower bound of the support is always negative infinity no matter
* the parameters.
*
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
@@ -287,8 +287,8 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
- * The upper bound of the support is always positive infinity no matter
+ *
+ * The upper bound of the support is always positive infinity no matter
* the parameters.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
@@ -300,7 +300,7 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
+ *
* The mean is always undefined no matter the parameters.
*
* @return mean (always Double.NaN)
@@ -312,7 +312,7 @@ public class CauchyDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
+ *
* The variance is always undefined no matter the parameters.
*
* @return variance (always Double.NaN)
diff --git a/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
index bbe3884dd..98fd6cc16 100644
--- a/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/ChiSquaredDistributionImpl.java
@@ -273,8 +273,8 @@ public class ChiSquaredDistributionImpl
/**
* {@inheritDoc}
- *
- * 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.
*
* @return lower bound of the support (always 0)
@@ -286,8 +286,8 @@ public class ChiSquaredDistributionImpl
/**
* {@inheritDoc}
- *
- * 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.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
@@ -299,7 +299,7 @@ public class ChiSquaredDistributionImpl
/**
* {@inheritDoc}
- *
+ *
* For k
degrees of freedom, the mean is
* k
*
@@ -312,7 +312,7 @@ public class ChiSquaredDistributionImpl
/**
* {@inheritDoc}
- *
+ *
* For k
degrees of freedom, the variance is
* 2 * k
*
diff --git a/src/main/java/org/apache/commons/math/distribution/Distribution.java b/src/main/java/org/apache/commons/math/distribution/Distribution.java
index 3edc3a4d2..2b58d8588 100644
--- a/src/main/java/org/apache/commons/math/distribution/Distribution.java
+++ b/src/main/java/org/apache/commons/math/distribution/Distribution.java
@@ -52,55 +52,55 @@ public interface Distribution {
* @throws IllegalArgumentException if x0 > x1
*/
double cumulativeProbability(double x0, double x1) throws MathException;
-
+
/**
- * Use this method to get the numerical value of the mean of this
+ * 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
+ * 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
+ * @return the variance (possibly Double.POSITIVE_INFINITY as
+ * for certain cases in {@link TDistributionImpl}) or
* Double.NaN if it's not defined
*/
- double getNumericalVariance();
-
+ double getNumericalVariance();
+
/**
- * 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.
*
* @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
+ * 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();
-
+ boolean isSupportUpperBoundInclusive();
+
/**
- * Use this method to get information about whether the support is connected,
+ * 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
+ * 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()}
+ * 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)
*
diff --git a/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
index d434c2eab..e5fc2340d 100644
--- a/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/ExponentialDistributionImpl.java
@@ -267,7 +267,7 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
+ *
* The lower bound of the support is always 0 no matter the mean parameter.
*
* @return lower bound of the support (always 0)
@@ -279,8 +279,8 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
- * 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.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
@@ -292,7 +292,7 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
+ *
* For mean parameter k
, the mean is
* k
*
@@ -305,7 +305,7 @@ public class ExponentialDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
+ *
* For mean parameter k
, the variance is
* k^2
*
diff --git a/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
index db8d48c66..06ce190c9 100644
--- a/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/FDistributionImpl.java
@@ -280,10 +280,10 @@ public class FDistributionImpl
protected double getSolverAbsoluteAccuracy() {
return solverAbsoluteAccuracy;
}
-
+
/**
* {@inheritDoc}
- *
+ *
* The lower bound of the support is always 0 no matter the parameters.
*
* @return lower bound of the support (always 0)
@@ -295,8 +295,8 @@ public class FDistributionImpl
/**
* {@inheritDoc}
- *
- * The upper bound of the support is always positive infinity
+ *
+ * The upper bound of the support is always positive infinity
* no matter the parameters.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
@@ -308,8 +308,8 @@ public class FDistributionImpl
/**
* {@inheritDoc}
- *
- * For denominator degrees of freedom parameter b
,
+ *
+ * For denominator degrees of freedom parameter b
,
* the mean is
*
b > 2
then b / (b - 2)
a
- * and denominator degrees of freedom parameter b
,
+ *
+ * For numerator degrees of freedom parameter a
+ * and denominator degrees of freedom parameter b
,
* the variance is
* b > 4
then
+ * if b > 4
then
* [ 2 * b^2 * (a + b - 2) ] / [ a * (b - 2)^2 * (b - 4) ]
* undefined
@@ -352,12 +352,12 @@ public class FDistributionImpl
if (denominatorDF > 4) {
final double numeratorDF = getNumeratorDegreesOfFreedom();
final double denomDFMinusTwo = denominatorDF - 2;
-
+
return ( 2 * (denominatorDF * denominatorDF) * (numeratorDF + denominatorDF - 2) )
/ ( (numeratorDF * (denomDFMinusTwo * denomDFMinusTwo) * (denominatorDF - 4)) );
}
-
- return Double.NaN;
+
+ return Double.NaN;
}
@Override
diff --git a/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
index 4a971c763..1056bb935 100644
--- a/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/GammaDistributionImpl.java
@@ -303,7 +303,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
+ *
* The lower bound of the support is always 0 no matter the parameters.
*
* @return lower bound of the support (always 0)
@@ -315,8 +315,8 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
- * The upper bound of the support is always positive infinity
+ *
+ * The upper bound of the support is always positive infinity
* no matter the parameters.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
@@ -328,8 +328,8 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
- * For shape parameter alpha
and scale
+ *
+ * For shape parameter alpha
and scale
* parameter beta
, the mean is
* alpha * beta
*
@@ -342,8 +342,8 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
- * For shape parameter alpha
and scale
+ *
+ * For shape parameter alpha
and scale
* parameter beta
, the variance is
* alpha * beta^2
*
@@ -351,7 +351,7 @@ public class GammaDistributionImpl extends AbstractContinuousDistribution
*/
@Override
protected double calculateNumericalVariance() {
- final double beta = getBeta();
+ final double beta = getBeta();
return getAlpha() * beta * beta;
}
diff --git a/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java
index 610c3ff73..4764085f9 100644
--- a/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/HypergeometricDistributionImpl.java
@@ -243,7 +243,7 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
setNumberOfSuccessesInternal(num);
invalidateParameterDependentMoments();
}
-
+
/**
* Modify the number of successes.
*
@@ -270,7 +270,7 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
setPopulationSizeInternal(size);
invalidateParameterDependentMoments();
}
-
+
/**
* Modify the population size.
*
@@ -359,10 +359,10 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
- * For population size N
,
- * number of successes m
, and
- * sample size n
,
+ *
+ * For population size N
,
+ * number of successes m
, and
+ * sample size n
,
* the lower bound of the support is
* max(0, n + m - N)
*
@@ -370,15 +370,15 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
*/
@Override
public int getSupportLowerBound() {
- return FastMath.max(0,
+ return FastMath.max(0,
getSampleSize() + getNumberOfSuccesses() - getPopulationSize());
}
/**
* {@inheritDoc}
- *
- * For number of successes m
and
- * sample size n
,
+ *
+ * For number of successes m
and
+ * sample size n
,
* the upper bound of the support is
* min(m, n)
*
@@ -391,9 +391,9 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
- * For population size N
,
- * number of successes m
, and
+ *
+ * For population size N
,
+ * number of successes m
, and
* sample size n
, the mean is
* n * m / N
*
@@ -406,9 +406,9 @@ public class HypergeometricDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
- * For population size N
,
- * number of successes m
, and
+ *
+ * For population size N
,
+ * number of successes m
, and
* sample size n
, the variance is
* [ n * m * (N - n) * (N - m) ] / [ N^2 * (N - 1) ]
*
diff --git a/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
index 75660fd0c..ce8e6c15f 100644
--- a/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/NormalDistributionImpl.java
@@ -106,7 +106,7 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
setMeanInternal(mean);
invalidateParameterDependentMoments();
}
-
+
/**
* Modify the mean.
* @param newMean for this distribution
@@ -134,7 +134,7 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
setStandardDeviationInternal(sd);
invalidateParameterDependentMoments();
}
-
+
/**
* Modify the standard deviation.
* @param sd standard deviation for this distribution
@@ -178,14 +178,14 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
* For this distribution, X, this method returns P(X < x
).
* If x
is more than 40 standard deviations from the mean, 0 or 1 is returned,
* as in these cases the actual value is within Double.MIN_VALUE
of 0 or 1.
- *
+ *
* @param x the value at which the CDF is evaluated.
* @return CDF evaluated at x
.
* @throws MathException if the algorithm fails to converge
*/
public double cumulativeProbability(double x) throws MathException {
final double dev = x - mean;
- if (FastMath.abs(dev) > 40 * standardDeviation) {
+ if (FastMath.abs(dev) > 40 * standardDeviation) {
return dev < 0 ? 0.0d : 1.0d;
}
return 0.5 * (1.0 + Erf.erf((dev) /
@@ -311,8 +311,8 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
- * The lower bound of the support is always negative infinity
+ *
+ * The lower bound of the support is always negative infinity
* no matter the parameters.
*
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
@@ -324,8 +324,8 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
- * The upper bound of the support is always positive infinity
+ *
+ * The upper bound of the support is always positive infinity
* no matter the parameters.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
@@ -337,7 +337,7 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
+ *
* For mean parameter mu
, the mean is mu
*
* @return {@inheritDoc}
@@ -349,8 +349,8 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
- * For standard deviation parameter s
,
+ *
+ * For standard deviation parameter s
,
* the variance is s^2
*
* @return {@inheritDoc}
diff --git a/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
index d7ae88248..8b53dd241 100644
--- a/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/PascalDistributionImpl.java
@@ -82,7 +82,7 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
setNumberOfSuccessesInternal(successes);
invalidateParameterDependentMoments();
}
-
+
/**
* Change the number of successes for this distribution.
* @param successes the new number of successes
@@ -110,7 +110,7 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
setProbabilityOfSuccessInternal(p);
invalidateParameterDependentMoments();
}
-
+
/**
* Change the probability of success for this distribution.
* @param p the new probability of success
@@ -218,7 +218,7 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
+ *
* The lower bound of the support is always 0 no matter the parameters.
*
* @return lower bound of the support (always 0)
@@ -230,10 +230,10 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
- * The upper bound of the support is always positive infinity
- * no matter the parameters. Positive infinity is symbolised
- * by Integer.MAX_VALUE
together with
+ *
+ * The upper bound of the support is always positive infinity
+ * no matter the parameters. Positive infinity is symbolised
+ * by Integer.MAX_VALUE
together with
* {@link #isSupportUpperBoundInclusive()} being false
*
* @return upper bound of the support (always Integer.MAX_VALUE
for positive infinity)
@@ -245,8 +245,8 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
- * For number of successes r
and
+ *
+ * For number of successes r
and
* probability of success p
, the mean is
* ( r * p ) / ( 1 - p )
*
@@ -261,8 +261,8 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
- * For number of successes r
and
+ *
+ * For number of successes r
and
* probability of success p
, the mean is
* ( r * p ) / ( 1 - p )^2
*
@@ -275,7 +275,7 @@ public class PascalDistributionImpl extends AbstractIntegerDistribution
final double pInv = 1 - p;
return ( r * p ) / (pInv * pInv);
}
-
+
@Override
public boolean isSupportUpperBoundInclusive() {
return false;
diff --git a/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
index 5654e6873..c8af9e355 100644
--- a/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/PoissonDistributionImpl.java
@@ -304,7 +304,7 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
+ *
* The lower bound of the support is always 0 no matter the mean parameter.
*
* @return lower bound of the support (always 0)
@@ -316,9 +316,9 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
- * The upper bound of the support is positive infinity,
- * regardless of the parameter values. There is no integer infinity,
+ *
+ * The upper bound of the support is positive infinity,
+ * regardless of the parameter values. There is no integer infinity,
* so this method returns Integer.MAX_VALUE
and
* {@link #isSupportUpperBoundInclusive()} returns true
.
*
@@ -331,7 +331,7 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
+ *
* For mean parameter p
, the mean is p
*
* @return {@inheritDoc}
@@ -343,7 +343,7 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
+ *
* For mean parameter p
, the variance is p
*
* @return {@inheritDoc}
@@ -352,7 +352,7 @@ public class PoissonDistributionImpl extends AbstractIntegerDistribution
protected double calculateNumericalVariance() {
return getMean();
}
-
+
@Override
public boolean isSupportUpperBoundInclusive() {
return true;
diff --git a/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
index f5c2951bc..42baf9758 100644
--- a/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/TDistributionImpl.java
@@ -83,7 +83,7 @@ public class TDistributionImpl
setDegreesOfFreedomInternal(degreesOfFreedom);
invalidateParameterDependentMoments();
}
-
+
/**
* Modify the degrees of freedom.
* @param newDegreesOfFreedom the new degrees of freedom.
@@ -228,8 +228,8 @@ public class TDistributionImpl
/**
* {@inheritDoc}
- *
- * The lower bound of the support is always negative infinity
+ *
+ * The lower bound of the support is always negative infinity
* no matter the parameters.
*
* @return lower bound of the support (always Double.NEGATIVE_INFINITY)
@@ -241,8 +241,8 @@ public class TDistributionImpl
/**
* {@inheritDoc}
- *
- * The upper bound of the support is always positive infinity
+ *
+ * The upper bound of the support is always positive infinity
* no matter the parameters.
*
* @return upper bound of the support (always Double.POSITIVE_INFINITY)
@@ -254,7 +254,7 @@ public class TDistributionImpl
/**
* {@inheritDoc}
- *
+ *
* For degrees of freedom parameter df, the mean is
* df > 1
then 0
df > 2
then df / (df - 2)
scale * Gamma(1 + (1 / shape))
* where Gamma(...)
is the Gamma-function
*
@@ -306,9 +306,9 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
/**
* {@inheritDoc}
- *
- * The variance is
- * scale^2 * Gamma(1 + (2 / shape)) - mean^2
+ *
+ * The variance is
+ * scale^2 * Gamma(1 + (2 / shape)) - mean^2
* where Gamma(...)
is the Gamma-function
*
* @return {@inheritDoc}
@@ -319,7 +319,7 @@ public class WeibullDistributionImpl extends AbstractContinuousDistribution
final double scale = getScale();
final double mean = getNumericalMean();
- return (scale * scale) *
+ return (scale * scale) *
FastMath.exp(Gamma.logGamma(1 + (2 / shape))) -
(mean * mean);
}
diff --git a/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java b/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java
index 008b67dd0..0e629f5de 100644
--- a/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java
+++ b/src/main/java/org/apache/commons/math/distribution/ZipfDistributionImpl.java
@@ -118,7 +118,7 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
setExponentInternal(s);
invalidateParameterDependentMoments();
}
-
+
/**
* Set the exponent characterising the distribution.
* The parameter value must be positive; otherwise an
@@ -216,19 +216,19 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
+ *
* The lower bound of the support is always 1 no matter the parameters.
*
* @return lower bound of the support (always 1)
*/
@Override
- public int getSupportLowerBound() {
+ public int getSupportLowerBound() {
return 1;
}
/**
* {@inheritDoc}
- *
+ *
* The upper bound of the support is the number of elements
*
* @return upper bound of the support
@@ -240,11 +240,11 @@ public class ZipfDistributionImpl extends AbstractIntegerDistribution
/**
* {@inheritDoc}
- *
+ *
* For number of elements N and exponent s, the mean is
- * Hs1 / Hs
where
+ * Hs1 / Hs
where
* Hs1 = generalizedHarmonic(N, s - 1)
Hs1 = generalizedHarmonic(N, s - 1)
Hs = generalizedHarmonic(N, s)
(Hs2 / Hs) - (Hs1^2 / Hs^2)
where
+ * (Hs2 / Hs) - (Hs1^2 / Hs^2)
where
* Hs2 = generalizedHarmonic(N, s - 2)
Hs1 = generalizedHarmonic(N, s - 1)
Hs1 = generalizedHarmonic(N, s - 1)
Hs = generalizedHarmonic(N, s)
All generators are quite fast. As an example, here are some comparisons, obtained on a 64 bits JVM on a diff --git a/src/main/java/org/apache/commons/math/special/Erf.java b/src/main/java/org/apache/commons/math/special/Erf.java index 5b8b1779b..c7023dce6 100644 --- a/src/main/java/org/apache/commons/math/special/Erf.java +++ b/src/main/java/org/apache/commons/math/special/Erf.java @@ -41,7 +41,7 @@ public class Erf { *
This implementation computes erf(x) using the * {@link Gamma#regularizedGammaP(double, double, double, int) regularized gamma function}, * following Erf, equation (3)
- * + * *The value returned is always between -1 and 1 (inclusive). If {@code abs(x) > 40}, then * {@code erf(x)} is indistinguishable from either 1 or -1 as a double, so the appropriate extreme * value is returned.
@@ -61,7 +61,7 @@ public class Erf { } return ret; } - + /** *Returns the complementary error function
*erfc(x) = 2/√π x∫∞ e-t2dt
@@ -70,11 +70,11 @@ public class Erf {
*
This implementation computes erfc(x) using the * {@link Gamma#regularizedGammaQ(double, double, double, int) regularized gamma function}, * following Erf, equation (3).
- * + * *The value returned is always between 0 and 2 (inclusive). If {@code abs(x) > 40}, then * {@code erf(x)} is indistinguishable from either 0 or 2 as a double, so the appropriate extreme * value is returned.
- * + * * @param x the value * @return the complementary error function erfc(x) * @throws MathException if the algorithm fails to converge diff --git a/src/main/java/org/apache/commons/math/stat/Frequency.java b/src/main/java/org/apache/commons/math/stat/Frequency.java index e66c1d327..3f0d6f1d2 100644 --- a/src/main/java/org/apache/commons/math/stat/Frequency.java +++ b/src/main/java/org/apache/commons/math/stat/Frequency.java @@ -287,12 +287,12 @@ public class Frequency implements Serializable { public long getCount(char v) { return getCount(Character.valueOf(v)); } - + /** * Returns the number of values in the frequency table. - * + * * @return the number of unique values that have been added to the frequency table. - * @see #valuesIterator() + * @see #valuesIterator() */ public int getUniqueCount(){ return freqTable.keySet().size(); diff --git a/src/main/java/org/apache/commons/math/stat/StatUtils.java b/src/main/java/org/apache/commons/math/stat/StatUtils.java index 629e25256..05f2fcae6 100644 --- a/src/main/java/org/apache/commons/math/stat/StatUtils.java +++ b/src/main/java/org/apache/commons/math/stat/StatUtils.java @@ -629,34 +629,34 @@ public final class StatUtils { } return (sum1 - (sum2 * sum2 / n)) / (n - 1); } - - - /** - * Normalize (standardize) the series, so in the end it is having a mean of 0 and a standard deviation of 1. - * + + + /** + * Normalize (standardize) the series, so in the end it is having a mean of 0 and a standard deviation of 1. + * * @param sample sample to normalize - * @return normalized (standardized) sample - */ - public static double[] normalize(final double[] sample) { - DescriptiveStatistics stats = new DescriptiveStatistics(); + * @return normalized (standardized) sample + */ + public static double[] normalize(final double[] sample) { + DescriptiveStatistics stats = new DescriptiveStatistics(); - // Add the data from the series to stats - for (int i = 0; i < sample.length; i++) { - stats.addValue(sample[i]); - } + // Add the data from the series to stats + for (int i = 0; i < sample.length; i++) { + stats.addValue(sample[i]); + } - // Compute mean and standard deviation - double mean = stats.getMean(); - double standardDeviation = stats.getStandardDeviation(); + // Compute mean and standard deviation + double mean = stats.getMean(); + double standardDeviation = stats.getStandardDeviation(); - // initialize the standardizedSample, which has the same length as the sample - double[] standardizedSample = new double[sample.length]; + // initialize the standardizedSample, which has the same length as the sample + double[] standardizedSample = new double[sample.length]; - for (int i = 0; i < sample.length; i++) { - // z = (x- mean)/standardDeviation - standardizedSample[i] = (sample[i] - mean) / standardDeviation; - } - return standardizedSample; - } + for (int i = 0; i < sample.length; i++) { + // z = (x- mean)/standardDeviation + standardizedSample[i] = (sample[i] - mean) / standardDeviation; + } + return standardizedSample; + } } diff --git a/src/main/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java b/src/main/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java index c32463944..6ece570c9 100644 --- a/src/main/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java +++ b/src/main/java/org/apache/commons/math/stat/descriptive/DescriptiveStatistics.java @@ -126,7 +126,7 @@ public class DescriptiveStatistics implements StatisticalSummary, Serializable { /** * Construct a DescriptiveStatistics instance with an infinite window * and the initial data values in double[] initialDoubleArray. - * If initialDoubleArray is null, then this constructor corresponds to + * If initialDoubleArray is null, then this constructor corresponds to * DescriptiveStatistics() * * @param initialDoubleArray the initial double[]. @@ -134,9 +134,9 @@ public class DescriptiveStatistics implements StatisticalSummary, Serializable { public DescriptiveStatistics(double[] initialDoubleArray) { if (initialDoubleArray != null) { eDA = new ResizableDoubleArray(initialDoubleArray); - } + } } - + /** * Copy constructor. Construct a new DescriptiveStatistics instance that * is a copy of original. diff --git a/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java b/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java index 756be7a6f..6cb38b1b8 100644 --- a/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java +++ b/src/main/java/org/apache/commons/math/stat/descriptive/StatisticalSummaryValues.java @@ -160,7 +160,7 @@ public class StatisticalSummaryValues implements Serializable, result = result * 31 + MathUtils.hash(getVariance()); return result; } - + /** * Generates a text report displaying values of statistics. * Each statistic is displayed on a separate line. diff --git a/src/main/java/org/apache/commons/math/util/FastMath.java b/src/main/java/org/apache/commons/math/util/FastMath.java index e6cdbb5d9..a7bfb3671 100644 --- a/src/main/java/org/apache/commons/math/util/FastMath.java +++ b/src/main/java/org/apache/commons/math/util/FastMath.java @@ -156,9 +156,9 @@ public class FastMath { /* Table of 2^((n+2)/3) */ private static final double CBRTTWO[] = { 0.6299605249474366, - 0.7937005259840998, - 1.0, - 1.2599210498948732, + 0.7937005259840998, + 1.0, + 1.2599210498948732, 1.5874010519681994 }; // Initialize tables @@ -494,7 +494,7 @@ public class FastMath { result = ratioa + ratiob; } - + if (negate) { result = -result; } @@ -893,10 +893,10 @@ public class FastMath { yb = -rb; } - if (hiPrecOut != null) { - hiPrecOut[0] = ya; - hiPrecOut[1] = yb; - } + if (hiPrecOut != null) { + hiPrecOut[0] = ya; + hiPrecOut[1] = yb; + } return ya + yb; } @@ -3143,12 +3143,12 @@ public class FastMath { int exp3 = exponent / 3; /* p2 will be the nearest power of 2 to x with its exponent divided by 3 */ - double p2 = Double.longBitsToDouble((inbits & 0x8000000000000000L) | + double p2 = Double.longBitsToDouble((inbits & 0x8000000000000000L) | (long)(((exp3 + 1023) & 0x7ff)) << 52); /* This will be a number between 1 and 2 */ final double mant = Double.longBitsToDouble((inbits & 0x000fffffffffffffL) | 0x3ff0000000000000L); - + /* Estimate the cube root of mant by polynomial */ double est = -0.010714690733195933; est = est * mant + 0.0875862700108075; @@ -3158,10 +3158,10 @@ public class FastMath { est *= CBRTTWO[exponent % 3 + 2]; - // est should now be good to about 15 bits of precision. Do 2 rounds of + // est should now be good to about 15 bits of precision. Do 2 rounds of // Newton's method to get closer, this should get us full double precision // Scale down x for the purpose of doing newtons method. This avoids over/under flows. - final double xs = x / (p2*p2*p2); + final double xs = x / (p2*p2*p2); est += (xs - est*est*est) / (3*est*est); est += (xs - est*est*est) / (3*est*est); diff --git a/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java b/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java index 1085e4e83..752fb3d00 100644 --- a/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java +++ b/src/main/java/org/apache/commons/math/util/MultidimensionalCounter.java @@ -302,7 +302,7 @@ public class MultidimensionalCounter implements IterableinitialCapacity = 16
* Create a ResizableArray with the specified initial capacity @@ -297,7 +297,7 @@ public class ResizableDoubleArray implements DoubleArray, Serializable { contract(); } } - + /** * Adds several element to the end of this expandable array. *