You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ps...@apache.org on 2009/09/05 19:37:05 UTC
svn commit: r811685 [13/24] - in /commons/proper/math/trunk: ./
src/main/java/org/apache/commons/math/
src/main/java/org/apache/commons/math/analysis/
src/main/java/org/apache/commons/math/analysis/integration/
src/main/java/org/apache/commons/math/ana...
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/RankingAlgorithm.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/RankingAlgorithm.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/RankingAlgorithm.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/RankingAlgorithm.java Sat Sep 5 17:36:48 2009
@@ -19,7 +19,7 @@
/**
* Interface representing a rank transformation.
- *
+ *
* @since 2.0
* @version $Revision$ $Date$
*/
@@ -27,13 +27,13 @@
/**
* <p>Performs a rank transformation on the input data, returning an array
* of ranks.</p>
- *
+ *
* <p>Ranks should be 1-based - that is, the smallest value
* returned in an array of ranks should be greater than or equal to one,
* rather than 0. Ranks should in general take integer values, though
* implementations may return averages or other floating point values
* to resolve ties in the input data.</p>
- *
+ *
* @param data array of data to be ranked
* @return an array of ranks corresponding to the elements of the input array
*/
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/TiesStrategy.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/TiesStrategy.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/TiesStrategy.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/ranking/TiesStrategy.java Sat Sep 5 17:36:48 2009
@@ -26,7 +26,7 @@
* of the first occurrence. For example, (1,3,4,3) is ranked as (1,2,4,2)</li>
* <li>MAXIMUM - Tied values are assigned the maximum applicable rank, or the rank
* of the last occurrence. For example, (1,3,4,3) is ranked as (1,3,4,3)</li>
- * <li>AVERAGE - Tied values are assigned the average of the applicable ranks.
+ * <li>AVERAGE - Tied values are assigned the average of the applicable ranks.
* For example, (1,3,4,3) is ranked as (1,2.5,4,2.5)</li>
* <li>AVERAGE - Tied values are assigned a random integer rank from among the
* applicable values. The assigned rank will always be an integer, (inclusively)
@@ -37,19 +37,19 @@
* @version $Revision$ $Date$
*/
public enum TiesStrategy {
-
+
/** Ties assigned sequential ranks in order of occurrence */
SEQUENTIAL,
-
+
/** Ties get the minimum applicable rank */
MINIMUM,
-
+
/** Ties get the maximum applicable rank */
MAXIMUM,
-
+
/** Ties get the average of applicable ranks */
AVERAGE,
-
+
/** Ties get a random integral value from among applicable ranks */
RANDOM
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/AbstractMultipleLinearRegression.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/AbstractMultipleLinearRegression.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/AbstractMultipleLinearRegression.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/AbstractMultipleLinearRegression.java Sat Sep 5 17:36:48 2009
@@ -39,7 +39,7 @@
/**
* Loads model x and y sample data from a flat array of data, overriding any previous sample.
* Assumes that rows are concatenated with y values first in each row.
- *
+ *
* @param data input data array
* @param nobs number of observations (rows)
* @param nvars number of independent variables (columns, not counting y)
@@ -58,10 +58,10 @@
this.X = new Array2DRowRealMatrix(x);
this.Y = new ArrayRealVector(y);
}
-
+
/**
* Loads new y sample data, overriding any previous sample
- *
+ *
* @param y the [n,1] array representing the y sample
*/
protected void newYSampleData(double[] y) {
@@ -70,7 +70,7 @@
/**
* Loads new x sample data, overriding any previous sample
- *
+ *
* @param x the [n,k] array representing the x sample
*/
protected void newXSampleData(double[][] x) {
@@ -79,7 +79,7 @@
/**
* Validates sample data.
- *
+ *
* @param x the [n,k] array representing the x sample
* @param y the [n,1] array representing the y sample
* @throws IllegalArgumentException if the x and y array data are not
@@ -100,7 +100,7 @@
/**
* Validates sample data.
- *
+ *
* @param x the [n,k] array representing the x sample
* @param covariance the [n,n] array representing the covariance matrix
* @throws IllegalArgumentException if the x sample data or covariance
@@ -141,7 +141,7 @@
public double[][] estimateRegressionParametersVariance() {
return calculateBetaVariance().getData();
}
-
+
/**
* {@inheritDoc}
*/
@@ -165,7 +165,7 @@
/**
* Calculates the beta of multiple linear regression in matrix notation.
- *
+ *
* @return beta
*/
protected abstract RealVector calculateBeta();
@@ -173,14 +173,14 @@
/**
* Calculates the beta variance of multiple linear regression in matrix
* notation.
- *
+ *
* @return beta variance
*/
protected abstract RealMatrix calculateBetaVariance();
/**
* Calculates the Y variance of multiple linear regression.
- *
+ *
* @return Y variance
*/
protected abstract double calculateYVariance();
@@ -188,11 +188,11 @@
/**
* Calculates the residuals of multiple linear regression in matrix
* notation.
- *
+ *
* <pre>
* u = y - X * b
* </pre>
- *
+ *
* @return The residuals [n,1] matrix
*/
protected RealVector calculateResiduals() {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/GLSMultipleLinearRegression.java Sat Sep 5 17:36:48 2009
@@ -24,13 +24,13 @@
/**
* The GLS implementation of the multiple linear regression.
- *
+ *
* GLS assumes a general covariance matrix Omega of the error
* <pre>
* u ~ N(0, Omega)
* </pre>
- *
- * Estimated by GLS,
+ *
+ * Estimated by GLS,
* <pre>
* b=(X' Omega^-1 X)^-1X'Omega^-1 y
* </pre>
@@ -42,7 +42,7 @@
* @since 2.0
*/
public class GLSMultipleLinearRegression extends AbstractMultipleLinearRegression {
-
+
/** Covariance matrix. */
private RealMatrix Omega;
@@ -64,7 +64,7 @@
/**
* Add the covariance data.
- *
+ *
* @param omega the [n,n] array representing the covariance
*/
protected void newCovarianceData(double[][] omega){
@@ -83,7 +83,7 @@
}
return OmegaInverse;
}
-
+
/**
* Calculates beta by GLS.
* <pre>
@@ -127,5 +127,5 @@
double t = residuals.dotProduct(getOmegaInverse().operate(residuals));
return t / (X.getRowDimension() - X.getColumnDimension());
}
-
+
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/MultipleLinearRegression.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/MultipleLinearRegression.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/MultipleLinearRegression.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/MultipleLinearRegression.java Sat Sep 5 17:36:48 2009
@@ -24,8 +24,8 @@
* where y is an <code>n-vector</code> <b>regressand</b>, X is a <code>[n,k]</code> matrix whose <code>k</code> columns are called
* <b>regressors</b>, b is <code>k-vector</code> of <b>regression parameters</b> and <code>u</code> is an <code>n-vector</code>
* of <b>error terms</b> or <b>residuals</b>.
- *
- * The notation is quite standard in literature,
+ *
+ * The notation is quite standard in literature,
* cf eg <a href="http://www.econ.queensu.ca/ETM">Davidson and MacKinnon, Econometrics Theory and Methods, 2004</a>.
* @version $Revision$ $Date$
* @since 2.0
@@ -34,35 +34,35 @@
/**
* Estimates the regression parameters b.
- *
+ *
* @return The [k,1] array representing b
*/
double[] estimateRegressionParameters();
/**
* Estimates the variance of the regression parameters, ie Var(b).
- *
+ *
* @return The [k,k] array representing the variance of b
*/
double[][] estimateRegressionParametersVariance();
-
+
/**
* Estimates the residuals, ie u = y - X*b.
- *
+ *
* @return The [n,1] array representing the residuals
*/
double[] estimateResiduals();
/**
* Returns the variance of the regressand, ie Var(y).
- *
+ *
* @return The double representing the variance of y
*/
double estimateRegressandVariance();
-
+
/**
* Returns the standard errors of the regression parameters.
- *
+ *
* @return standard errors of estimated regression parameters
*/
double[] estimateRegressionParametersStandardErrors();
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegression.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegression.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegression.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/OLSMultipleLinearRegression.java Sat Sep 5 17:36:48 2009
@@ -26,20 +26,20 @@
import org.apache.commons.math.linear.ArrayRealVector;
/**
- * <p>Implements ordinary least squares (OLS) to estimate the parameters of a
+ * <p>Implements ordinary least squares (OLS) to estimate the parameters of a
* multiple linear regression model.</p>
- *
+ *
* <p>OLS assumes the covariance matrix of the error to be diagonal and with
* equal variance.</p>
* <p>
* u ~ N(0, σ<sup>2</sup>I)
* </p>
- *
+ *
* <p>The regression coefficients, b, satisfy the normal equations:
* <p>
* X<sup>T</sup> X b = X<sup>T</sup> y
* </p>
- *
+ *
* <p>To solve the normal equations, this implementation uses QR decomposition
* of the X matrix. (See {@link QRDecompositionImpl} for details on the
* decomposition algorithm.)
@@ -52,18 +52,18 @@
* R b = Q<sup>T</sup> y
* </p>
* Given Q and R, the last equation is solved by back-subsitution.</p>
- *
+ *
* @version $Revision$ $Date$
* @since 2.0
*/
public class OLSMultipleLinearRegression extends AbstractMultipleLinearRegression {
-
+
/** Cached QR decomposition of X matrix */
private QRDecomposition qr = null;
/**
* Loads model x and y sample data, overriding any previous sample.
- *
+ *
* Computes and caches QR decomposition of the X matrix.
* @param y the [n,1] array representing the y sample
* @param x the [n,k] array representing the x sample
@@ -75,10 +75,10 @@
newYSampleData(y);
newXSampleData(x);
}
-
+
/**
* {@inheritDoc}
- *
+ *
* Computes and caches QR decomposition of the X matrix
*/
@Override
@@ -86,7 +86,7 @@
super.newSampleData(data, nobs, nvars);
qr = new QRDecompositionImpl(X);
}
-
+
/**
* <p>Compute the "hat" matrix.
* </p>
@@ -97,9 +97,9 @@
* hat matrix as Q I<sub>p</sub>Q<sup>T</sup> where I<sub>p</sub> is the
* p-dimensional identity matrix augmented by 0's. This computational
* formula is from "The Hat Matrix in Regression and ANOVA",
- * David C. Hoaglin and Roy E. Welsch,
+ * David C. Hoaglin and Roy E. Welsch,
* <i>The American Statistician</i>, Vol. 32, No. 1 (Feb., 1978), pp. 17-22.
- *
+ *
* @return the hat matrix
*/
public RealMatrix calculateHat() {
@@ -118,14 +118,14 @@
}
}
}
-
+
// Compute and return Hat matrix
return Q.multiply(augI).multiply(Q.transpose());
}
-
+
/**
* Loads new x sample data, overriding any previous sample
- *
+ *
* @param x the [n,k] array representing the x sample
*/
@Override
@@ -133,10 +133,10 @@
this.X = new Array2DRowRealMatrix(x);
qr = new QRDecompositionImpl(X);
}
-
+
/**
* Calculates regression coefficients using OLS.
- *
+ *
* @return beta
*/
@Override
@@ -151,8 +151,8 @@
* </p>
* <p>Uses QR decomposition to reduce (X<sup>T</sup>X)<sup>-1</sup>
* to (R<sup>T</sup>R)<sup>-1</sup>, with only the top p rows of
- * R included, where p = the length of the beta vector.</p>
- *
+ * R included, where p = the length of the beta vector.</p>
+ *
* @return The beta variance
*/
@Override
@@ -162,7 +162,7 @@
RealMatrix Rinv = new LUDecompositionImpl(Raug).getSolver().getInverse();
return Rinv.multiply(Rinv.transpose());
}
-
+
/**
* <p>Calculates the variance on the Y by OLS.
@@ -177,26 +177,26 @@
return residuals.dotProduct(residuals) /
(X.getRowDimension() - X.getColumnDimension());
}
-
- /** TODO: Find a home for the following methods in the linear package */
-
+
+ /** TODO: Find a home for the following methods in the linear package */
+
/**
* <p>Uses back substitution to solve the system</p>
- *
+ *
* <p>coefficients X = constants</p>
- *
- * <p>coefficients must upper-triangular and constants must be a column
+ *
+ * <p>coefficients must upper-triangular and constants must be a column
* matrix. The solution is returned as a column matrix.</p>
- *
+ *
* <p>The number of columns in coefficients determines the length
* of the returned solution vector (column matrix). If constants
* has more rows than coefficients has columns, excess rows are ignored.
* Similarly, extra (zero) rows in coefficients are ignored</p>
- *
+ *
* @param coefficients upper-triangular coefficients matrix
* @param constants column RHS constants vector
* @return solution matrix as a column vector
- *
+ *
*/
private static RealVector solveUpperTriangular(RealMatrix coefficients,
RealVector constants) {
@@ -210,19 +210,19 @@
sum += coefficients.getEntry(index, j) * x[j];
}
x[index] = (constants.getEntry(index) - sum) / coefficients.getEntry(index, index);
- }
+ }
return new ArrayRealVector(x);
}
-
+
/**
* <p>Check if a matrix is upper-triangular.</p>
- *
+ *
* <p>Makes sure all below-diagonal elements are within epsilon of 0.</p>
- *
+ *
* @param m matrix to check
* @param epsilon maximum allowable absolute value for elements below
* the main diagonal
- *
+ *
* @throws IllegalArgumentException if m is not upper-triangular
*/
private static void checkUpperTriangular(RealMatrix m, double epsilon) {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/regression/SimpleRegression.java Sat Sep 5 17:36:48 2009
@@ -29,24 +29,24 @@
* <p>
* <code> y = intercept + slope * x </code></p>
* <p>
- * Standard errors for <code>intercept</code> and <code>slope</code> are
+ * Standard errors for <code>intercept</code> and <code>slope</code> are
* available as well as ANOVA, r-square and Pearson's r statistics.</p>
* <p>
- * Observations (x,y pairs) can be added to the model one at a time or they
+ * Observations (x,y pairs) can be added to the model one at a time or they
* can be provided in a 2-dimensional array. The observations are not stored
* in memory, so there is no limit to the number of observations that can be
- * added to the model.</p>
+ * added to the model.</p>
* <p>
* <strong>Usage Notes</strong>: <ul>
* <li> When there are fewer than two observations in the model, or when
- * there is no variation in the x values (i.e. all x values are the same)
+ * there is no variation in the x values (i.e. all x values are the same)
* all statistics return <code>NaN</code>. At least two observations with
- * different x coordinates are requred to estimate a bivariate regression
+ * different x coordinates are requred to estimate a bivariate regression
* model.
* </li>
* <li> getters for the statistics always compute values based on the current
* set of observations -- i.e., you can get statistics, then add more data
- * and get updated statistics without using a new instance. There is no
+ * and get updated statistics without using a new instance. There is no
* "compute" method that updates all statistics. Each of the getters performs
* the necessary computations to return the requested statistic.</li>
* </ul></p>
@@ -60,7 +60,7 @@
/** the distribution used to compute inference statistics. */
private TDistribution distribution;
-
+
/** sum of x values */
private double sumX = 0d;
@@ -93,7 +93,7 @@
public SimpleRegression() {
this(new TDistributionImpl(1.0));
}
-
+
/**
* Create an empty SimpleRegression using the given distribution object to
* compute inference statistics.
@@ -104,13 +104,13 @@
super();
setDistribution(t);
}
-
+
/**
* Adds the observation (x,y) to the regression data set.
* <p>
- * Uses updating formulas for means and sums of squares defined in
+ * Uses updating formulas for means and sums of squares defined in
* "Algorithms for Computing the Sample Variance: Analysis and
- * Recommendations", Chan, T.F., Golub, G.H., and LeVeque, R.J.
+ * Recommendations", Chan, T.F., Golub, G.H., and LeVeque, R.J.
* 1983, American Statistician, vol. 37, pp. 242-247, referenced in
* Weisberg, S. "Applied Linear Regression". 2nd Ed. 1985.</p>
*
@@ -134,21 +134,21 @@
sumX += x;
sumY += y;
n++;
-
+
if (n > 2) {
distribution.setDegreesOfFreedom(n - 2);
}
}
-
+
/**
* Removes the observation (x,y) from the regression data set.
* <p>
- * Mirrors the addData method. This method permits the use of
- * SimpleRegression instances in streaming mode where the regression
- * is applied to a sliding "window" of observations, however the caller is
+ * Mirrors the addData method. This method permits the use of
+ * SimpleRegression instances in streaming mode where the regression
+ * is applied to a sliding "window" of observations, however the caller is
* responsible for maintaining the set of observations in the window.</p>
- *
+ *
* The method has no effect if there are no points of data (i.e. n=0)
*
* @param x independent variable value
@@ -166,27 +166,27 @@
sumX -= x;
sumY -= y;
n--;
-
+
if (n > 2) {
distribution.setDegreesOfFreedom(n - 2);
- }
+ }
}
}
/**
- * Adds the observations represented by the elements in
+ * Adds the observations represented by the elements in
* <code>data</code>.
* <p>
* <code>(data[0][0],data[0][1])</code> will be the first observation, then
* <code>(data[1][0],data[1][1])</code>, etc.</p>
- * <p>
+ * <p>
* This method does not replace data that has already been added. The
* observations represented by <code>data</code> are added to the existing
* dataset.</p>
- * <p>
- * To replace all data, use <code>clear()</code> before adding the new
+ * <p>
+ * To replace all data, use <code>clear()</code> before adding the new
* data.</p>
- *
+ *
* @param data array of observations to be added
*/
public void addData(double[][] data) {
@@ -198,15 +198,15 @@
/**
* Removes observations represented by the elements in <code>data</code>.
- * <p>
- * If the array is larger than the current n, only the first n elements are
- * processed. This method permits the use of SimpleRegression instances in
- * streaming mode where the regression is applied to a sliding "window" of
- * observations, however the caller is responsible for maintaining the set
+ * <p>
+ * If the array is larger than the current n, only the first n elements are
+ * processed. This method permits the use of SimpleRegression instances in
+ * streaming mode where the regression is applied to a sliding "window" of
+ * observations, however the caller is responsible for maintaining the set
* of observations in the window.</p>
- * <p>
+ * <p>
* To remove all data, use <code>clear()</code>.</p>
- *
+ *
* @param data array of observations to be removed
*/
public void removeData(double[][] data) {
@@ -237,7 +237,7 @@
}
/**
- * Returns the "predicted" <code>y</code> value associated with the
+ * Returns the "predicted" <code>y</code> value associated with the
* supplied <code>x</code> value, based on the data that has been
* added to the model when this method is activated.
* <p>
@@ -245,7 +245,7 @@
* <p>
* <strong>Preconditions</strong>: <ul>
* <li>At least two observations (with at least two different x values)
- * must have been added before invoking this method. If this method is
+ * must have been added before invoking this method. If this method is
* invoked before a model can be estimated, <code>Double,NaN</code> is
* returned.
* </li></ul></p>
@@ -261,13 +261,13 @@
/**
* Returns the intercept of the estimated regression line.
* <p>
- * The least squares estimate of the intercept is computed using the
+ * The least squares estimate of the intercept is computed using the
* <a href="http://www.xycoon.com/estimation4.htm">normal equations</a>.
* The intercept is sometimes denoted b0.</p>
* <p>
* <strong>Preconditions</strong>: <ul>
* <li>At least two observations (with at least two different x values)
- * must have been added before invoking this method. If this method is
+ * must have been added before invoking this method. If this method is
* invoked before a model can be estimated, <code>Double,NaN</code> is
* returned.
* </li></ul></p>
@@ -279,15 +279,15 @@
}
/**
- * Returns the slope of the estimated regression line.
+ * Returns the slope of the estimated regression line.
* <p>
- * The least squares estimate of the slope is computed using the
+ * The least squares estimate of the slope is computed using the
* <a href="http://www.xycoon.com/estimation4.htm">normal equations</a>.
* The slope is sometimes denoted b1.</p>
* <p>
* <strong>Preconditions</strong>: <ul>
* <li>At least two observations (with at least two different x values)
- * must have been added before invoking this method. If this method is
+ * must have been added before invoking this method. If this method is
* invoked before a model can be estimated, <code>Double.NaN</code> is
* returned.
* </li></ul></p>
@@ -296,7 +296,7 @@
*/
public double getSlope() {
if (n < 2) {
- return Double.NaN; //not enough data
+ return Double.NaN; //not enough data
}
if (Math.abs(sumXX) < 10 * Double.MIN_VALUE) {
return Double.NaN; //not enough variation in x
@@ -306,7 +306,7 @@
/**
* Returns the <a href="http://www.xycoon.com/SumOfSquares.htm">
- * sum of squared errors</a> (SSE) associated with the regression
+ * sum of squared errors</a> (SSE) associated with the regression
* model.
* <p>
* The sum is computed using the computational formula</p>
@@ -317,16 +317,16 @@
* values about their mean, <code>SXX</code> is similarly defined and
* <code>SXY</code> is the sum of the products of x and y mean deviations.
* </p><p>
- * The sums are accumulated using the updating algorithm referenced in
+ * The sums are accumulated using the updating algorithm referenced in
* {@link #addData}.</p>
* <p>
- * The return value is constrained to be non-negative - i.e., if due to
- * rounding errors the computational formula returns a negative result,
+ * The return value is constrained to be non-negative - i.e., if due to
+ * rounding errors the computational formula returns a negative result,
* 0 is returned.</p>
* <p>
* <strong>Preconditions</strong>: <ul>
* <li>At least two observations (with at least two different x values)
- * must have been added before invoking this method. If this method is
+ * must have been added before invoking this method. If this method is
* invoked before a model can be estimated, <code>Double,NaN</code> is
* returned.
* </li></ul></p>
@@ -340,7 +340,7 @@
/**
* Returns the sum of squared deviations of the y values about their mean.
* <p>
- * This is defined as SSTO
+ * This is defined as SSTO
* <a href="http://www.xycoon.com/SumOfSquares.htm">here</a>.</p>
* <p>
* If <code>n < 2</code>, this returns <code>Double.NaN</code>.</p>
@@ -353,7 +353,7 @@
}
return sumYY;
}
-
+
/**
* Returns the sum of squared deviations of the x values about their mean.
*
@@ -367,7 +367,7 @@
}
return sumXX;
}
-
+
/**
* Returns the sum of crossproducts, x<sub>i</sub>*y<sub>i</sub>.
*
@@ -378,15 +378,15 @@
}
/**
- * Returns the sum of squared deviations of the predicted y values about
+ * Returns the sum of squared deviations of the predicted y values about
* their mean (which equals the mean of y).
* <p>
- * This is usually abbreviated SSR or SSM. It is defined as SSM
+ * This is usually abbreviated SSR or SSM. It is defined as SSM
* <a href="http://www.xycoon.com/SumOfSquares.htm">here</a></p>
* <p>
* <strong>Preconditions</strong>: <ul>
* <li>At least two observations (with at least two different x values)
- * must have been added before invoking this method. If this method is
+ * must have been added before invoking this method. If this method is
* invoked before a model can be estimated, <code>Double.NaN</code> is
* returned.
* </li></ul></p>
@@ -399,10 +399,10 @@
/**
* Returns the sum of squared errors divided by the degrees of freedom,
- * usually abbreviated MSE.
+ * usually abbreviated MSE.
* <p>
* If there are fewer than <strong>three</strong> data pairs in the model,
- * or if there is no variation in <code>x</code>, this returns
+ * or if there is no variation in <code>x</code>, this returns
* <code>Double.NaN</code>.</p>
*
* @return sum of squared deviations of y values
@@ -417,11 +417,11 @@
/**
* Returns <a href="http://mathworld.wolfram.com/CorrelationCoefficient.html">
* Pearson's product moment correlation coefficient</a>,
- * usually denoted r.
+ * usually denoted r.
* <p>
* <strong>Preconditions</strong>: <ul>
* <li>At least two observations (with at least two different x values)
- * must have been added before invoking this method. If this method is
+ * must have been added before invoking this method. If this method is
* invoked before a model can be estimated, <code>Double,NaN</code> is
* returned.
* </li></ul></p>
@@ -437,14 +437,14 @@
return result;
}
- /**
- * Returns the <a href="http://www.xycoon.com/coefficient1.htm">
+ /**
+ * Returns the <a href="http://www.xycoon.com/coefficient1.htm">
* coefficient of determination</a>,
- * usually denoted r-square.
+ * usually denoted r-square.
* <p>
* <strong>Preconditions</strong>: <ul>
* <li>At least two observations (with at least two different x values)
- * must have been added before invoking this method. If this method is
+ * must have been added before invoking this method. If this method is
* invoked before a model can be estimated, <code>Double,NaN</code> is
* returned.
* </li></ul></p>
@@ -458,11 +458,11 @@
/**
* Returns the <a href="http://www.xycoon.com/standarderrorb0.htm">
- * standard error of the intercept estimate</a>,
- * usually denoted s(b0).
+ * standard error of the intercept estimate</a>,
+ * usually denoted s(b0).
* <p>
- * If there are fewer that <strong>three</strong> observations in the
- * model, or if there is no variation in x, this returns
+ * If there are fewer that <strong>three</strong> observations in the
+ * model, or if there is no variation in x, this returns
* <code>Double.NaN</code>.</p>
*
* @return standard error associated with intercept estimate
@@ -475,12 +475,12 @@
/**
* Returns the <a href="http://www.xycoon.com/standerrorb(1).htm">standard
* error of the slope estimate</a>,
- * usually denoted s(b1).
+ * usually denoted s(b1).
* <p>
* If there are fewer that <strong>three</strong> data pairs in the model,
* or if there is no variation in x, this returns <code>Double.NaN</code>.
* </p>
- *
+ *
* @return standard error associated with slope estimate
*/
public double getSlopeStdErr() {
@@ -493,15 +493,15 @@
* <p>
* The 95% confidence interval is</p>
* <p>
- * <code>(getSlope() - getSlopeConfidenceInterval(),
+ * <code>(getSlope() - getSlopeConfidenceInterval(),
* getSlope() + getSlopeConfidenceInterval())</code></p>
* <p>
- * If there are fewer that <strong>three</strong> observations in the
- * model, or if there is no variation in x, this returns
+ * If there are fewer that <strong>three</strong> observations in the
+ * model, or if there is no variation in x, this returns
* <code>Double.NaN</code>.</p>
* <p>
* <strong>Usage Note</strong>:<br>
- * The validity of this statistic depends on the assumption that the
+ * The validity of this statistic depends on the assumption that the
* observations included in the model are drawn from a
* <a href="http://mathworld.wolfram.com/BivariateNormalDistribution.html">
* Bivariate Normal Distribution</a>.</p>
@@ -514,33 +514,33 @@
}
/**
- * Returns the half-width of a (100-100*alpha)% confidence interval for
+ * Returns the half-width of a (100-100*alpha)% confidence interval for
* the slope estimate.
* <p>
* The (100-100*alpha)% confidence interval is </p>
* <p>
- * <code>(getSlope() - getSlopeConfidenceInterval(),
+ * <code>(getSlope() - getSlopeConfidenceInterval(),
* getSlope() + getSlopeConfidenceInterval())</code></p>
* <p>
- * To request, for example, a 99% confidence interval, use
+ * To request, for example, a 99% confidence interval, use
* <code>alpha = .01</code></p>
* <p>
* <strong>Usage Note</strong>:<br>
- * The validity of this statistic depends on the assumption that the
+ * The validity of this statistic depends on the assumption that the
* observations included in the model are drawn from a
* <a href="http://mathworld.wolfram.com/BivariateNormalDistribution.html">
* Bivariate Normal Distribution</a>.</p>
* <p>
* <strong> Preconditions:</strong><ul>
- * <li>If there are fewer that <strong>three</strong> observations in the
- * model, or if there is no variation in x, this returns
+ * <li>If there are fewer that <strong>three</strong> observations in the
+ * model, or if there is no variation in x, this returns
* <code>Double.NaN</code>.
* </li>
- * <li><code>(0 < alpha < 1)</code>; otherwise an
+ * <li><code>(0 < alpha < 1)</code>; otherwise an
* <code>IllegalArgumentException</code> is thrown.
- * </li></ul></p>
+ * </li></ul></p>
*
- * @param alpha the desired significance level
+ * @param alpha the desired significance level
* @return half-width of 95% confidence interval for the slope estimate
* @throws MathException if the confidence interval can not be computed.
*/
@@ -556,7 +556,7 @@
}
/**
- * Returns the significance level of the slope (equiv) correlation.
+ * Returns the significance level of the slope (equiv) correlation.
* <p>
* Specifically, the returned value is the smallest <code>alpha</code>
* such that the slope confidence interval with significance level
@@ -564,13 +564,13 @@
* On regression output, this is often denoted <code>Prob(|t| > 0)</code>
* </p><p>
* <strong>Usage Note</strong>:<br>
- * The validity of this statistic depends on the assumption that the
+ * The validity of this statistic depends on the assumption that the
* observations included in the model are drawn from a
* <a href="http://mathworld.wolfram.com/BivariateNormalDistribution.html">
* Bivariate Normal Distribution</a>.</p>
* <p>
- * If there are fewer that <strong>three</strong> observations in the
- * model, or if there is no variation in x, this returns
+ * If there are fewer that <strong>three</strong> observations in the
+ * model, or if there is no variation in x, this returns
* <code>Double.NaN</code>.</p>
*
* @return significance level for slope/correlation
@@ -597,14 +597,14 @@
/**
* Computes SSR from b1.
- *
+ *
* @param slope regression slope estimate
* @return sum of squared deviations of predicted y values
*/
private double getRegressionSumSquares(double slope) {
return slope * slope * sumXX;
}
-
+
/**
* Modify the distribution used to compute inference statistics.
* @param value the new distribution
@@ -612,7 +612,7 @@
*/
public void setDistribution(TDistribution value) {
distribution = value;
-
+
// modify degrees of freedom
if (n > 2) {
distribution.setDegreesOfFreedom(n - 2);
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastCosineTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastCosineTransformer.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastCosineTransformer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastCosineTransformer.java Sat Sep 5 17:36:48 2009
@@ -53,7 +53,7 @@
* The formula is F<sub>n</sub> = (1/2) [f<sub>0</sub> + (-1)<sup>n</sup> f<sub>N</sub>] +
* ∑<sub>k=1</sub><sup>N-1</sup> f<sub>k</sub> cos(π nk/N)
* </p>
- *
+ *
* @param f the real data array to be transformed
* @return the real transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -68,7 +68,7 @@
* The formula is F<sub>n</sub> = (1/2) [f<sub>0</sub> + (-1)<sup>n</sup> f<sub>N</sub>] +
* ∑<sub>k=1</sub><sup>N-1</sup> f<sub>k</sub> cos(π nk/N)
* </p>
- *
+ *
* @param f the function to be sampled and transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -91,7 +91,7 @@
* The formula is F<sub>n</sub> = √(1/2N) [f<sub>0</sub> + (-1)<sup>n</sup> f<sub>N</sub>] +
* √(2/N) ∑<sub>k=1</sub><sup>N-1</sup> f<sub>k</sub> cos(π nk/N)
* </p>
- *
+ *
* @param f the real data array to be transformed
* @return the real transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -109,7 +109,7 @@
* √(2/N) ∑<sub>k=1</sub><sup>N-1</sup> f<sub>k</sub> cos(π nk/N)
*
* </p>
- *
+ *
* @param f the function to be sampled and transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -134,7 +134,7 @@
* The formula is f<sub>k</sub> = (1/N) [F<sub>0</sub> + (-1)<sup>k</sup> F<sub>N</sub>] +
* (2/N) ∑<sub>n=1</sub><sup>N-1</sup> F<sub>n</sub> cos(π nk/N)
* </p>
- *
+ *
* @param f the real data array to be inversely transformed
* @return the real inversely transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -151,7 +151,7 @@
* The formula is f<sub>k</sub> = (1/N) [F<sub>0</sub> + (-1)<sup>k</sup> F<sub>N</sub>] +
* (2/N) ∑<sub>n=1</sub><sup>N-1</sup> F<sub>n</sub> cos(π nk/N)
* </p>
- *
+ *
* @param f the function to be sampled and inversely transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -176,7 +176,7 @@
* The formula is f<sub>k</sub> = √(1/2N) [F<sub>0</sub> + (-1)<sup>k</sup> F<sub>N</sub>] +
* √(2/N) ∑<sub>n=1</sub><sup>N-1</sup> F<sub>n</sub> cos(π nk/N)
* </p>
- *
+ *
* @param f the real data array to be inversely transformed
* @return the real inversely transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -191,7 +191,7 @@
* The formula is f<sub>k</sub> = √(1/2N) [F<sub>0</sub> + (-1)<sup>k</sup> F<sub>N</sub>] +
* √(2/N) ∑<sub>n=1</sub><sup>N-1</sup> F<sub>n</sub> cos(π nk/N)
* </p>
- *
+ *
* @param f the function to be sampled and inversely transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastFourierTransformer.java Sat Sep 5 17:36:48 2009
@@ -63,7 +63,7 @@
* <p>
* The formula is $ y_n = \Sigma_{k=0}^{N-1} e^{-2 \pi i nk/N} x_k $
* </p>
- *
+ *
* @param f the real data array to be transformed
* @return the complex transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -78,7 +78,7 @@
* <p>
* The formula is $ y_n = \Sigma_{k=0}^{N-1} e^{-2 \pi i nk/N} x_k $
* </p>
- *
+ *
* @param f the function to be sampled and transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -100,7 +100,7 @@
* <p>
* The formula is $ y_n = \Sigma_{k=0}^{N-1} e^{-2 \pi i nk/N} x_k $
* </p>
- *
+ *
* @param f the complex data array to be transformed
* @return the complex transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -116,7 +116,7 @@
* <p>
* The formula is $y_n = (1/\sqrt{N}) \Sigma_{k=0}^{N-1} e^{-2 \pi i nk/N} x_k$
* </p>
- *
+ *
* @param f the real data array to be transformed
* @return the complex transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -133,7 +133,7 @@
* <p>
* The formula is $y_n = (1/\sqrt{N}) \Sigma_{k=0}^{N-1} e^{-2 \pi i nk/N} x_k$
* </p>
- *
+ *
* @param f the function to be sampled and transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -157,7 +157,7 @@
* <p>
* The formula is $y_n = (1/\sqrt{N}) \Sigma_{k=0}^{N-1} e^{-2 \pi i nk/N} x_k$
* </p>
- *
+ *
* @param f the complex data array to be transformed
* @return the complex transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -175,7 +175,7 @@
* <p>
* The formula is $ x_k = (1/N) \Sigma_{n=0}^{N-1} e^{2 \pi i nk/N} y_n $
* </p>
- *
+ *
* @param f the real data array to be inversely transformed
* @return the complex inversely transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -192,7 +192,7 @@
* <p>
* The formula is $ x_k = (1/N) \Sigma_{n=0}^{N-1} e^{2 \pi i nk/N} y_n $
* </p>
- *
+ *
* @param f the function to be sampled and inversely transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -216,7 +216,7 @@
* <p>
* The formula is $ x_k = (1/N) \Sigma_{n=0}^{N-1} e^{2 \pi i nk/N} y_n $
* </p>
- *
+ *
* @param f the complex data array to be inversely transformed
* @return the complex inversely transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -234,7 +234,7 @@
* <p>
* The formula is $x_k = (1/\sqrt{N}) \Sigma_{n=0}^{N-1} e^{2 \pi i nk/N} y_n$
* </p>
- *
+ *
* @param f the real data array to be inversely transformed
* @return the complex inversely transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -251,7 +251,7 @@
* <p>
* The formula is $x_k = (1/\sqrt{N}) \Sigma_{n=0}^{N-1} e^{2 \pi i nk/N} y_n$
* </p>
- *
+ *
* @param f the function to be sampled and inversely transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -275,7 +275,7 @@
* <p>
* The formula is $x_k = (1/\sqrt{N}) \Sigma_{n=0}^{N-1} e^{2 \pi i nk/N} y_n$
* </p>
- *
+ *
* @param f the complex data array to be inversely transformed
* @return the complex inversely transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -400,7 +400,7 @@
f[i+j+k].getImaginary() * omega_k_times_m_imaginary,
f[i+j+k].getReal() * omega_k_times_m_imaginary +
f[i+j+k].getImaginary() * omega_k_times_m_real);
-
+
f[i+j+k] = f[j+k].subtract(z);
f[j+k] = f[j+k].add(z);
}
@@ -477,7 +477,7 @@
/**
* Returns true if the argument is power of 2.
- *
+ *
* @param n the number to test
* @return true if the argument is power of 2
*/
@@ -487,7 +487,7 @@
/**
* Verifies that the data set has length of power of 2.
- *
+ *
* @param d the data array
* @throws IllegalArgumentException if array length is not power of 2
*/
@@ -496,12 +496,12 @@
throw MathRuntimeException.createIllegalArgumentException(
"{0} is not a power of 2, consider padding for fix",
d.length);
- }
+ }
}
/**
* Verifies that the data set has length of power of 2.
- *
+ *
* @param o the data array
* @throws IllegalArgumentException if array length is not power of 2
*/
@@ -510,12 +510,12 @@
throw MathRuntimeException.createIllegalArgumentException(
"{0} is not a power of 2, consider padding for fix",
o.length);
- }
+ }
}
/**
* Verifies that the endpoints specify an interval.
- *
+ *
* @param lower lower endpoint
* @param upper upper endpoint
* @throws IllegalArgumentException if not interval
@@ -527,9 +527,9 @@
throw MathRuntimeException.createIllegalArgumentException(
"endpoints do not specify an interval: [{0}, {1}]",
lower, upper);
- }
+ }
}
-
+
/**
* Performs a multi-dimensional Fourier transform on a given array.
* Use {@link #inversetransform2(Complex[])} and
@@ -555,7 +555,7 @@
}
return mdcm.getArray();
}
-
+
/**
* Performs one dimension of a multi-dimensional Fourier transform.
*
@@ -577,12 +577,12 @@
subVector[d] = i;
temp[i] = mdcm.get(subVector);
}
-
+
if (forward)
temp = transform2(temp);
else
temp = inversetransform2(temp);
-
+
for (int i = 0; i < dimensionSize[d]; i++) {
subVector[d] = i;
mdcm.set(temp[i], subVector);
@@ -673,15 +673,15 @@
"some dimensions don't match: {0} != {1}",
vector.length, dimensionSize.length);
}
-
+
Object lastDimension = multiDimensionalComplexArray;
-
+
for (int i = 0; i < dimensionSize.length; i++) {
lastDimension = ((Object[]) lastDimension)[vector[i]];
}
return (Complex) lastDimension;
}
-
+
/**
* Set a matrix element.
* @param magnitude magnitude of the element
@@ -741,7 +741,7 @@
clone(mdcm);
return mdcm;
}
-
+
/**
* Copy contents of current array into mdcm.
* @param mdcm array where to copy data
@@ -765,15 +765,15 @@
}
}
}
-
+
for (int[] nextVector: vectorList) {
mdcm.set(get(nextVector), nextVector);
}
}
}
-
-
- /** Computes the n<sup>th</sup> roots of unity.
+
+
+ /** Computes the n<sup>th</sup> roots of unity.
* A cache of already computed values is maintained.
*/
private static class RootsOfUnity implements Serializable {
@@ -800,13 +800,13 @@
* Build an engine for computing then <sup>th</sup> roots of unity
*/
public RootsOfUnity() {
-
+
omegaCount = 0;
omegaReal = null;
omegaImaginaryForward = null;
omegaImaginaryInverse = null;
isForward = true;
-
+
}
/**
@@ -815,15 +815,15 @@
* @throws IllegalStateException if no roots of unity have been computed yet
*/
public synchronized boolean isForward() throws IllegalStateException {
-
+
if (omegaCount == 0) {
throw MathRuntimeException.createIllegalStateException(
"roots of unity have not been computed yet");
- }
+ }
return isForward;
-
+
}
-
+
/** Computes the n<sup>th</sup> roots of unity.
* <p>The computed omega[] = { 1, w, w<sup>2</sup>, ... w<sup>(n-1)</sup> } where
* w = exp(-2 π i / n), i = &sqrt;(-1).</p>
@@ -841,10 +841,10 @@
}
isForward = (n > 0);
-
+
// avoid repetitive calculations
final int absN = Math.abs(n);
-
+
if (absN == omegaCount) {
return;
}
@@ -879,7 +879,7 @@
*/
public synchronized double getOmegaReal(int k)
throws IllegalStateException, IllegalArgumentException {
-
+
if (omegaCount == 0) {
throw MathRuntimeException.createIllegalStateException(
"roots of unity have not been computed yet");
@@ -889,9 +889,9 @@
"out of range root of unity index {0} (must be in [{1};{2}])",
k, 0, omegaCount - 1);
}
-
+
return omegaReal[k];
-
+
}
/**
@@ -903,7 +903,7 @@
*/
public synchronized double getOmegaImaginary(int k)
throws IllegalStateException, IllegalArgumentException {
-
+
if (omegaCount == 0) {
throw MathRuntimeException.createIllegalStateException(
"roots of unity have not been computed yet");
@@ -916,9 +916,9 @@
return (isForward) ?
omegaImaginaryForward[k] : omegaImaginaryInverse[k];
-
+
}
}
-
+
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastHadamardTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastHadamardTransformer.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastHadamardTransformer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastHadamardTransformer.java Sat Sep 5 17:36:48 2009
@@ -109,23 +109,23 @@
* +----+----------+---------+----------+
* </code>
* </pre>
- *
+ *
* <b><u>How it works</u></b>
* <ol>
- * <li>Construct a matrix with N rows and n+1 columns<br> <b>hadm[n+1][N]</b>
+ * <li>Construct a matrix with N rows and n+1 columns<br> <b>hadm[n+1][N]</b>
* <br><i>(If I use [x][y] it always means [row-offset][column-offset] of a Matrix with n rows and m columns. Its entries go from M[0][0] to M[n][m])</i></li>
* <li>Place the input vector <b>x[N]</b> in the first column of the matrix <b>hadm</b></li>
* <li>The entries of the submatrix D<sub>top</sub> are calculated as follows.
* <br>D<sub>top</sub> goes from entry [0][1] to [N/2-1][n+1].
- * <br>The columns of D<sub>top</sub> are the pairwise mutually exclusive sums of the previous column
+ * <br>The columns of D<sub>top</sub> are the pairwise mutually exclusive sums of the previous column
* </li>
* <li>The entries of the submatrix D<sub>bottom</sub> are calculated as follows.
* <br>D<sub>bottom</sub> goes from entry [N/2][1] to [N][n+1].
- * <br>The columns of D<sub>bottom</sub> are the pairwise differences of the previous column
+ * <br>The columns of D<sub>bottom</sub> are the pairwise differences of the previous column
* </li>
* <li>How D<sub>top</sub> and D<sub>bottom</sub> you can understand best with the example for N=8 above.
* <li>The output vector y is now in the last column of <b>hadm</b></li>
- * <li><i>Algorithm from: http://www.archive.chipcenter.com/dsp/DSP000517F1.html</i></li>
+ * <li><i>Algorithm from: http://www.archive.chipcenter.com/dsp/DSP000517F1.html</i></li>
* </ol>
* <br>
* <b><u>Visually</u></b>
@@ -146,7 +146,7 @@
* |N | x<sub>N/2</sub> | \/ |
* +------+--------+---+---+---+-----+---+
* </pre>
- *
+ *
* @param x input vector
* @return y output vector
* @exception IllegalArgumentException if input array is not a power of 2
@@ -178,14 +178,14 @@
yPrevious = yTmp;
// iterate from top to bottom (row)
- for (int i = 0; i < halfN; ++i) {
+ for (int i = 0; i < halfN; ++i) {
// D<sub>top</sub>
// The top part works with addition
final int twoI = 2 * i;
yCurrent[i] = yPrevious[twoI] + yPrevious[twoI + 1];
}
- for (int i = halfN; i < n; ++i) {
- // D<sub>bottom</sub>
+ for (int i = halfN; i < n; ++i) {
+ // D<sub>bottom</sub>
// The bottom part works with subtraction
final int twoI = 2 * i;
yCurrent[i] = yPrevious[twoI - n] - yPrevious[twoI - n + 1];
@@ -229,14 +229,14 @@
yPrevious = yTmp;
// iterate from top to bottom (row)
- for (int i = 0; i < halfN; ++i) {
+ for (int i = 0; i < halfN; ++i) {
// D<sub>top</sub>
// The top part works with addition
final int twoI = 2 * i;
yCurrent[i] = yPrevious[twoI] + yPrevious[twoI + 1];
}
- for (int i = halfN; i < n; ++i) {
- // D<sub>bottom</sub>
+ for (int i = halfN; i < n; ++i) {
+ // D<sub>bottom</sub>
// The bottom part works with subtraction
final int twoI = 2 * i;
yCurrent[i] = yPrevious[twoI - n] - yPrevious[twoI - n + 1];
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/FastSineTransformer.java Sat Sep 5 17:36:48 2009
@@ -34,7 +34,7 @@
* In addition, the first element must be 0 and it's enforced in function
* transformation after sampling.</p>
* <p>As of version 2.0 this no longer implements Serializable</p>
- *
+ *
* @version $Revision$ $Date$
* @since 1.2
*/
@@ -52,7 +52,7 @@
* <p>
* The formula is F<sub>n</sub> = ∑<sub>k=0</sub><sup>N-1</sup> f<sub>k</sub> sin(π nk/N)
* </p>
- *
+ *
* @param f the real data array to be transformed
* @return the real transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -67,7 +67,7 @@
* <p>
* The formula is F<sub>n</sub> = ∑<sub>k=0</sub><sup>N-1</sup> f<sub>k</sub> sin(π nk/N)
* </p>
- *
+ *
* @param f the function to be sampled and transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -91,7 +91,7 @@
* <p>
* The formula is F<sub>n</sub> = √(2/N) ∑<sub>k=0</sub><sup>N-1</sup> f<sub>k</sub> sin(π nk/N)
* </p>
- *
+ *
* @param f the real data array to be transformed
* @return the real transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -107,7 +107,7 @@
* <p>
* The formula is F<sub>n</sub> = √(2/N) ∑<sub>k=0</sub><sup>N-1</sup> f<sub>k</sub> sin(π nk/N)
* </p>
- *
+ *
* @param f the function to be sampled and transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -132,7 +132,7 @@
* <p>
* The formula is f<sub>k</sub> = (2/N) ∑<sub>n=0</sub><sup>N-1</sup> F<sub>n</sub> sin(π nk/N)
* </p>
- *
+ *
* @param f the real data array to be inversely transformed
* @return the real inversely transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -148,7 +148,7 @@
* <p>
* The formula is f<sub>k</sub> = (2/N) ∑<sub>n=0</sub><sup>N-1</sup> F<sub>n</sub> sin(π nk/N)
* </p>
- *
+ *
* @param f the function to be sampled and inversely transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
@@ -172,7 +172,7 @@
* <p>
* The formula is f<sub>k</sub> = √(2/N) ∑<sub>n=0</sub><sup>N-1</sup> F<sub>n</sub> sin(π nk/N)
* </p>
- *
+ *
* @param f the real data array to be inversely transformed
* @return the real inversely transformed array
* @throws IllegalArgumentException if any parameters are invalid
@@ -187,7 +187,7 @@
* <p>
* The formula is f<sub>k</sub> = √(2/N) ∑<sub>n=0</sub><sup>N-1</sup> F<sub>n</sub> sin(π nk/N)
* </p>
- *
+ *
* @param f the function to be sampled and inversely transformed
* @param min the lower bound for the interval
* @param max the upper bound for the interval
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/RealTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/RealTransformer.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/RealTransformer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/transform/RealTransformer.java Sat Sep 5 17:36:48 2009
@@ -79,4 +79,4 @@
double[] inversetransform(UnivariateRealFunction f, double min, double max, int n)
throws FunctionEvaluationException, IllegalArgumentException;
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/BigRealField.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/BigRealField.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/BigRealField.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/BigRealField.java Sat Sep 5 17:36:48 2009
@@ -70,7 +70,7 @@
*/
private Object readResolve() {
// return the singleton instance
- return LazyHolder.INSTANCE;
+ return LazyHolder.INSTANCE;
}
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/CompositeFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/CompositeFormat.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/CompositeFormat.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/CompositeFormat.java Sat Sep 5 17:36:48 2009
@@ -36,7 +36,7 @@
/**
* Create a default number format. The default number format is based on
* {@link NumberFormat#getInstance()} with the only customizing that the
- * maximum number of fraction digits is set to 2.
+ * maximum number of fraction digits is set to 2.
* @return the default number format.
*/
protected static NumberFormat getDefaultNumberFormat() {
@@ -46,7 +46,7 @@
/**
* Create a default number format. The default number format is based on
* {@link NumberFormat#getInstance(java.util.Locale)} with the only
- * customizing that the maximum number of fraction digits is set to 2.
+ * customizing that the maximum number of fraction digits is set to 2.
* @param locale the specific locale used by the format.
* @return the default number format specific to the given locale.
*/
@@ -81,19 +81,19 @@
int index = pos.getIndex();
final int n = source.length();
char ret = 0;
-
+
if (index < n) {
char c;
do {
c = source.charAt(index++);
} while (Character.isWhitespace(c) && index < n);
pos.setIndex(index);
-
+
if (index < n) {
ret = c;
}
}
-
+
return ret;
}
@@ -109,12 +109,12 @@
private Number parseNumber(final String source, final double value,
final ParsePosition pos) {
Number ret = null;
-
+
StringBuffer sb = new StringBuffer();
sb.append('(');
sb.append(value);
sb.append(')');
-
+
final int n = sb.length();
final int startIndex = pos.getIndex();
final int endIndex = startIndex + n;
@@ -124,7 +124,7 @@
pos.setIndex(endIndex);
}
}
-
+
return ret;
}
@@ -143,7 +143,7 @@
final int startIndex = pos.getIndex();
Number number = format.parse(source, pos);
final int endIndex = pos.getIndex();
-
+
// check for error parsing number
if (startIndex == endIndex) {
// try parsing special numbers
@@ -157,7 +157,7 @@
}
}
}
-
+
return number;
}
@@ -218,4 +218,4 @@
return toAppendTo;
}
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ContinuedFraction.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ContinuedFraction.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ContinuedFraction.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/ContinuedFraction.java Sat Sep 5 17:36:48 2009
@@ -35,7 +35,7 @@
* @version $Revision$ $Date$
*/
public abstract class ContinuedFraction {
-
+
/** Maximum allowed numerical error. */
private static final double DEFAULT_EPSILON = 10e-9;
@@ -67,7 +67,7 @@
/**
* Evaluates the continued fraction at the value x.
* @param x the evaluation point.
- * @return the value of the continued fraction evaluated at x.
+ * @return the value of the continued fraction evaluated at x.
* @throws MathException if the algorithm fails to converge.
*/
public double evaluate(double x) throws MathException {
@@ -78,7 +78,7 @@
* Evaluates the continued fraction at the value x.
* @param x the evaluation point.
* @param epsilon maximum error allowed.
- * @return the value of the continued fraction evaluated at x.
+ * @return the value of the continued fraction evaluated at x.
* @throws MathException if the algorithm fails to converge.
*/
public double evaluate(double x, double epsilon) throws MathException {
@@ -89,7 +89,7 @@
* Evaluates the continued fraction at the value x.
* @param x the evaluation point.
* @param maxIterations maximum number of convergents
- * @return the value of the continued fraction evaluated at x.
+ * @return the value of the continued fraction evaluated at x.
* @throws MathException if the algorithm fails to converge.
*/
public double evaluate(double x, int maxIterations) throws MathException {
@@ -100,7 +100,7 @@
* <p>
* Evaluates the continued fraction at the value x.
* </p>
- *
+ *
* <p>
* The implementation of this method is based on equations 14-17 of:
* <ul>
@@ -115,11 +115,11 @@
* very large intermediate results which can result in numerical overflow.
* As a means to combat these overflow conditions, the intermediate results
* are scaled whenever they threaten to become numerically unstable.</p>
- *
+ *
* @param x the evaluation point.
* @param epsilon maximum error allowed.
* @param maxIterations maximum number of convergents
- * @return the value of the continued fraction evaluated at x.
+ * @return the value of the continued fraction evaluated at x.
* @throws MathException if the algorithm fails to converge.
*/
public double evaluate(double x, double epsilon, int maxIterations)
@@ -155,7 +155,7 @@
}
double r = p2 / q2;
relativeError = Math.abs(r / c - 1.0);
-
+
// prepare for next iteration
c = p2 / q2;
p0 = p1;
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DefaultTransformer.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DefaultTransformer.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DefaultTransformer.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DefaultTransformer.java Sat Sep 5 17:36:48 2009
@@ -22,22 +22,22 @@
import org.apache.commons.math.MathException;
/**
- * A Default NumberTransformer for java.lang.Numbers and Numeric Strings. This
- * provides some simple conversion capabilities to turn any java.lang.Number
- * into a primitive double or to turn a String representation of a Number into
+ * A Default NumberTransformer for java.lang.Numbers and Numeric Strings. This
+ * provides some simple conversion capabilities to turn any java.lang.Number
+ * into a primitive double or to turn a String representation of a Number into
* a double.
*
* @version $Revision$ $Date$
*/
public class DefaultTransformer implements NumberTransformer, Serializable {
-
+
/** Serializable version identifier */
private static final long serialVersionUID = 4019938025047800455L;
-
+
/**
* @param o the object that gets transformed.
* @return a double primitive representation of the Object o.
- * @throws org.apache.commons.math.MathException If it cannot successfully
+ * @throws org.apache.commons.math.MathException If it cannot successfully
* be transformed or is null.
* @see <a href="http://commons.apache.org/collections/api-release/org/apache/commons/collections/Transformer.html"/>
*/
@@ -50,7 +50,7 @@
if (o instanceof Number) {
return ((Number)o).doubleValue();
}
-
+
try {
return Double.valueOf(o.toString()).doubleValue();
} catch (NumberFormatException e) {
@@ -62,7 +62,7 @@
/** {@inheritDoc} */
@Override
public boolean equals(Object other) {
- if (this == other) {
+ if (this == other) {
return true;
}
if (other == null) {
@@ -70,7 +70,7 @@
}
return other instanceof DefaultTransformer;
}
-
+
/** {@inheritDoc} */
@Override
public int hashCode() {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DoubleArray.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DoubleArray.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DoubleArray.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/util/DoubleArray.java Sat Sep 5 17:36:48 2009
@@ -28,17 +28,17 @@
/**
* Returns the number of elements currently in the array. Please note
- * that this may be different from the length of the internal storage array.
- *
+ * that this may be different from the length of the internal storage array.
+ *
* @return number of elements
*/
int getNumElements();
/**
* Returns the element at the specified index. Note that if an
- * out of bounds index is supplied a ArrayIndexOutOfBoundsException
+ * out of bounds index is supplied a ArrayIndexOutOfBoundsException
* will be thrown.
- *
+ *
* @param index index to fetch a value from
* @return value stored at the specified index
* @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than
@@ -49,10 +49,10 @@
/**
* Sets the element at the specified index. If the specified index is greater than
* <code>getNumElements() - 1</code>, the <code>numElements</code> property
- * is increased to <code>index +1</code> and additional storage is allocated
- * (if necessary) for the new element and all (uninitialized) elements
+ * is increased to <code>index +1</code> and additional storage is allocated
+ * (if necessary) for the new element and all (uninitialized) elements
* between the new element and the previous end of the array).
- *
+ *
* @param index index to store a value in
* @param value value to store at the specified index
* @throws ArrayIndexOutOfBoundsException if <code>index</code> is less than
@@ -62,7 +62,7 @@
/**
* Adds an element to the end of this expandable array
- *
+ *
* @param value to be added to end of array
*/
void addElement(double value);
@@ -78,7 +78,7 @@
* and addElementRolling(5) is invoked, the result is an array containing
* the entries 2, 3, 4, 5 and the value returned is 1.
* </p>
- *
+ *
* @param value the value to be added to the array
* @return the value which has been discarded or "pushed" out of the array
* by this rolling insert
@@ -86,9 +86,9 @@
double addElementRolling(double value);
/**
- * Returns a double[] array containing the elements of this
- * <code>DoubleArray</code>. If the underlying implementation is
- * array-based, this method should always return a copy, rather than a
+ * Returns a double[] array containing the elements of this
+ * <code>DoubleArray</code>. If the underlying implementation is
+ * array-based, this method should always return a copy, rather than a
* reference to the underlying array so that changes made to the returned
* array have no effect on the <code>DoubleArray.</code>
*