Example usage for org.apache.commons.math3.exception NoDataException NoDataException

List of usage examples for org.apache.commons.math3.exception NoDataException NoDataException

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception NoDataException NoDataException.

Prototype

public NoDataException(Localizable specific) 

Source Link

Document

Construct the exception with a specific context.

Usage

From source file:lirmm.inria.fr.math.BigSparseRealMatrix.java

/**
 * Create a new {@code BigSparseRealMatrix} using the input array as the
 * underlying data array./*from   w  ww .j a  v a2 s  .c  o m*/
 *
 * @param data Data for the new matrix.
 * @throws DimensionMismatchException if {@code d} is not rectangular.
 * @throws NoDataException if {@code d} i or column dimension is zero.
 */
public BigSparseRealMatrix(final double[][] data) throws DimensionMismatchException, NoDataException {
    MathUtils.checkNotNull(data);
    this.entries = new OpenLongToDoubleHashMap(0.0);
    rows = data.length;
    if (rows == 0) {
        throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
    }
    columns = data[0].length;
    if (columns == 0) {
        throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
    }
    for (int i = 0; i < rows; i++) {
        for (int j = 0; j < columns; j++) {
            setEntry(i, j, data[i][j]);
        }
    }
}

From source file:logic.ApachePolyNewtonForm.java

/**
 * Verifies that the input arrays are valid.
 * <p>// w  w w  .  j a v  a  2  s.co  m
 * The centers must be distinct for interpolation purposes, but not
 * for general use. Thus it is not verified here.</p>
 *
 * @param a the coefficients in Newton form formula
 * @param c the centers
 * @throws NullArgumentException if any argument is {@code null}.
 * @throws NoDataException if any array has zero length.
 * @throws DimensionMismatchException if the size difference between
 * {@code a} and {@code c} is not equal to 1.
 * @see org.apache.commons.math3.analysis.interpolation.DividedDifferenceInterpolator#computeDividedDifference(double[],
 * double[])
 */
protected static void verifyInputArray(double a[], double c[])
        throws NullArgumentException, NoDataException, DimensionMismatchException {
    MathUtils.checkNotNull(a);
    MathUtils.checkNotNull(c);
    if (a.length == 0 || c.length == 0) {
        throw new NoDataException(LocalizedFormats.EMPTY_POLYNOMIALS_COEFFICIENTS_ARRAY);
    }
    if (a.length != c.length + 1) {
        throw new DimensionMismatchException(LocalizedFormats.ARRAY_SIZES_SHOULD_HAVE_DIFFERENCE_1, a.length,
                c.length);
    }
}

From source file:experiment.SimpleRegression_bug.java

/**
 * Performs a regression on data present in buffers and outputs a RegressionResults object.
 *
 * <p>If there are fewer than 3 observations in the model and {@code hasIntercept} is true
 * a {@code NoDataException} is thrown.  If there is no intercept term, the model must
 * contain at least 2 observations.</p>
 *
 * @return RegressionResults acts as a container of regression output
 * @throws ModelSpecificationException if the model is not correctly specified
 * @throws NoDataException if there is not sufficient data in the model to
 * estimate the regression parameters//from www  .j a v a 2 s  .c o  m
 */
public RegressionResults regress() throws ModelSpecificationException, NoDataException {
    if (hasIntercept) {
        if (n < 3) {
            throw new NoDataException(LocalizedFormats.NOT_ENOUGH_DATA_REGRESSION);
        }
        if (FastMath.abs(sumXX) > Precision.SAFE_MIN) {
            final double[] params = new double[] { getIntercept(), getSlope() };
            final double mse = getMeanSquareError();
            final double _syy = sumYY + sumY * sumY / n;
            final double[] vcv = new double[] { mse * (xbar * xbar / sumXX + 1.0 / n), -xbar * mse / sumXX,
                    mse / sumXX };
            return new RegressionResults(params, new double[][] { vcv }, true, n, 2, sumY, _syy,
                    getSumSquaredErrors(), true, false);
        } else {
            final double[] params = new double[] { sumY / n, Double.NaN };
            //final double mse = getMeanSquareError();
            final double[] vcv = new double[] { ybar / (n - 1.0), Double.NaN, Double.NaN };
            return new RegressionResults(params, new double[][] { vcv }, true, n, 1, sumY, sumYY,
                    getSumSquaredErrors(), true, false);
        }
    } else {
        if (n < 2) {
            throw new NoDataException(LocalizedFormats.NOT_ENOUGH_DATA_REGRESSION);
        }
        if (!Double.isNaN(sumXX)) {
            final double[] vcv = new double[] { getMeanSquareError() / sumXX };
            final double[] params = new double[] { sumXY / sumXX };
            return new RegressionResults(params, new double[][] { vcv }, true, n, 1, sumY, sumYY,
                    getSumSquaredErrors(), false, false);
        } else {
            final double[] vcv = new double[] { Double.NaN };
            final double[] params = new double[] { Double.NaN };
            return new RegressionResults(params, new double[][] { vcv }, true, n, 1, Double.NaN, Double.NaN,
                    Double.NaN, false, false);
        }
    }
}