fixed checkstyle warnings

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@705239 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2008-10-16 13:32:32 +00:00
parent 0e77ce68b3
commit 223168ee50
11 changed files with 42 additions and 96 deletions

View File

@ -21,7 +21,9 @@ import org.apache.commons.math.MathException;
/** /**
* Computes the cumulative, inverse cumulative and density functions for the beta distribuiton. * Computes the cumulative, inverse cumulative and density functions for the beta distribuiton.
* *
* See http://en.wikipedia.org/wiki/Beta_distribution * @see <a href="http://en.wikipedia.org/wiki/Beta_distribution">Beta_distribution</a>
* @version $Revision$ $Date$
* @since 2.0
*/ */
public interface BetaDistribution extends ContinuousDistribution, HasDensity<Double> { public interface BetaDistribution extends ContinuousDistribution, HasDensity<Double> {
/** /**
@ -52,6 +54,7 @@ public interface BetaDistribution extends ContinuousDistribution, HasDensity<Dou
* Return the probability density for a particular point. * Return the probability density for a particular point.
* @param x The point at which the density should be computed. * @param x The point at which the density should be computed.
* @return The pdf at point x. * @return The pdf at point x.
* @exception MathException if probability density cannot be computed
*/ */
double density(Double x) throws MathException; double density(Double x) throws MathException;

View File

@ -29,6 +29,8 @@ import org.apache.commons.math.special.Beta;
* Beta distribution</a></li> * Beta distribution</a></li>
* </ul> * </ul>
* </p> * </p>
* @version $Revision$ $Date$
* @since 2.0
*/ */
public class BetaDistributionImpl public class BetaDistributionImpl
extends AbstractContinuousDistribution implements BetaDistribution { extends AbstractContinuousDistribution implements BetaDistribution {
@ -58,40 +60,24 @@ public class BetaDistributionImpl
z = Double.NaN; z = Double.NaN;
} }
/** /** {@inheritDoc} */
* Modify the shape parameter, alpha.
*
* @param alpha the new shape parameter.
*/
public void setAlpha(double alpha) { public void setAlpha(double alpha) {
this.alpha = alpha; this.alpha = alpha;
z = Double.NaN; z = Double.NaN;
} }
/** /** {@inheritDoc} */
* Access the shape parameter, alpha
*
* @return alpha.
*/
public double getAlpha() { public double getAlpha() {
return alpha; return alpha;
} }
/** /** {@inheritDoc} */
* Modify the shape parameter, beta.
*
* @param beta the new scale parameter.
*/
public void setBeta(double beta) { public void setBeta(double beta) {
this.beta = beta; this.beta = beta;
z = Double.NaN; z = Double.NaN;
} }
/** /** {@inheritDoc} */
* Access the shape parameter, beta
*
* @return beta.
*/
public double getBeta() { public double getBeta() {
return beta; return beta;
} }
@ -105,12 +91,7 @@ public class BetaDistributionImpl
} }
} }
/** /** {@inheritDoc} */
* Return the probability density for a particular point.
*
* @param x The point at which the density should be computed.
* @return The pdf at point x.
*/
public double density(Double x) throws MathException { public double density(Double x) throws MathException {
recomputeZ(); recomputeZ();
if (x < 0 || x > 1) { if (x < 0 || x > 1) {
@ -132,15 +113,7 @@ public class BetaDistributionImpl
} }
} }
/** /** {@inheritDoc} */
* For this distribution, X, this method returns x such that P(X &lt; x) = p.
*
* @param p the cumulative probability.
* @return x.
* @throws org.apache.commons.math.MathException
* if the inverse cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
public double inverseCumulativeProbability(double p) throws MathException { public double inverseCumulativeProbability(double p) throws MathException {
if (p == 0) { if (p == 0) {
return 0; return 0;
@ -151,57 +124,22 @@ public class BetaDistributionImpl
} }
} }
/** /** {@inheritDoc} */
* Access the initial domain value, based on <code>p</code>, used to
* bracket a CDF root. This method is used by
* {@link #inverseCumulativeProbability(double)} to find critical values.
*
* @param p the desired probability for the critical value
* @return initial domain value
*/
protected double getInitialDomain(double p) { protected double getInitialDomain(double p) {
return p; return p;
} }
/** /** {@inheritDoc} */
* Access the domain value lower bound, based on <code>p</code>, used to
* bracket a CDF root. This method is used by
* {@link #inverseCumulativeProbability(double)} to find critical values.
*
* @param p the desired probability for the critical value
* @return domain value lower bound, i.e.
* P(X &lt; <i>lower bound</i>) &lt; <code>p</code>
*/
protected double getDomainLowerBound(double p) { protected double getDomainLowerBound(double p) {
return 0; return 0;
} }
/** /** {@inheritDoc} */
* Access the domain value upper bound, based on <code>p</code>, used to
* bracket a CDF root. This method is used by
* {@link #inverseCumulativeProbability(double)} to find critical values.
*
* @param p the desired probability for the critical value
* @return domain value upper bound, i.e.
* P(X &lt; <i>upper bound</i>) &gt; <code>p</code>
*/
protected double getDomainUpperBound(double p) { protected double getDomainUpperBound(double p) {
return 1; return 1;
} }
/** /** {@inheritDoc} */
* For a random variable X whose values are distributed according
* to this distribution, this method returns P(X &le; x). In other words,
* this method represents the (cumulative) distribution function, or
* CDF, for this distribution.
*
* @param x the value at which the distribution function is evaluated.
* @return the probability that a random variable with this
* distribution takes a value less than or equal to <code>x</code>
* @throws org.apache.commons.math.MathException
* if the cumulative probability can not be
* computed due to convergence or other numerical errors.
*/
public double cumulativeProbability(double x) throws MathException { public double cumulativeProbability(double x) throws MathException {
if (x <= 0) { if (x <= 0) {
return 0; return 0;
@ -212,20 +150,7 @@ public class BetaDistributionImpl
} }
} }
/** /** {@inheritDoc} */
* For a random variable X whose values are distributed according
* to this distribution, this method returns P(x0 &le; X &le; x1).
*
* @param x0 the (inclusive) lower bound
* @param x1 the (inclusive) upper bound
* @return the probability that a random variable with this distribution
* will take a value between <code>x0</code> and <code>x1</code>,
* including the endpoints
* @throws org.apache.commons.math.MathException
* if the cumulative probability can not be
* computed due to convergence or other numerical errors.
* @throws IllegalArgumentException if <code>x0 > x1</code>
*/
public double cumulativeProbability(double x0, double x1) throws MathException { public double cumulativeProbability(double x0, double x1) throws MathException {
return cumulativeProbability(x1) - cumulativeProbability(x0); return cumulativeProbability(x1) - cumulativeProbability(x0);
} }

View File

@ -22,6 +22,8 @@ import org.apache.commons.math.MathException;
/** /**
* Interface that signals that a distribution can compute the probability density function * Interface that signals that a distribution can compute the probability density function
* for a particular point. * for a particular point.
* @param <P> the type of the point at which density is to be computed, this
* may be for example <code>Double</code>
* @version $Revision$ $Date$ * @version $Revision$ $Date$
*/ */
public interface HasDensity<P> { public interface HasDensity<P> {

View File

@ -35,12 +35,14 @@ public class NormalDistributionImpl extends AbstractContinuousDistribution
/** Serializable version identifier */ /** Serializable version identifier */
private static final long serialVersionUID = 8589540077390120676L; private static final long serialVersionUID = 8589540077390120676L;
/** &sqrt;(2 &pi;) */
private static final double SQRT2PI = Math.sqrt(2 * Math.PI);
/** The mean of this distribution. */ /** The mean of this distribution. */
private double mean = 0; private double mean = 0;
/** The standard deviation of this distribution. */ /** The standard deviation of this distribution. */
private double standardDeviation = 1; private double standardDeviation = 1;
private static final double SQRT2PI = Math.sqrt(2 * Math.PI);
/** /**
* Create a normal distribution using the given mean and standard deviation. * Create a normal distribution using the given mean and standard deviation.

View File

@ -40,7 +40,7 @@ public interface DecompositionSolver extends Serializable {
/** /**
* Decompose a matrix. * Decompose a matrix.
* @param matrix * @param matrix matrix to decompose
* @exception InvalidMatrixException if matrix does not fulfill * @exception InvalidMatrixException if matrix does not fulfill
* the decomposition requirements (for example non-square matrix * the decomposition requirements (for example non-square matrix
* for {@link LUDecomposition}) * for {@link LUDecomposition})

View File

@ -93,6 +93,7 @@ public interface EigenDecomposition extends DecompositionSolver {
/** /**
* Returns the i<sup>th</sup> eigenvalue of the original matrix. * Returns the i<sup>th</sup> eigenvalue of the original matrix.
* @param i index of the eigenvalue (counting from 0)
* @return i<sup>th</sup> eigenvalue of the original matrix * @return i<sup>th</sup> eigenvalue of the original matrix
* @exception IllegalStateException if {@link * @exception IllegalStateException if {@link
* DecompositionSolver#decompose(RealMatrix) decompose} has not been called * DecompositionSolver#decompose(RealMatrix) decompose} has not been called
@ -103,6 +104,7 @@ public interface EigenDecomposition extends DecompositionSolver {
/** /**
* Returns a copy of the i<sup>th</sup> eigenvector of the original matrix. * Returns a copy of the i<sup>th</sup> eigenvector of the original matrix.
* @param i index of the eigenvector (counting from 0)
* @return copy of the i<sup>th</sup> eigenvector of the original matrix * @return copy of the i<sup>th</sup> eigenvector of the original matrix
* @exception IllegalStateException if {@link * @exception IllegalStateException if {@link
* DecompositionSolver#decompose(RealMatrix) decompose} has not been called * DecompositionSolver#decompose(RealMatrix) decompose} has not been called

View File

@ -75,13 +75,18 @@ class GershgorinCirclesUnion implements Comparable<GershgorinCirclesUnion> {
* either circles union. It is mainly intended for circles unions * either circles union. It is mainly intended for circles unions
* that {@link #intersects(GershgorinCirclesUnion) intersect} * that {@link #intersects(GershgorinCirclesUnion) intersect}
* each other beforehand.</p> * each other beforehand.</p>
* @param other Gershgorin circles union to swallow
*/ */
public void swallow(final GershgorinCirclesUnion other) { public void swallow(final GershgorinCirclesUnion other) {
low = Math.min(low, other.low); low = Math.min(low, other.low);
high = Math.max(high, other.high); high = Math.max(high, other.high);
} }
/** Comparator class for sorting intervals. */ /** Compare another Gershgorin circles union in interval start order.
* @param other Gershgorin circles union to compare to instance
* @return a negative, zero or positive value depending on the other
* union starting before, at same location or after instance
*/
public int compareTo(GershgorinCirclesUnion other) { public int compareTo(GershgorinCirclesUnion other) {
return Double.compare(low, other.low); return Double.compare(low, other.low);
} }

View File

@ -348,8 +348,10 @@ public class LUDecompositionImpl implements LUDecomposition {
* <p>The A matrix is implicit here. It is </p> * <p>The A matrix is implicit here. It is </p>
* @param b right-hand side of the equation A &times; X = B * @param b right-hand side of the equation A &times; X = B
* @return a vector X such that A &times; X = B * @return a vector X such that A &times; X = B
* @throws IllegalArgumentException if matrices dimensions don't match * @exception IllegalStateException if {@link #decompose(RealMatrix) decompose}
* @throws InvalidMatrixException if decomposed matrix is singular * has not been called
* @exception IllegalArgumentException if matrices dimensions don't match
* @exception InvalidMatrixException if decomposed matrix is singular
*/ */
public RealVectorImpl solve(RealVectorImpl b) public RealVectorImpl solve(RealVectorImpl b)
throws IllegalStateException, IllegalArgumentException, InvalidMatrixException { throws IllegalStateException, IllegalArgumentException, InvalidMatrixException {

View File

@ -56,7 +56,7 @@ public interface SingularValueDecomposition extends DecompositionSolver {
/** /**
* Decompose a matrix to find its largest singular values. * Decompose a matrix to find its largest singular values.
* @param matrix * @param matrix matrix to decompose
* @param maxSingularValues maximal number of singular values to compute * @param maxSingularValues maximal number of singular values to compute
* @exception InvalidMatrixException (wrapping a {@link ConvergenceException} * @exception InvalidMatrixException (wrapping a {@link ConvergenceException}
* if algorithm fails to converge * if algorithm fails to converge

View File

@ -48,6 +48,11 @@ public class GLSMultipleLinearRegression extends AbstractMultipleLinearRegressio
/** Inverse of covariance matrix. */ /** Inverse of covariance matrix. */
private RealMatrix OmegaInverse; private RealMatrix OmegaInverse;
/** Replace sample data, overriding any previous sample.
* @param y y values of the sample
* @param x x values of the sample
* @param covariance array representing the covariance matrix
*/
public void newSampleData(double[] y, double[][] x, double[][] covariance) { public void newSampleData(double[] y, double[][] x, double[][] covariance) {
validateSampleData(x, y); validateSampleData(x, y);
newYSampleData(y); newYSampleData(y);

View File

@ -58,7 +58,7 @@ public class OLSMultipleLinearRegression extends AbstractMultipleLinearRegressio
/** Cached QR decomposition of X matrix */ /** Cached QR decomposition of X matrix */
private QRDecomposition qr = null; private QRDecomposition qr = null;
/* /**
* {@inheritDoc} * {@inheritDoc}
* *
* Computes and caches QR decomposition of the X matrix. * Computes and caches QR decomposition of the X matrix.