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 [11/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/descriptive/moment/StandardDeviation.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/StandardDeviation.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/StandardDeviation.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/StandardDeviation.java Sat Sep 5 17:36:48 2009
@@ -25,24 +25,24 @@
* is the positive square root of the variance. This implementation wraps a
* {@link Variance} instance. The <code>isBiasCorrected</code> property of the
* wrapped Variance instance is exposed, so that this class can be used to
- * compute both the "sample standard deviation" (the square root of the
+ * compute both the "sample standard deviation" (the square root of the
* bias-corrected "sample variance") or the "population standard deviation"
- * (the square root of the non-bias-corrected "population variance"). See
- * {@link Variance} for more information.
+ * (the square root of the non-bias-corrected "population variance"). See
+ * {@link Variance} for more information.
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class StandardDeviation extends AbstractStorelessUnivariateStatistic
implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = 5728716329662425188L;
-
+ private static final long serialVersionUID = 5728716329662425188L;
+
/** Wrapped Variance instance */
private Variance variance = null;
@@ -56,44 +56,44 @@
/**
* Constructs a StandardDeviation from an external second moment.
- *
+ *
* @param m2 the external moment
*/
public StandardDeviation(final SecondMoment m2) {
variance = new Variance(m2);
}
-
+
/**
* Copy constructor, creates a new {@code StandardDeviation} identical
* to the {@code original}
- *
+ *
* @param original the {@code StandardDeviation} instance to copy
*/
public StandardDeviation(StandardDeviation original) {
copy(original, this);
}
-
+
/**
* Contructs a StandardDeviation with the specified value for the
- * <code>isBiasCorrected</code> property. If this property is set to
+ * <code>isBiasCorrected</code> property. If this property is set to
* <code>true</code>, the {@link Variance} used in computing results will
* use the bias-corrected, or "sample" formula. See {@link Variance} for
* details.
- *
+ *
* @param isBiasCorrected whether or not the variance computation will use
* the bias-corrected formula
*/
public StandardDeviation(boolean isBiasCorrected) {
variance = new Variance(isBiasCorrected);
}
-
+
/**
* Contructs a StandardDeviation with the specified value for the
* <code>isBiasCorrected</code> property and the supplied external moment.
* If <code>isBiasCorrected</code> is set to <code>true</code>, the
* {@link Variance} used in computing results will use the bias-corrected,
* or "sample" formula. See {@link Variance} for details.
- *
+ *
* @param isBiasCorrected whether or not the variance computation will use
* the bias-corrected formula
* @param m2 the external moment
@@ -109,7 +109,7 @@
public void increment(final double d) {
variance.increment(d);
}
-
+
/**
* {@inheritDoc}
*/
@@ -134,7 +134,7 @@
}
/**
- * Returns the Standard Deviation of the entries in the input array, or
+ * Returns the Standard Deviation of the entries in the input array, or
* <code>Double.NaN</code> if the array is empty.
* <p>
* Returns 0 for a single-value (i.e. length = 1) sample.</p>
@@ -142,16 +142,16 @@
* Throws <code>IllegalArgumentException</code> if the array is null.</p>
* <p>
* Does not change the internal state of the statistic.</p>
- *
+ *
* @param values the input array
* @return the standard deviation of the values or Double.NaN if length = 0
* @throws IllegalArgumentException if the array is null
- */
+ */
@Override
public double evaluate(final double[] values) {
return Math.sqrt(variance.evaluate(values));
}
-
+
/**
* Returns the Standard Deviation of the entries in the specified portion of
* the input array, or <code>Double.NaN</code> if the designated subarray
@@ -162,7 +162,7 @@
* Throws <code>IllegalArgumentException</code> if the array is null.</p>
* <p>
* Does not change the internal state of the statistic.</p>
- *
+ *
* @param values the input array
* @param begin index of the first array element to include
* @param length the number of elements to include
@@ -174,7 +174,7 @@
public double evaluate(final double[] values, final int begin, final int length) {
return Math.sqrt(variance.evaluate(values, begin, length));
}
-
+
/**
* Returns the Standard Deviation of the entries in the specified portion of
* the input array, using the precomputed mean value. Returns
@@ -190,7 +190,7 @@
* Throws <code>IllegalArgumentException</code> if the array is null.</p>
* <p>
* Does not change the internal state of the statistic.</p>
- *
+ *
* @param values the input array
* @param mean the precomputed mean value
* @param begin index of the first array element to include
@@ -203,7 +203,7 @@
final int begin, final int length) {
return Math.sqrt(variance.evaluate(values, mean, begin, length));
}
-
+
/**
* Returns the Standard Deviation of the entries in the input array, using
* the precomputed mean value. Returns
@@ -219,7 +219,7 @@
* Throws <code>IllegalArgumentException</code> if the array is null.</p>
* <p>
* Does not change the internal state of the statistic.</p>
- *
+ *
* @param values the input array
* @param mean the precomputed mean value
* @return the standard deviation of the values or Double.NaN if length = 0
@@ -228,7 +228,7 @@
public double evaluate(final double[] values, final double mean) {
return Math.sqrt(variance.evaluate(values, mean));
}
-
+
/**
* @return Returns the isBiasCorrected.
*/
@@ -242,7 +242,7 @@
public void setBiasCorrected(boolean isBiasCorrected) {
variance.setBiasCorrected(isBiasCorrected);
}
-
+
/**
* {@inheritDoc}
*/
@@ -252,12 +252,12 @@
copy(this, result);
return result;
}
-
-
+
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source StandardDeviation to copy
* @param dest StandardDeviation to copy to
* @throws NullPointerException if either source or dest is null
@@ -265,5 +265,5 @@
public static void copy(StandardDeviation source, StandardDeviation dest) {
dest.variance = source.variance.copy();
}
-
+
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/ThirdMoment.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/ThirdMoment.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/ThirdMoment.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/ThirdMoment.java Sat Sep 5 17:36:48 2009
@@ -37,24 +37,24 @@
* Returns <code>Double.NaN</code> if no data values have been added and
* returns <code>0</code> if there is just one value in the data set.</p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class ThirdMoment extends SecondMoment implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = -7818711964045118679L;
-
+ private static final long serialVersionUID = -7818711964045118679L;
+
/** third moment of values that have been added */
protected double m3;
/**
- * Square of deviation of most recently added value from previous first
- * moment, normalized by previous sample size. Retained to prevent
+ * Square of deviation of most recently added value from previous first
+ * moment, normalized by previous sample size. Retained to prevent
* repeated computation in higher order moments. nDevSq = nDev * nDev.
*/
protected double nDevSq;
@@ -67,11 +67,11 @@
m3 = Double.NaN;
nDevSq = Double.NaN;
}
-
+
/**
* Copy constructor, creates a new {@code ThirdMoment} identical
* to the {@code original}
- *
+ *
* @param original the {@code ThirdMoment} instance to copy
*/
public ThirdMoment(ThirdMoment original) {
@@ -85,8 +85,8 @@
public void increment(final double d) {
if (n < 1) {
m3 = m2 = m1 = 0.0;
- }
-
+ }
+
double prevM2 = m2;
super.increment(d);
nDevSq = nDev * nDev;
@@ -111,7 +111,7 @@
m3 = Double.NaN;
nDevSq = Double.NaN;
}
-
+
/**
* {@inheritDoc}
*/
@@ -119,13 +119,13 @@
public ThirdMoment copy() {
ThirdMoment result = new ThirdMoment();
copy(this, result);
- return result;
+ return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source ThirdMoment to copy
* @param dest ThirdMoment to copy to
* @throws NullPointerException if either source or dest is null
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Variance.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Variance.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Variance.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/Variance.java Sat Sep 5 17:36:48 2009
@@ -56,18 +56,18 @@
* To compute population variances, set this property to <code>false.</code>
* </p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class Variance extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = -9111962718267217978L;
-
+ private static final long serialVersionUID = -9111962718267217978L;
+
/** SecondMoment is used in incremental calculation of Variance*/
protected SecondMoment moment = null;
@@ -432,7 +432,7 @@
for (int i = 0; i < weights.length; i++) {
sumWts += weights[i];
}
-
+
if (isBiasCorrected) {
var = accum / (sumWts - 1);
} else {
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovariance.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovariance.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovariance.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialCovariance.java Sat Sep 5 17:36:48 2009
@@ -151,4 +151,4 @@
return true;
}
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialMean.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialMean.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialMean.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/moment/VectorialMean.java Sat Sep 5 17:36:48 2009
@@ -102,4 +102,4 @@
return true;
}
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/package.html
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/package.html?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/package.html (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/package.html Sat Sep 5 17:36:48 2009
@@ -18,7 +18,7 @@
<!-- $Revision$ $Date$ -->
<body>
Generic univariate summary statistic objects.
-
+
<h3>UnivariateStatistic API Usage Examples:</h3>
<h4>UnivariateStatistic:</h4>
<code>/* evaluation approach */<br/> double[] values = new double[] { 1, 2,
@@ -28,7 +28,7 @@
<h4>StorelessUnivariateStatistic:</h4>
<code>/* incremental approach */<br/> double[] values = new double[] { 1, 2,
3, 4, 5 };<br/> <span style="font-weight: bold;">
- StorelessUnivariateStatistic stat = new Mean();</span><br/>
+ StorelessUnivariateStatistic stat = new Mean();</span><br/>
System.out.println("mean before adding a value is NaN = " + <span
style="font-weight: bold;">stat.getResult()</span>);<br/> for (int i = 0;
i < values.length; i++) {<br/> <span
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Max.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Max.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Max.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Max.java Sat Sep 5 17:36:48 2009
@@ -24,27 +24,27 @@
* Returns the maximum of the available values.
* <p>
* <ul>
- * <li>The result is <code>NaN</code> iff all values are <code>NaN</code>
+ * <li>The result is <code>NaN</code> iff all values are <code>NaN</code>
* (i.e. <code>NaN</code> values have no impact on the value of the statistic).</li>
- * <li>If any of the values equals <code>Double.POSITIVE_INFINITY</code>,
+ * <li>If any of the values equals <code>Double.POSITIVE_INFINITY</code>,
* the result is <code>Double.POSITIVE_INFINITY.</code></li>
* </ul></p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class Max extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = -5593383832225844641L;
-
+ private static final long serialVersionUID = -5593383832225844641L;
+
/** Number of values that have been added */
private long n;
-
+
/** Current value of the statistic */
private double value;
@@ -55,17 +55,17 @@
n = 0;
value = Double.NaN;
}
-
+
/**
* Copy constructor, creates a new {@code Max} identical
* to the {@code original}
- *
+ *
* @param original the {@code Max} instance to copy
*/
public Max(Max original) {
copy(original, this);
}
-
+
/**
* {@inheritDoc}
*/
@@ -100,7 +100,7 @@
public long getN() {
return n;
}
-
+
/**
* Returns the maximum of the entries in the specified portion of
* the input array, or <code>Double.NaN</code> if the designated subarray
@@ -110,12 +110,12 @@
* the array index parameters are not valid.</p>
* <p>
* <ul>
- * <li>The result is <code>NaN</code> iff all values are <code>NaN</code>
+ * <li>The result is <code>NaN</code> iff all values are <code>NaN</code>
* (i.e. <code>NaN</code> values have no impact on the value of the statistic).</li>
- * <li>If any of the values equals <code>Double.POSITIVE_INFINITY</code>,
+ * <li>If any of the values equals <code>Double.POSITIVE_INFINITY</code>,
* the result is <code>Double.POSITIVE_INFINITY.</code></li>
* </ul></p>
- *
+ *
* @param values the input array
* @param begin index of the first array element to include
* @param length the number of elements to include
@@ -136,7 +136,7 @@
}
return max;
}
-
+
/**
* {@inheritDoc}
*/
@@ -146,11 +146,11 @@
copy(this, result);
return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source Max to copy
* @param dest Max to copy to
* @throws NullPointerException if either source or dest is null
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Median.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Median.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Median.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Median.java Sat Sep 5 17:36:48 2009
@@ -23,17 +23,17 @@
* Returns the median of the available values. This is the same as the 50th percentile.
* See {@link Percentile} for a description of the algorithm used.
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class Median extends Percentile implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = -3961477041290915687L;
+ private static final long serialVersionUID = -3961477041290915687L;
/**
* Default constructor.
@@ -41,15 +41,15 @@
public Median() {
super(50.0);
}
-
+
/**
* Copy constructor, creates a new {@code Median} identical
* to the {@code original}
- *
+ *
* @param original the {@code Median} instance to copy
*/
public Median(Median original) {
super(original);
- }
+ }
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Min.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Min.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Min.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Min.java Sat Sep 5 17:36:48 2009
@@ -24,27 +24,27 @@
* Returns the minimum of the available values.
* <p>
* <ul>
- * <li>The result is <code>NaN</code> iff all values are <code>NaN</code>
+ * <li>The result is <code>NaN</code> iff all values are <code>NaN</code>
* (i.e. <code>NaN</code> values have no impact on the value of the statistic).</li>
- * <li>If any of the values equals <code>Double.NEGATIVE_INFINITY</code>,
+ * <li>If any of the values equals <code>Double.NEGATIVE_INFINITY</code>,
* the result is <code>Double.NEGATIVE_INFINITY.</code></li>
* </ul></p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class Min extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = -2941995784909003131L;
-
+ private static final long serialVersionUID = -2941995784909003131L;
+
/**Number of values that have been added */
private long n;
-
+
/**Current value of the statistic */
private double value;
@@ -55,17 +55,17 @@
n = 0;
value = Double.NaN;
}
-
+
/**
* Copy constructor, creates a new {@code Min} identical
* to the {@code original}
- *
+ *
* @param original the {@code Min} instance to copy
*/
public Min(Min original) {
copy(original, this);
}
-
+
/**
* {@inheritDoc}
*/
@@ -100,7 +100,7 @@
public long getN() {
return n;
}
-
+
/**
* Returns the minimum of the entries in the specified portion of
* the input array, or <code>Double.NaN</code> if the designated subarray
@@ -110,12 +110,12 @@
* the array index parameters are not valid.</p>
* <p>
* <ul>
- * <li>The result is <code>NaN</code> iff all values are <code>NaN</code>
+ * <li>The result is <code>NaN</code> iff all values are <code>NaN</code>
* (i.e. <code>NaN</code> values have no impact on the value of the statistic).</li>
- * <li>If any of the values equals <code>Double.NEGATIVE_INFINITY</code>,
+ * <li>If any of the values equals <code>Double.NEGATIVE_INFINITY</code>,
* the result is <code>Double.NEGATIVE_INFINITY.</code></li>
* </ul> </p>
- *
+ *
* @param values the input array
* @param begin index of the first array element to include
* @param length the number of elements to include
@@ -136,7 +136,7 @@
}
return min;
}
-
+
/**
* {@inheritDoc}
*/
@@ -146,11 +146,11 @@
copy(this, result);
return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source Min to copy
* @param dest Min to copy to
* @throws NullPointerException if either source or dest is null
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/rank/Percentile.java Sat Sep 5 17:36:48 2009
@@ -25,21 +25,21 @@
/**
* Provides percentile computation.
* <p>
- * There are several commonly used methods for estimating percentiles (a.k.a.
- * quantiles) based on sample data. For large samples, the different methods
+ * There are several commonly used methods for estimating percentiles (a.k.a.
+ * quantiles) based on sample data. For large samples, the different methods
* agree closely, but when sample sizes are small, different methods will give
* significantly different results. The algorithm implemented here works as follows:
* <ol>
- * <li>Let <code>n</code> be the length of the (sorted) array and
+ * <li>Let <code>n</code> be the length of the (sorted) array and
* <code>0 < p <= 100</code> be the desired percentile.</li>
- * <li>If <code> n = 1 </code> return the unique array element (regardless of
+ * <li>If <code> n = 1 </code> return the unique array element (regardless of
* the value of <code>p</code>); otherwise </li>
- * <li>Compute the estimated percentile position
+ * <li>Compute the estimated percentile position
* <code> pos = p * (n + 1) / 100</code> and the difference, <code>d</code>
* between <code>pos</code> and <code>floor(pos)</code> (i.e. the fractional
* part of <code>pos</code>). If <code>pos >= n</code> return the largest
* element in the array; otherwise</li>
- * <li>Let <code>lower</code> be the element in position
+ * <li>Let <code>lower</code> be the element in position
* <code>floor(pos)</code> in the array and let <code>upper</code> be the
* next element in the array. Return <code>lower + d * (upper - lower)</code>
* </li>
@@ -48,29 +48,29 @@
* To compute percentiles, the data must be (totally) ordered. Input arrays
* are copied and then sorted using {@link java.util.Arrays#sort(double[])}.
* The ordering used by <code>Arrays.sort(double[])</code> is the one determined
- * by {@link java.lang.Double#compareTo(Double)}. This ordering makes
- * <code>Double.NaN</code> larger than any other value (including
+ * by {@link java.lang.Double#compareTo(Double)}. This ordering makes
+ * <code>Double.NaN</code> larger than any other value (including
* <code>Double.POSITIVE_INFINITY</code>). Therefore, for example, the median
- * (50th percentile) of
+ * (50th percentile) of
* <code>{0, 1, 2, 3, 4, Double.NaN}</code> evaluates to <code>2.5.</code></p>
* <p>
- * Since percentile estimation usually involves interpolation between array
+ * Since percentile estimation usually involves interpolation between array
* elements, arrays containing <code>NaN</code> or infinite values will often
* result in <code>NaN<code> or infinite values returned.</p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class Percentile extends AbstractUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = -8091216485095130416L;
-
- /** Determines what percentile is computed when evaluate() is activated
+ private static final long serialVersionUID = -8091216485095130416L;
+
+ /** Determines what percentile is computed when evaluate() is activated
* with no quantile argument */
private double quantile = 0.0;
@@ -95,13 +95,13 @@
/**
* Copy constructor, creates a new {@code Percentile} identical
* to the {@code original}
- *
+ *
* @param original the {@code Percentile} instance to copy
*/
public Percentile(Percentile original) {
copy(original, this);
- }
-
+ }
+
/**
* Returns an estimate of the <code>p</code>th percentile of the values
* in the <code>values</code> array.
@@ -110,7 +110,7 @@
* state of this statistic.</p>
* <p>
* <ul>
- * <li>Returns <code>Double.NaN</code> if <code>values</code> has length
+ * <li>Returns <code>Double.NaN</code> if <code>values</code> has length
* <code>0</code></li>
* <li>Returns (for any value of <code>p</code>) <code>values[0]</code>
* if <code>values</code> has length <code>1</code></li>
@@ -121,11 +121,11 @@
* <p>
* See {@link Percentile} for a description of the percentile estimation
* algorithm used.</p>
- *
+ *
* @param values input array of values
* @param p the percentile value to compute
* @return the percentile value or Double.NaN if the array is empty
- * @throws IllegalArgumentException if <code>values</code> is null
+ * @throws IllegalArgumentException if <code>values</code> is null
* or p is invalid
*/
public double evaluate(final double[] values, final double p) {
@@ -140,22 +140,22 @@
* <p>
* <ul>
* <li>Returns <code>Double.NaN</code> if <code>length = 0</code></li>
- * <li>Returns (for any value of <code>quantile</code>)
+ * <li>Returns (for any value of <code>quantile</code>)
* <code>values[begin]</code> if <code>length = 1 </code></li>
* <li>Throws <code>IllegalArgumentException</code> if <code>values</code>
- * is null, or <code>start</code> or <code>length</code>
+ * is null, or <code>start</code> or <code>length</code>
* is invalid</li>
* </ul></p>
* <p>
* See {@link Percentile} for a description of the percentile estimation
* algorithm used.</p>
- *
+ *
* @param values the input array
* @param start index of the first array element to include
* @param length the number of elements to include
* @return the percentile value
* @throws IllegalArgumentException if the parameters are not valid
- *
+ *
*/
@Override
public double evaluate( final double[] values, final int start, final int length) {
@@ -176,14 +176,14 @@
* <li>Returns (for any value of <code>p</code>) <code>values[begin]</code>
* if <code>length = 1 </code></li>
* <li>Throws <code>IllegalArgumentException</code> if <code>values</code>
- * is null , <code>begin</code> or <code>length</code> is invalid, or
+ * is null , <code>begin</code> or <code>length</code> is invalid, or
* <code>p</code> is not a valid quantile value (p must be greater than 0
* and less than or equal to 100)</li>
* </ul></p>
* <p>
* See {@link Percentile} for a description of the percentile estimation
* algorithm used.</p>
- *
+ *
* @param values array of input values
* @param p the percentile to compute
* @param begin the first (0-based) element to include in the computation
@@ -192,7 +192,7 @@
* @throws IllegalArgumentException if the parameters are not valid or the
* input array is null
*/
- public double evaluate(final double[] values, final int begin,
+ public double evaluate(final double[] values, final int begin,
final int length, final double p) {
test(values, begin, length);
@@ -230,7 +230,7 @@
/**
* Returns the value of the quantile field (determines what percentile is
* computed when evaluate() is called with no quantile argument).
- *
+ *
* @return quantile
*/
public double getQuantile() {
@@ -238,10 +238,10 @@
}
/**
- * Sets the value of the quantile field (determines what percentile is
+ * Sets the value of the quantile field (determines what percentile is
* computed when evaluate() is called with no quantile argument).
- *
- * @param p a value between 0 < p <= 100
+ *
+ * @param p a value between 0 < p <= 100
* @throws IllegalArgumentException if p is not greater than 0 and less
* than or equal to 100
*/
@@ -252,7 +252,7 @@
}
quantile = p;
}
-
+
/**
* {@inheritDoc}
*/
@@ -262,11 +262,11 @@
copy(this, result);
return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source Percentile to copy
* @param dest Percentile to copy to
* @throws NullPointerException if either source or dest is null
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/Product.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/Product.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/Product.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/Product.java Sat Sep 5 17:36:48 2009
@@ -23,24 +23,24 @@
/**
* Returns the product of the available values.
* <p>
- * If there are no values in the dataset, or any of the values are
+ * If there are no values in the dataset, or any of the values are
* <code>NaN</code>, then <code>NaN</code> is returned.</p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class Product extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = 2824226005990582538L;
-
+ private static final long serialVersionUID = 2824226005990582538L;
+
/**The number of values that have been added */
private long n;
-
+
/**
* The current Running Product.
*/
@@ -131,7 +131,7 @@
* <p>Returns the weighted product of the entries in the specified portion of
* the input array, or <code>Double.NaN</code> if the designated subarray
* is empty.</p>
- *
+ *
* <p>Throws <code>IllegalArgumentException</code> if any of the following are true:
* <ul><li>the values array is null</li>
* <li>the weights array is null</li>
@@ -141,7 +141,7 @@
* <li>the weights array contains negative values</li>
* <li>the start and length arguments do not determine a valid array</li>
* </ul></p>
- *
+ *
* <p>Uses the formula, <pre>
* weighted product = ∏values[i]<sup>weights[i]</sup>
* </pre>
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/Sum.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/Sum.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/Sum.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/Sum.java Sat Sep 5 17:36:48 2009
@@ -23,24 +23,24 @@
/**
* Returns the sum of the available values.
* <p>
- * If there are no values in the dataset, or any of the values are
+ * If there are no values in the dataset, or any of the values are
* <code>NaN</code>, then <code>NaN</code> is returned.</p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class Sum extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = -8231831954703408316L;
-
+ private static final long serialVersionUID = -8231831954703408316L;
+
/** */
private long n;
-
+
/**
* The currently running sum.
*/
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/SumOfLogs.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/SumOfLogs.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/SumOfLogs.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/SumOfLogs.java Sat Sep 5 17:36:48 2009
@@ -21,39 +21,39 @@
import org.apache.commons.math.stat.descriptive.AbstractStorelessUnivariateStatistic;
/**
- * Returns the sum of the natural logs for this collection of values.
+ * Returns the sum of the natural logs for this collection of values.
* <p>
* Uses {@link java.lang.Math#log(double)} to compute the logs. Therefore,
* <ul>
* <li>If any of values are < 0, the result is <code>NaN.</code></li>
- * <li>If all values are non-negative and less than
+ * <li>If all values are non-negative and less than
* <code>Double.POSITIVE_INFINITY</code>, but at least one value is 0, the
* result is <code>Double.NEGATIVE_INFINITY.</code></li>
- * <li>If both <code>Double.POSITIVE_INFINITY</code> and
+ * <li>If both <code>Double.POSITIVE_INFINITY</code> and
* <code>Double.NEGATIVE_INFINITY</code> are among the values, the result is
* <code>NaN.</code></li>
* </ul></p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class SumOfLogs extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = -370076995648386763L;
+ private static final long serialVersionUID = -370076995648386763L;
/**Number of values that have been added */
private int n;
-
+
/**
* The currently running value
*/
private double value;
-
+
/**
* Create a SumOfLogs instance
*/
@@ -61,11 +61,11 @@
value = 0d;
n = 0;
}
-
+
/**
* Copy constructor, creates a new {@code SumOfLogs} identical
* to the {@code original}
- *
+ *
* @param original the {@code SumOfLogs} instance to copy
*/
public SumOfLogs(SumOfLogs original) {
@@ -99,7 +99,7 @@
public long getN() {
return n;
}
-
+
/**
* {@inheritDoc}
*/
@@ -117,11 +117,11 @@
* Throws <code>IllegalArgumentException</code> if the array is null.</p>
* <p>
* See {@link SumOfLogs}.</p>
- *
+ *
* @param values the input array
* @param begin index of the first array element to include
* @param length the number of elements to include
- * @return the sum of the natural logs of the values or Double.NaN if
+ * @return the sum of the natural logs of the values or Double.NaN if
* length = 0
* @throws IllegalArgumentException if the array is null or the array index
* parameters are not valid
@@ -137,7 +137,7 @@
}
return sumLog;
}
-
+
/**
* {@inheritDoc}
*/
@@ -147,11 +147,11 @@
copy(this, result);
return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source SumOfLogs to copy
* @param dest SumOfLogs to copy to
* @throws NullPointerException if either source or dest is null
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/SumOfSquares.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/SumOfSquares.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/SumOfSquares.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/descriptive/summary/SumOfSquares.java Sat Sep 5 17:36:48 2009
@@ -23,24 +23,24 @@
/**
* Returns the sum of the squares of the available values.
* <p>
- * If there are no values in the dataset, or any of the values are
+ * If there are no values in the dataset, or any of the values are
* <code>NaN</code>, then <code>NaN</code> is returned.</p>
* <p>
- * <strong>Note that this implementation is not synchronized.</strong> If
+ * <strong>Note that this implementation is not synchronized.</strong> If
* multiple threads access an instance of this class concurrently, and at least
- * one of the threads invokes the <code>increment()</code> or
+ * one of the threads invokes the <code>increment()</code> or
* <code>clear()</code> method, it must be synchronized externally.</p>
- *
+ *
* @version $Revision$ $Date$
*/
public class SumOfSquares extends AbstractStorelessUnivariateStatistic implements Serializable {
/** Serializable version identifier */
- private static final long serialVersionUID = 1460986908574398008L;
-
+ private static final long serialVersionUID = 1460986908574398008L;
+
/** */
private long n;
-
+
/**
* The currently running sumSq
*/
@@ -53,17 +53,17 @@
n = 0;
value = Double.NaN;
}
-
+
/**
* Copy constructor, creates a new {@code SumOfSquares} identical
* to the {@code original}
- *
+ *
* @param original the {@code SumOfSquares} instance to copy
*/
public SumOfSquares(SumOfSquares original) {
copy(original, this);
}
-
+
/**
* {@inheritDoc}
*/
@@ -91,7 +91,7 @@
public long getN() {
return n;
}
-
+
/**
* {@inheritDoc}
*/
@@ -107,7 +107,7 @@
* is empty.
* <p>
* Throws <code>IllegalArgumentException</code> if the array is null.</p>
- *
+ *
* @param values the input array
* @param begin index of the first array element to include
* @param length the number of elements to include
@@ -126,7 +126,7 @@
}
return sumSq;
}
-
+
/**
* {@inheritDoc}
*/
@@ -136,11 +136,11 @@
copy(this, result);
return result;
}
-
+
/**
* Copies source to dest.
* <p>Neither source nor dest can be null.</p>
- *
+ *
* @param source SumOfSquares to copy
* @param dest SumOfSquares to copy to
* @throws NullPointerException if either source or dest is null
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTest.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTest.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTest.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTest.java Sat Sep 5 17:36:48 2009
@@ -23,27 +23,27 @@
* <p>This interface handles only known distributions. If the distribution is
* unknown and should be provided by a sample, then the {@link UnknownDistributionChiSquareTest
* UnknownDistributionChiSquareTest} extended interface should be used instead.</p>
- * @version $Revision$ $Date$
+ * @version $Revision$ $Date$
*/
public interface ChiSquareTest {
-
+
/**
* Computes the <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm">
- * Chi-Square statistic</a> comparing <code>observed</code> and <code>expected</code>
- * frequency counts.
+ * Chi-Square statistic</a> comparing <code>observed</code> and <code>expected</code>
+ * frequency counts.
* <p>
* This statistic can be used to perform a Chi-Square test evaluating the null hypothesis that
* the observed counts follow the expected distribution.</p>
* <p>
* <strong>Preconditions</strong>: <ul>
- * <li>Expected counts must all be positive.
+ * <li>Expected counts must all be positive.
* </li>
- * <li>Observed counts must all be >= 0.
+ * <li>Observed counts must all be >= 0.
* </li>
* <li>The observed and expected arrays must have the same length and
- * their common length must be at least 2.
+ * their common length must be at least 2.
* </li></ul></p><p>
- * If any of the preconditions are not met, an
+ * If any of the preconditions are not met, an
* <code>IllegalArgumentException</code> is thrown.</p>
*
* @param observed array of observed frequency counts
@@ -51,30 +51,30 @@
* @return chiSquare statistic
* @throws IllegalArgumentException if preconditions are not met
*/
- double chiSquare(double[] expected, long[] observed)
+ double chiSquare(double[] expected, long[] observed)
throws IllegalArgumentException;
-
+
/**
* Returns the <i>observed significance level</i>, or <a href=
* "http://www.cas.lancs.ac.uk/glossary_v1.1/hyptest.html#pvalue">
- * p-value</a>, associated with a
+ * p-value</a>, associated with a
* <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm">
- * Chi-square goodness of fit test</a> comparing the <code>observed</code>
+ * Chi-square goodness of fit test</a> comparing the <code>observed</code>
* frequency counts to those in the <code>expected</code> array.
* <p>
- * The number returned is the smallest significance level at which one can reject
- * the null hypothesis that the observed counts conform to the frequency distribution
+ * The number returned is the smallest significance level at which one can reject
+ * the null hypothesis that the observed counts conform to the frequency distribution
* described by the expected counts.</p>
* <p>
* <strong>Preconditions</strong>: <ul>
- * <li>Expected counts must all be positive.
+ * <li>Expected counts must all be positive.
* </li>
- * <li>Observed counts must all be >= 0.
+ * <li>Observed counts must all be >= 0.
* </li>
* <li>The observed and expected arrays must have the same length and
- * their common length must be at least 2.
+ * their common length must be at least 2.
* </li></ul></p><p>
- * If any of the preconditions are not met, an
+ * If any of the preconditions are not met, an
* <code>IllegalArgumentException</code> is thrown.</p>
*
* @param observed array of observed frequency counts
@@ -83,31 +83,31 @@
* @throws IllegalArgumentException if preconditions are not met
* @throws MathException if an error occurs computing the p-value
*/
- double chiSquareTest(double[] expected, long[] observed)
+ double chiSquareTest(double[] expected, long[] observed)
throws IllegalArgumentException, MathException;
-
+
/**
* Performs a <a href="http://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm">
- * Chi-square goodness of fit test</a> evaluating the null hypothesis that the observed counts
- * conform to the frequency distribution described by the expected counts, with
+ * Chi-square goodness of fit test</a> evaluating the null hypothesis that the observed counts
+ * conform to the frequency distribution described by the expected counts, with
* significance level <code>alpha</code>. Returns true iff the null hypothesis can be rejected
* with 100 * (1 - alpha) percent confidence.
* <p>
* <strong>Example:</strong><br>
- * To test the hypothesis that <code>observed</code> follows
+ * To test the hypothesis that <code>observed</code> follows
* <code>expected</code> at the 99% level, use </p><p>
* <code>chiSquareTest(expected, observed, 0.01) </code></p>
* <p>
* <strong>Preconditions</strong>: <ul>
- * <li>Expected counts must all be positive.
+ * <li>Expected counts must all be positive.
* </li>
- * <li>Observed counts must all be >= 0.
+ * <li>Observed counts must all be >= 0.
* </li>
* <li>The observed and expected arrays must have the same length and
- * their common length must be at least 2.
+ * their common length must be at least 2.
* <li> <code> 0 < alpha < 0.5 </code>
* </li></ul></p><p>
- * If any of the preconditions are not met, an
+ * If any of the preconditions are not met, an
* <code>IllegalArgumentException</code> is thrown.</p>
*
* @param observed array of observed frequency counts
@@ -118,59 +118,59 @@
* @throws IllegalArgumentException if preconditions are not met
* @throws MathException if an error occurs performing the test
*/
- boolean chiSquareTest(double[] expected, long[] observed, double alpha)
+ boolean chiSquareTest(double[] expected, long[] observed, double alpha)
throws IllegalArgumentException, MathException;
-
+
/**
- * Computes the Chi-Square statistic associated with a
+ * Computes the Chi-Square statistic associated with a
* <a href="http://www.itl.nist.gov/div898/handbook/prc/section4/prc45.htm">
* chi-square test of independence</a> based on the input <code>counts</code>
- * array, viewed as a two-way table.
+ * array, viewed as a two-way table.
* <p>
- * The rows of the 2-way table are
+ * The rows of the 2-way table are
* <code>count[0], ... , count[count.length - 1] </code></p>
* <p>
* <strong>Preconditions</strong>: <ul>
- * <li>All counts must be >= 0.
+ * <li>All counts must be >= 0.
* </li>
* <li>The count array must be rectangular (i.e. all count[i] subarrays
- * must have the same length).
+ * must have the same length).
* </li>
* <li>The 2-way table represented by <code>counts</code> must have at
* least 2 columns and at least 2 rows.
* </li>
* </li></ul></p><p>
- * If any of the preconditions are not met, an
+ * If any of the preconditions are not met, an
* <code>IllegalArgumentException</code> is thrown.</p>
*
* @param counts array representation of 2-way table
* @return chiSquare statistic
* @throws IllegalArgumentException if preconditions are not met
*/
- double chiSquare(long[][] counts)
+ double chiSquare(long[][] counts)
throws IllegalArgumentException;
-
+
/**
* Returns the <i>observed significance level</i>, or <a href=
* "http://www.cas.lancs.ac.uk/glossary_v1.1/hyptest.html#pvalue">
- * p-value</a>, associated with a
+ * p-value</a>, associated with a
* <a href="http://www.itl.nist.gov/div898/handbook/prc/section4/prc45.htm">
* chi-square test of independence</a> based on the input <code>counts</code>
- * array, viewed as a two-way table.
+ * array, viewed as a two-way table.
* <p>
- * The rows of the 2-way table are
+ * The rows of the 2-way table are
* <code>count[0], ... , count[count.length - 1] </code></p>
* <p>
* <strong>Preconditions</strong>: <ul>
- * <li>All counts must be >= 0.
+ * <li>All counts must be >= 0.
* </li>
- * <li>The count array must be rectangular (i.e. all count[i] subarrays must have the same length).
+ * <li>The count array must be rectangular (i.e. all count[i] subarrays must have the same length).
* </li>
* <li>The 2-way table represented by <code>counts</code> must have at least 2 columns and
* at least 2 rows.
* </li>
* </li></ul></p><p>
- * If any of the preconditions are not met, an
+ * If any of the preconditions are not met, an
* <code>IllegalArgumentException</code> is thrown.</p>
*
* @param counts array representation of 2-way table
@@ -178,17 +178,17 @@
* @throws IllegalArgumentException if preconditions are not met
* @throws MathException if an error occurs computing the p-value
*/
- double chiSquareTest(long[][] counts)
+ double chiSquareTest(long[][] counts)
throws IllegalArgumentException, MathException;
-
+
/**
* Performs a <a href="http://www.itl.nist.gov/div898/handbook/prc/section4/prc45.htm">
- * chi-square test of independence</a> evaluating the null hypothesis that the classifications
+ * chi-square test of independence</a> evaluating the null hypothesis that the classifications
* represented by the counts in the columns of the input 2-way table are independent of the rows,
* with significance level <code>alpha</code>. Returns true iff the null hypothesis can be rejected
* with 100 * (1 - alpha) percent confidence.
* <p>
- * The rows of the 2-way table are
+ * The rows of the 2-way table are
* <code>count[0], ... , count[count.length - 1] </code></p>
* <p>
* <strong>Example:</strong><br>
@@ -198,15 +198,15 @@
* <code>chiSquareTest(counts, 0.01) </code></p>
* <p>
* <strong>Preconditions</strong>: <ul>
- * <li>All counts must be >= 0.
+ * <li>All counts must be >= 0.
* </li>
- * <li>The count array must be rectangular (i.e. all count[i] subarrays must have the same length).
+ * <li>The count array must be rectangular (i.e. all count[i] subarrays must have the same length).
* </li>
* <li>The 2-way table represented by <code>counts</code> must have at least 2 columns and
* at least 2 rows.
* </li>
* </li></ul></p><p>
- * If any of the preconditions are not met, an
+ * If any of the preconditions are not met, an
* <code>IllegalArgumentException</code> is thrown.</p>
*
* @param counts array representation of 2-way table
@@ -216,7 +216,7 @@
* @throws IllegalArgumentException if preconditions are not met
* @throws MathException if an error occurs performing the test
*/
- boolean chiSquareTest(long[][] counts, double alpha)
+ boolean chiSquareTest(long[][] counts, double alpha)
throws IllegalArgumentException, MathException;
}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/ChiSquareTestImpl.java Sat Sep 5 17:36:48 2009
@@ -31,9 +31,9 @@
/** Distribution used to compute inference statistics. */
private ChiSquaredDistribution distribution;
-
+
/**
- * Construct a ChiSquareTestImpl
+ * Construct a ChiSquareTestImpl
*/
public ChiSquareTestImpl() {
this(new ChiSquaredDistributionImpl(1.0));
@@ -51,10 +51,10 @@
}
/**
* {@inheritDoc}
- * <p><strong>Note: </strong>This implementation rescales the
+ * <p><strong>Note: </strong>This implementation rescales the
* <code>expected</code> array if necessary to ensure that the sum of the
* expected and observed counts are equal.</p>
- *
+ *
* @param observed array of observed frequency counts
* @param expected array of expected frequency counts
* @return chi-square test statistic
@@ -102,10 +102,10 @@
/**
* {@inheritDoc}
- * <p><strong>Note: </strong>This implementation rescales the
+ * <p><strong>Note: </strong>This implementation rescales the
* <code>expected</code> array if necessary to ensure that the sum of the
* expected and observed counts are equal.</p>
- *
+ *
* @param observed array of observed frequency counts
* @param expected array of expected frequency counts
* @return p-value
@@ -121,10 +121,10 @@
/**
* {@inheritDoc}
- * <p><strong>Note: </strong>This implementation rescales the
+ * <p><strong>Note: </strong>This implementation rescales the
* <code>expected</code> array if necessary to ensure that the sum of the
* expected and observed counts are equal.</p>
- *
+ *
* @param observed array of observed frequency counts
* @param expected array of expected frequency counts
* @param alpha significance level of the test
@@ -133,7 +133,7 @@
* @throws IllegalArgumentException if preconditions are not met
* @throws MathException if an error occurs performing the test
*/
- public boolean chiSquareTest(double[] expected, long[] observed,
+ public boolean chiSquareTest(double[] expected, long[] observed,
double alpha) throws IllegalArgumentException, MathException {
if ((alpha <= 0) || (alpha > 0.5)) {
throw MathRuntimeException.createIllegalArgumentException(
@@ -142,18 +142,18 @@
}
return (chiSquareTest(expected, observed) < alpha);
}
-
+
/**
* @param counts array representation of 2-way table
* @return chi-square test statistic
* @throws IllegalArgumentException if preconditions are not met
*/
public double chiSquare(long[][] counts) throws IllegalArgumentException {
-
+
checkArray(counts);
int nRows = counts.length;
int nCols = counts[0].length;
-
+
// compute row, column and total sums
double[] rowSum = new double[nRows];
double[] colSum = new double[nCols];
@@ -165,17 +165,17 @@
total += counts[row][col];
}
}
-
+
// compute expected counts and chi-square
double sumSq = 0.0d;
double expected = 0.0d;
for (int row = 0; row < nRows; row++) {
for (int col = 0; col < nCols; col++) {
expected = (rowSum[row] * colSum[col]) / total;
- sumSq += ((counts[row][col] - expected) *
- (counts[row][col] - expected)) / expected;
+ sumSq += ((counts[row][col] - expected) *
+ (counts[row][col] - expected)) / expected;
}
- }
+ }
return sumSq;
}
@@ -210,7 +210,7 @@
}
return (chiSquareTest(counts) < alpha);
}
-
+
/**
* @param observed1 array of observed frequency counts of the first data set
* @param observed2 array of observed frequency counts of the second data set
@@ -220,7 +220,7 @@
*/
public double chiSquareDataSetsComparison(long[] observed1, long[] observed2)
throws IllegalArgumentException {
-
+
// Make sure lengths are same
if (observed1.length < 2) {
throw MathRuntimeException.createIllegalArgumentException(
@@ -244,16 +244,16 @@
double weight = 0.0;
for (int i = 0; i < observed1.length; i++) {
countSum1 += observed1[i];
- countSum2 += observed2[i];
+ countSum2 += observed2[i];
}
// Ensure neither sample is uniformly 0
if (countSum1 == 0) {
throw MathRuntimeException.createIllegalArgumentException(
- "observed counts are all 0 in first observed array");
+ "observed counts are all 0 in first observed array");
}
if (countSum2 == 0) {
throw MathRuntimeException.createIllegalArgumentException(
- "observed counts are all 0 in second observed array");
+ "observed counts are all 0 in second observed array");
}
// Compare and compute weight only if different
unequalCounts = (countSum1 != countSum2);
@@ -322,34 +322,34 @@
* Checks to make sure that the input long[][] array is rectangular,
* has at least 2 rows and 2 columns, and has all non-negative entries,
* throwing IllegalArgumentException if any of these checks fail.
- *
+ *
* @param in input 2-way table to check
* @throws IllegalArgumentException if the array is not valid
*/
private void checkArray(long[][] in) throws IllegalArgumentException {
-
+
if (in.length < 2) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid row dimension: {0} (must be at least 2)",
in.length);
}
-
+
if (in[0].length < 2) {
throw MathRuntimeException.createIllegalArgumentException(
"invalid column dimension: {0} (must be at least 2)",
in[0].length);
- }
-
+ }
+
checkRectangular(in);
checkNonNegative(in);
-
+
}
-
+
//--------------------- Private array methods -- should find a utility home for these
-
+
/**
* Throws IllegalArgumentException if the input array is not rectangular.
- *
+ *
* @param in array to be tested
* @throws NullPointerException if input array is null
* @throws IllegalArgumentException if input array is not rectangular
@@ -361,12 +361,12 @@
"some rows have length {0} while others have length {1}",
in[i].length, in[0].length);
}
- }
+ }
}
-
+
/**
* Check all entries of the input array are > 0.
- *
+ *
* @param in array to be tested
* @exception IllegalArgumentException if one entry is not positive
*/
@@ -379,10 +379,10 @@
}
}
}
-
+
/**
* Check all entries of the input array are >= 0.
- *
+ *
* @param in array to be tested
* @exception IllegalArgumentException if one entry is negative
*/
@@ -395,10 +395,10 @@
}
}
}
-
+
/**
* Check all entries of the input array are >= 0.
- *
+ *
* @param in array to be tested
* @exception IllegalArgumentException if one entry is negative
*/
@@ -413,10 +413,10 @@
}
}
}
-
+
/**
* Modify the distribution used to compute inference statistics.
- *
+ *
* @param value
* the new distribution
* @since 1.2
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/OneWayAnova.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/OneWayAnova.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/OneWayAnova.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/OneWayAnova.java Sat Sep 5 17:36:48 2009
@@ -20,7 +20,7 @@
import java.util.Collection;
/**
- * An interface for one-way ANOVA (analysis of variance).
+ * An interface for one-way ANOVA (analysis of variance).
*
* <p> Tests for differences between two or more categories of univariate data
* (for example, the body mass index of accountants, lawyers, doctors and
@@ -29,13 +29,13 @@
* </p>
*
* @since 1.2
- * @version $Revision$ $Date$
+ * @version $Revision$ $Date$
*/
public interface OneWayAnova {
/**
* Computes the ANOVA F-value for a collection of <code>double[]</code>
* arrays.
- *
+ *
* <p><strong>Preconditions</strong>: <ul>
* <li>The categoryData <code>Collection</code> must contain
* <code>double[]</code> arrays.</li>
@@ -77,7 +77,7 @@
/**
* Performs an ANOVA test, evaluating the null hypothesis that there
* is no difference among the means of the data categories.
- *
+ *
* <p><strong>Preconditions</strong>: <ul>
* <li>The categoryData <code>Collection</code> must contain
* <code>double[]</code> arrays.</li>
@@ -90,7 +90,7 @@
* @param categoryData <code>Collection</code> of <code>double[]</code>
* arrays each containing data for one category
* @param alpha significance level of the test
- * @return true if the null hypothesis can be rejected with
+ * @return true if the null hypothesis can be rejected with
* confidence 1 - alpha
* @throws IllegalArgumentException if the preconditions are not met
* @throws MathException if the statistic can not be computed do to a
@@ -99,4 +99,4 @@
public boolean anovaTest(Collection<double[]> categoryData, double alpha)
throws IllegalArgumentException, MathException;
-}
\ No newline at end of file
+}
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/OneWayAnovaImpl.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/OneWayAnovaImpl.java?rev=811685&r1=811684&r2=811685&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/OneWayAnovaImpl.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/stat/inference/OneWayAnovaImpl.java Sat Sep 5 17:36:48 2009
@@ -29,12 +29,12 @@
/**
* Implements one-way ANOVA statistics defined in the {@link OneWayAnovaImpl}
* interface.
- *
- * <p>Uses the
+ *
+ * <p>Uses the
* {@link org.apache.commons.math.distribution.FDistribution
* commons-math F Distribution implementation} to estimate exact p-values.</p>
*
- * <p>This implementation is based on a description at
+ * <p>This implementation is based on a description at
* http://faculty.vassar.edu/lowry/ch13pt1.html</p>
* <pre>
* Abbreviations: bg = between groups,
@@ -52,10 +52,10 @@
*/
public OneWayAnovaImpl() {
}
-
+
/**
* {@inheritDoc}<p>
- * This implementation computes the F statistic using the definitional
+ * This implementation computes the F statistic using the definitional
* formula<pre>
* F = msbg/mswg</pre>
* where<pre>
@@ -111,7 +111,7 @@
/**
* This method actually does the calculations (except P-value).
- *
+ *
* @param categoryData <code>Collection</code> of <code>double[]</code>
* arrays each containing data for one category
* @return computed AnovaStats
@@ -128,7 +128,7 @@
"two or more categories required, got {0}",
categoryData.size());
}
-
+
// check if each category has enough data and all is double[]
for (double[] array : categoryData) {
if (array.length <= 1) {
@@ -143,7 +143,7 @@
Sum totsum = new Sum();
SumOfSquares totsumsq = new SumOfSquares();
int totnum = 0;
-
+
for (double[] data : categoryData) {
Sum sum = new Sum();
@@ -167,7 +167,7 @@
double ss = sumsq.getResult() - sum.getResult() * sum.getResult() / num;
sswg += ss;
}
- double sst = totsumsq.getResult() - totsum.getResult() *
+ double sst = totsumsq.getResult() - totsum.getResult() *
totsum.getResult()/totnum;
double ssbg = sst - sswg;
int dfbg = categoryData.size() - 1;
@@ -178,7 +178,7 @@
return new AnovaStats(dfbg, dfwg, F);
}
- /**
+ /**
Convenience class to pass dfbg,dfwg,F values around within AnovaImpl.
No get/set methods provided.
*/
@@ -206,4 +206,4 @@
}
}
-}
\ No newline at end of file
+}