commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pste...@apache.org
Subject svn commit: r1382332 [2/2] - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat: ./ descriptive/ descriptive/moment/
Date Sat, 08 Sep 2012 17:27:48 GMT
Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Skewness.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Skewness.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Skewness.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Skewness.java
Sat Sep  8 17:27:47 2012
@@ -18,6 +18,7 @@ package org.apache.commons.math3.stat.de
 
 import java.io.Serializable;
 
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic;
 import org.apache.commons.math3.util.FastMath;
@@ -78,13 +79,17 @@ public class Skewness extends AbstractSt
      * to the {@code original}
      *
      * @param original the {@code Skewness} instance to copy
+     * @throws NullArgumentException if original is null
      */
-    public Skewness(Skewness original) {
+    public Skewness(Skewness original) throws NullArgumentException {
         copy(original, this);
     }
 
     /**
      * {@inheritDoc}
+     * <p>Note that when {@link #Skewness(ThirdMoment)} is used to
+     * create a Skewness, this method does nothing. In that case, the
+     * ThirdMoment should be incremented directly.</p>
      */
     @Override
     public void increment(final double d) {
@@ -146,12 +151,12 @@ public class Skewness extends AbstractSt
      * @param length the number of elements to include
      * @return the skewness of the values or Double.NaN if length is less than
      * 3
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      *  parameters are not valid
      */
     @Override
     public double evaluate(final double[] values,final int begin,
-            final int length) {
+            final int length) throws MathIllegalArgumentException {
 
         // Initialize the skewness
         double skew = Double.NaN;
@@ -195,6 +200,7 @@ public class Skewness extends AbstractSt
     @Override
     public Skewness copy() {
         Skewness result = new Skewness();
+        // No try-catch or advertised exception because args are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/StandardDeviation.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/StandardDeviation.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/StandardDeviation.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/StandardDeviation.java
Sat Sep  8 17:27:47 2012
@@ -18,6 +18,7 @@ package org.apache.commons.math3.stat.de
 
 import java.io.Serializable;
 
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic;
 import org.apache.commons.math3.util.FastMath;
@@ -142,16 +143,16 @@ public class StandardDeviation extends A
      * <p>
      * Returns 0 for a single-value (i.e. length = 1) sample.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if the array is null.</p>
+     * Throws <code>MathIllegalArgumentException</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
+     * @throws MathIllegalArgumentException if the array is null
      */
     @Override
-    public double evaluate(final double[] values)  {
+    public double evaluate(final double[] values) throws MathIllegalArgumentException  {
         return FastMath.sqrt(variance.evaluate(values));
     }
 
@@ -162,7 +163,7 @@ public class StandardDeviation extends A
      * <p>
      * Returns 0 for a single-value (i.e. length = 1) sample. </p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if the array is null.</p>
+     * Throws <code>MathIllegalArgumentException</code> if the array is null.</p>
      * <p>
      * Does not change the internal state of the statistic.</p>
      *
@@ -170,11 +171,12 @@ public class StandardDeviation extends A
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the standard deviation of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      *  parameters are not valid
      */
     @Override
-    public double evaluate(final double[] values, final int begin, final int length)  {
+    public double evaluate(final double[] values, final int begin, final int length)
+    throws MathIllegalArgumentException  {
        return FastMath.sqrt(variance.evaluate(values, begin, length));
     }
 
@@ -199,11 +201,11 @@ public class StandardDeviation extends A
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the standard deviation of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      *  parameters are not valid
      */
     public double evaluate(final double[] values, final double mean,
-            final int begin, final int length)  {
+            final int begin, final int length) throws MathIllegalArgumentException  {
         return FastMath.sqrt(variance.evaluate(values, mean, begin, length));
     }
 
@@ -219,16 +221,17 @@ public class StandardDeviation extends A
      * is supplied only to save computation when the mean has already been
      * computed.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if the array is null.</p>
+     * Throws <code>MathIllegalArgumentException</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
-     * @throws IllegalArgumentException if the array is null
+     * @throws MathIllegalArgumentException if the array is null
      */
-    public double evaluate(final double[] values, final double mean)  {
+    public double evaluate(final double[] values, final double mean)
+    throws MathIllegalArgumentException  {
         return FastMath.sqrt(variance.evaluate(values, mean));
     }
 
@@ -252,6 +255,7 @@ public class StandardDeviation extends A
     @Override
     public StandardDeviation copy() {
         StandardDeviation result = new StandardDeviation();
+        // No try-catch or advertised exception because args are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/ThirdMoment.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/ThirdMoment.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/ThirdMoment.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/ThirdMoment.java
Sat Sep  8 17:27:47 2012
@@ -76,8 +76,9 @@ class ThirdMoment extends SecondMoment i
      * to the {@code original}
      *
      * @param original the {@code ThirdMoment} instance to copy
+     * @throws NullArgumentException if orginal is null
      */
-    public ThirdMoment(ThirdMoment original) {
+    public ThirdMoment(ThirdMoment original) throws NullArgumentException {
         copy(original, this);
     }
 
@@ -121,6 +122,7 @@ class ThirdMoment extends SecondMoment i
     @Override
     public ThirdMoment copy() {
         ThirdMoment result = new ThirdMoment();
+        // No try-catch or advertised exception because args are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Variance.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Variance.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Variance.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/Variance.java
Sat Sep  8 17:27:47 2012
@@ -18,6 +18,7 @@ package org.apache.commons.math3.stat.de
 
 import java.io.Serializable;
 
+import org.apache.commons.math3.exception.MathIllegalArgumentException;
 import org.apache.commons.math3.exception.NullArgumentException;
 import org.apache.commons.math3.exception.util.LocalizedFormats;
 import org.apache.commons.math3.stat.descriptive.WeightedEvaluation;
@@ -146,8 +147,9 @@ public class Variance extends AbstractSt
      * to the {@code original}
      *
      * @param original the {@code Variance} instance to copy
+     * @throws NullArgumentException if original is null
      */
-    public Variance(Variance original) {
+    public Variance(Variance original) throws NullArgumentException {
         copy(original, this);
     }
 
@@ -214,16 +216,16 @@ public class Variance extends AbstractSt
      * <p>
      * Returns 0 for a single-value (i.e. length = 1) sample.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if the array is null.</p>
+     * Throws <code>MathIllegalArgumentException</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 variance of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the array is null
+     * @throws MathIllegalArgumentException if the array is null
      */
     @Override
-    public double evaluate(final double[] values) {
+    public double evaluate(final double[] values) throws MathIllegalArgumentException {
         if (values == null) {
             throw new NullArgumentException(LocalizedFormats.INPUT_ARRAY);
         }
@@ -241,17 +243,18 @@ public class Variance extends AbstractSt
      * <p>
      * Does not change the internal state of the statistic.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if the array is null.</p>
+     * Throws <code>MathIllegalArgumentException</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
      * @return the variance of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      *  parameters are not valid
      */
     @Override
-    public double evaluate(final double[] values, final int begin, final int length) {
+    public double evaluate(final double[] values, final int begin, final int length)
+    throws MathIllegalArgumentException {
 
         double var = Double.NaN;
 
@@ -300,18 +303,18 @@ public class Variance extends AbstractSt
      * <p>
      * Does not change the internal state of the statistic.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if either array is null.</p>
+     * Throws <code>MathIllegalArgumentException</code> if either array is null.</p>
      *
      * @param values the input array
      * @param weights the weights array
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the weighted variance of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the parameters are not valid
+     * @throws MathIllegalArgumentException if the parameters are not valid
      * @since 2.1
      */
     public double evaluate(final double[] values, final double[] weights,
-                           final int begin, final int length) {
+                           final int begin, final int length) throws MathIllegalArgumentException
{
 
         double var = Double.NaN;
 
@@ -347,7 +350,7 @@ public class Variance extends AbstractSt
      * <p>
      * Returns 0 for a single-value (i.e. length = 1) sample.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if any of the following are
true:
+     * Throws <code>MathIllegalArgumentException</code> if any of the following
are true:
      * <ul><li>the values array is null</li>
      *     <li>the weights array is null</li>
      *     <li>the weights array does not have the same length as the values array</li>
@@ -358,15 +361,16 @@ public class Variance extends AbstractSt
      * <p>
      * Does not change the internal state of the statistic.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if either array is null.</p>
+     * Throws <code>MathIllegalArgumentException</code> if either array is null.</p>
      *
      * @param values the input array
      * @param weights the weights array
      * @return the weighted variance of the values
-     * @throws IllegalArgumentException if the parameters are not valid
+     * @throws MathIllegalArgumentException if the parameters are not valid
      * @since 2.1
      */
-    public double evaluate(final double[] values, final double[] weights) {
+    public double evaluate(final double[] values, final double[] weights)
+    throws MathIllegalArgumentException {
         return evaluate(values, weights, 0, values.length);
     }
 
@@ -384,7 +388,7 @@ public class Variance extends AbstractSt
      * <p>
      * Returns 0 for a single-value (i.e. length = 1) sample.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if the array is null.</p>
+     * Throws <code>MathIllegalArgumentException</code> if the array is null.</p>
      * <p>
      * Does not change the internal state of the statistic.</p>
      *
@@ -393,11 +397,11 @@ public class Variance extends AbstractSt
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the variance of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the array is null or the array index
+     * @throws MathIllegalArgumentException if the array is null or the array index
      *  parameters are not valid
      */
     public double evaluate(final double[] values, final double mean,
-            final int begin, final int length) {
+            final int begin, final int length) throws MathIllegalArgumentException {
 
         double var = Double.NaN;
 
@@ -440,16 +444,16 @@ public class Variance extends AbstractSt
      * <p>
      * Returns 0 for a single-value (i.e. length = 1) sample.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if the array is null.</p>
+     * Throws <code>MathIllegalArgumentException</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 variance of the values or Double.NaN if the array is empty
-     * @throws IllegalArgumentException if the array is null
+     * @throws MathIllegalArgumentException if the array is null
      */
-    public double evaluate(final double[] values, final double mean) {
+    public double evaluate(final double[] values, final double mean) throws MathIllegalArgumentException
{
         return evaluate(values, mean, 0, values.length);
     }
 
@@ -477,7 +481,7 @@ public class Variance extends AbstractSt
      * <p>
      * Returns 0 for a single-value (i.e. length = 1) sample.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if any of the following are
true:
+     * Throws <code>MathIllegalArgumentException</code> if any of the following
are true:
      * <ul><li>the values array is null</li>
      *     <li>the weights array is null</li>
      *     <li>the weights array does not have the same length as the values array</li>
@@ -495,11 +499,12 @@ public class Variance extends AbstractSt
      * @param begin index of the first array element to include
      * @param length the number of elements to include
      * @return the variance of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the parameters are not valid
+     * @throws MathIllegalArgumentException if the parameters are not valid
      * @since 2.1
      */
     public double evaluate(final double[] values, final double[] weights,
-                           final double mean, final int begin, final int length) {
+    final double mean, final int begin, final int length)
+    throws MathIllegalArgumentException {
 
         double var = Double.NaN;
 
@@ -554,7 +559,7 @@ public class Variance extends AbstractSt
      * <p>
      * Returns 0 for a single-value (i.e. length = 1) sample.</p>
      * <p>
-     * Throws <code>IllegalArgumentException</code> if any of the following are
true:
+     * Throws <code>MathIllegalArgumentException</code> if any of the following
are true:
      * <ul><li>the values array is null</li>
      *     <li>the weights array is null</li>
      *     <li>the weights array does not have the same length as the values array</li>
@@ -569,10 +574,11 @@ public class Variance extends AbstractSt
      * @param weights the weights array
      * @param mean the precomputed weighted mean value
      * @return the variance of the values or Double.NaN if length = 0
-     * @throws IllegalArgumentException if the parameters are not valid
+     * @throws MathIllegalArgumentException if the parameters are not valid
      * @since 2.1
      */
-    public double evaluate(final double[] values, final double[] weights, final double mean)
{
+    public double evaluate(final double[] values, final double[] weights, final double mean)
+    throws MathIllegalArgumentException {
         return evaluate(values, weights, mean, 0, values.length);
     }
 
@@ -596,6 +602,7 @@ public class Variance extends AbstractSt
     @Override
     public Variance copy() {
         Variance result = new Variance();
+        // No try-catch or advertised exception because parameters are guaranteed non-null
         copy(this, result);
         return result;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/VectorialMean.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/VectorialMean.java?rev=1382332&r1=1382331&r2=1382332&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/VectorialMean.java
(original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/stat/descriptive/moment/VectorialMean.java
Sat Sep  8 17:27:47 2012
@@ -49,7 +49,7 @@ public class VectorialMean implements Se
      * @param v vector to add
      * @throws DimensionMismatchException if the vector does not have the right dimension
      */
-    public void increment(double[] v) {
+    public void increment(double[] v) throws DimensionMismatchException {
         if (v.length != means.length) {
             throw new DimensionMismatchException(v.length, means.length);
         }



Mime
View raw message