diff --git a/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Max.java b/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Max.java index 92181c45b..a87c48f9a 100644 --- a/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Max.java +++ b/src/main/java/org/apache/commons/math3/stat/descriptive/rank/Max.java @@ -18,6 +18,7 @@ package org.apache.commons.math3.stat.descriptive.rank; 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.MathUtils; @@ -63,8 +64,9 @@ public class Max extends AbstractStorelessUnivariateStatistic implements Seriali * to the {@code original} * * @param original the {@code Max} instance to copy + * @throws NullArgumentException if original is null */ - public Max(Max original) { + public Max(Max original) throws NullArgumentException { copy(original, this); } @@ -108,7 +110,7 @@ public class Max extends AbstractStorelessUnivariateStatistic implements Seriali * the input array, or Double.NaN if the designated subarray * is empty. *

- * Throws IllegalArgumentException if the array is null or + * Throws MathIllegalArgumentException if the array is null or * the array index parameters are not valid.

*

*

*

* See {@link Percentile} for a description of the percentile estimation @@ -215,11 +222,12 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa * @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 + * @throws MathIllegalArgumentException if the parameters are not valid * */ @Override - public double evaluate( final double[] values, final int start, final int length) { + public double evaluate(final double[] values, final int start, final int length) + throws MathIllegalArgumentException { return evaluate(values, start, length, quantile); } @@ -236,7 +244,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa *

  • Returns Double.NaN if length = 0
  • *
  • Returns (for any value of p) values[begin] * if length = 1
  • - *
  • Throws IllegalArgumentException if values + *
  • Throws MathIllegalArgumentException if values * is null , begin or length is invalid, or * p is not a valid quantile value (p must be greater than 0 * and less than or equal to 100)
  • @@ -250,16 +258,17 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa * @param begin the first (0-based) element to include in the computation * @param length the number of array elements to include * @return the percentile value - * @throws IllegalArgumentException if the parameters are not valid or the + * @throws MathIllegalArgumentException if the parameters are not valid or the * input array is null */ public double evaluate(final double[] values, final int begin, - final int length, final double p) { + final int length, final double p) throws MathIllegalArgumentException { test(values, begin, length); if ((p > 100) || (p <= 0)) { - throw new OutOfRangeException(LocalizedFormats.OUT_OF_BOUNDS_QUANTILE_VALUE, p, 0, 100); + throw new OutOfRangeException( + LocalizedFormats.OUT_OF_BOUNDS_QUANTILE_VALUE, p, 0, 100); } if (length == 0) { return Double.NaN; @@ -457,12 +466,13 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa * computed when evaluate() is called with no quantile argument). * * @param p a value between 0 < p <= 100 - * @throws IllegalArgumentException if p is not greater than 0 and less + * @throws MathIllegalArgumentException if p is not greater than 0 and less * than or equal to 100 */ - public void setQuantile(final double p) { + public void setQuantile(final double p) throws MathIllegalArgumentException { if (p <= 0 || p > 100) { - throw new OutOfRangeException(LocalizedFormats.OUT_OF_BOUNDS_QUANTILE_VALUE, p, 0, 100); + throw new OutOfRangeException( + LocalizedFormats.OUT_OF_BOUNDS_QUANTILE_VALUE, p, 0, 100); } quantile = p; } @@ -473,6 +483,7 @@ public class Percentile extends AbstractUnivariateStatistic implements Serializa @Override public Percentile copy() { Percentile result = new Percentile(); + //No try-catch or advertised exception because args are guaranteed non-null copy(this, result); return result; }