Class Arguments
- java.lang.Object
-
- org.apache.commons.statistics.inference.Arguments
-
final class Arguments extends java.lang.Object
Argument validation methods.- Since:
- 1.1
-
-
Field Summary
Fields Modifier and Type Field Description private static int
TWO
Two.
-
Constructor Summary
Constructors Modifier Constructor Description private
Arguments()
No instances.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static void
checkCategoriesRequiredSize(int size, int required)
Check the categories size is the minimum required,size >= required
.(package private) static double
checkFinite(double v)
Check that the value is finite.(package private) static void
checkNonNaN(double[] values)
Check that all values are notDouble.NaN
.(package private) static void
checkNonNegative(double v)
Check that the value is>= 0
.(package private) static int
checkNonNegative(int v)
Check that the value is>= 0
.(package private) static void
checkNonNegative(long[] values)
Check that all values are>= 0
.(package private) static void
checkNonNegative(long[][] values)
Check that all values are>= 0
.(package private) static <E extends java.lang.Enum<E>>
EcheckOption(E v, java.util.Set<E> allowed)
Check the option is allowed.(package private) static void
checkRectangular(long[][] array)
Checks if the input array is rectangular.(package private) static void
checkSignificance(double alpha)
Check the significance level is in the correct range.(package private) static double
checkStrictlyPositive(double v)
Check that value is> 0
.(package private) static void
checkStrictlyPositive(double[] values)
Check that all values are> 0
.(package private) static int
checkStrictlyPositive(int v)
Check that value is> 0
.(package private) static void
checkTable(int[][] table)
Check the input is a 2-by-2 contingency table.(package private) static void
checkValuesRequiredSize(int size, int required)
Check the values size is the minimum required,size >= required
.(package private) static void
checkValuesSizeMatch(int size1, int size2)
Check the values sizes are equal,size1 == size2
.
-
-
-
Field Detail
-
TWO
private static final int TWO
Two.- See Also:
- Constant Field Values
-
-
Method Detail
-
checkSignificance
static void checkSignificance(double alpha)
Check the significance level is in the correct range.- Parameters:
alpha
- Significance level of the test.- Throws:
java.lang.IllegalArgumentException
- ifalpha
is not in the range(0, 0.5]
-
checkNonNegative
static int checkNonNegative(int v)
Check that the value is>= 0
.- Parameters:
v
- Value to be tested.- Returns:
- the value
- Throws:
java.lang.IllegalArgumentException
- if the value is less than 0.
-
checkNonNegative
static void checkNonNegative(double v)
Check that the value is>= 0
.- Parameters:
v
- Value to be tested.- Throws:
java.lang.IllegalArgumentException
- if the value is less than 0.
-
checkNonNegative
static void checkNonNegative(long[] values)
Check that all values are>= 0
.- Parameters:
values
- Values to be tested.- Throws:
java.lang.IllegalArgumentException
- if any values are less than 0.
-
checkNonNegative
static void checkNonNegative(long[][] values)
Check that all values are>= 0
.- Parameters:
values
- Values to be tested.- Throws:
java.lang.IllegalArgumentException
- if any values are less than 0.
-
checkStrictlyPositive
static int checkStrictlyPositive(int v)
Check that value is> 0
.- Parameters:
v
- Value to be tested.- Returns:
- the value
- Throws:
java.lang.IllegalArgumentException
- if the value is not strictly positive.
-
checkStrictlyPositive
static double checkStrictlyPositive(double v)
Check that value is> 0
.- Parameters:
v
- Value to be tested.- Returns:
- the value
- Throws:
java.lang.IllegalArgumentException
- if the value is not strictly positive.
-
checkStrictlyPositive
static void checkStrictlyPositive(double[] values)
Check that all values are> 0
.- Parameters:
values
- Values to be tested.- Throws:
java.lang.IllegalArgumentException
- if any values are not strictly positive.
-
checkFinite
static double checkFinite(double v)
Check that the value is finite.- Parameters:
v
- Value to be tested.- Returns:
- the value
- Throws:
java.lang.IllegalArgumentException
- if the value is not finite.
-
checkNonNaN
static void checkNonNaN(double[] values)
Check that all values are notDouble.NaN
.- Parameters:
values
- Values to be tested.- Throws:
java.lang.IllegalArgumentException
- if any values are NaN.
-
checkRectangular
static void checkRectangular(long[][] array)
Checks if the input array is rectangular. It is assumed the array is non-null and has a non-zero length.- Parameters:
array
- Array to be tested.- Throws:
java.lang.NullPointerException
- if input array is nulljava.lang.IndexOutOfBoundsException
- if input array is zero lengthjava.lang.IllegalArgumentException
- if input array is not rectangular
-
checkValuesRequiredSize
static void checkValuesRequiredSize(int size, int required)
Check the values size is the minimum required,size >= required
.- Parameters:
size
- Values size.required
- Required size.- Throws:
java.lang.IllegalArgumentException
- ifsize < required
-
checkCategoriesRequiredSize
static void checkCategoriesRequiredSize(int size, int required)
Check the categories size is the minimum required,size >= required
.- Parameters:
size
- Values size.required
- Required size.- Throws:
java.lang.IllegalArgumentException
- ifsize < required
-
checkValuesSizeMatch
static void checkValuesSizeMatch(int size1, int size2)
Check the values sizes are equal,size1 == size2
.- Parameters:
size1
- First size.size2
- Second size.- Throws:
java.lang.IllegalArgumentException
- ifsize1 != size2
-
checkOption
static <E extends java.lang.Enum<E>> E checkOption(E v, java.util.Set<E> allowed)
Check the option is allowed.- Type Parameters:
E
- Option type.- Parameters:
v
- Option value.allowed
- Allowed options.- Returns:
- the value
- Throws:
java.lang.IllegalArgumentException
- if the value is not in the allowed options or is null
-
checkTable
static void checkTable(int[][] table)
Check the input is a 2-by-2 contingency table.- Parameters:
table
- Table.- Throws:
java.lang.IllegalArgumentException
- if thetable
is not a 2-by-2 table; any table entry is negative; or the sum is zero or is not an integer
-
-