Java Code Examples for org.apache.commons.math.exception.util.LocalizedFormats#INSUFFICIENT_DIMENSION

The following examples show how to use org.apache.commons.math.exception.util.LocalizedFormats#INSUFFICIENT_DIMENSION . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChiSquareTestImpl.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 MathIllegalArgumentException if any of these checks fail.
 *
 * @param in input 2-way table to check
 * @throws MathIllegalArgumentException if the array is not valid
 */
private void checkArray(long[][] in) {
    if (in.length < 2) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INSUFFICIENT_DIMENSION, in.length, 2);
    }

    if (in[0].length < 2) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INSUFFICIENT_DIMENSION, in[0].length, 2);
    }

    checkRectangular(in);
    checkNonNegative(in);

}
 
Example 2
Source File: ChiSquareTestImpl.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 MathIllegalArgumentException if any of these checks fail.
 *
 * @param in input 2-way table to check
 * @throws MathIllegalArgumentException if the array is not valid
 */
private void checkArray(long[][] in) {
    if (in.length < 2) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INSUFFICIENT_DIMENSION, in.length, 2);
    }

    if (in[0].length < 2) {
        throw new MathIllegalArgumentException(
                LocalizedFormats.INSUFFICIENT_DIMENSION, in[0].length, 2);
    }

    checkRectangular(in);
    checkNonNegative(in);

}
 
Example 3
Source File: StatUtils.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the sum of the (signed) differences between corresponding elements of the
 * input arrays -- i.e., sum(sample1[i] - sample2[i]).
 *
 * @param sample1  the first array
 * @param sample2  the second array
 * @return sum of paired differences
 * @throws DimensionMismatchException if the arrays do not have the same
 * (positive) length.
 * @throws NoDataException if the sample arrays are empty.
 */
public static double sumDifference(final double[] sample1, final double[] sample2) {
    int n = sample1.length;
    if (n != sample2.length) {
        throw new DimensionMismatchException(n, sample2.length);
    }
    if (n <= 0) {
        throw new NoDataException(LocalizedFormats.INSUFFICIENT_DIMENSION);
    }
    double result = 0;
    for (int i = 0; i < n; i++) {
        result += sample1[i] - sample2[i];
    }
    return result;
}
 
Example 4
Source File: StatUtils.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the sum of the (signed) differences between corresponding elements of the
 * input arrays -- i.e., sum(sample1[i] - sample2[i]).
 *
 * @param sample1  the first array
 * @param sample2  the second array
 * @return sum of paired differences
 * @throws DimensionMismatchException if the arrays do not have the same
 * (positive) length.
 * @throws NoDataException if the sample arrays are empty.
 */
public static double sumDifference(final double[] sample1, final double[] sample2) {
    int n = sample1.length;
    if (n != sample2.length) {
        throw new DimensionMismatchException(n, sample2.length);
    }
    if (n <= 0) {
        throw new NoDataException(LocalizedFormats.INSUFFICIENT_DIMENSION);
    }
    double result = 0;
    for (int i = 0; i < n; i++) {
        result += sample1[i] - sample2[i];
    }
    return result;
}
 
Example 5
Source File: StatUtils.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the sum of the (signed) differences between corresponding elements of the
 * input arrays -- i.e., sum(sample1[i] - sample2[i]).
 *
 * @param sample1  the first array
 * @param sample2  the second array
 * @return sum of paired differences
 * @throws DimensionMismatchException if the arrays do not have the same
 * (positive) length.
 * @throws NoDataException if the sample arrays are empty.
 */
public static double sumDifference(final double[] sample1, final double[] sample2) {
    int n = sample1.length;
    if (n != sample2.length) {
        throw new DimensionMismatchException(n, sample2.length);
    }
    if (n <= 0) {
        throw new NoDataException(LocalizedFormats.INSUFFICIENT_DIMENSION);
    }
    double result = 0;
    for (int i = 0; i < n; i++) {
        result += sample1[i] - sample2[i];
    }
    return result;
}