List of usage examples for org.apache.commons.math3.exception.util LocalizedFormats NOT_ENOUGH_DATA_FOR_NUMBER_OF_PREDICTORS
LocalizedFormats NOT_ENOUGH_DATA_FOR_NUMBER_OF_PREDICTORS
To view the source code for org.apache.commons.math3.exception.util LocalizedFormats NOT_ENOUGH_DATA_FOR_NUMBER_OF_PREDICTORS.
Click Source Link
From source file:experiment.SimpleRegression_bug.java
/** * Adds a series of observations to the regression model. The lengths of * x and y must be the same and x must be rectangular. * * @param x a series of observations on the independent variables * @param y a series of observations on the dependent variable * The length of x and y must be the same * @throws ModelSpecificationException if {@code x} is not rectangular, does not match * the length of {@code y} or does not contain sufficient data to estimate the model *//* www. ja va2s. co m*/ public void addObservations(final double[][] x, final double[] y) throws ModelSpecificationException { if ((x == null) || (y == null) || (x.length != y.length)) { throw new ModelSpecificationException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, (x == null) ? 0 : x.length, (y == null) ? 0 : y.length); } boolean obsOk = true; for (int i = 0; i < x.length; i++) { if (x[i] == null || x[i].length == 0) { obsOk = false; } } if (!obsOk) { throw new ModelSpecificationException(LocalizedFormats.NOT_ENOUGH_DATA_FOR_NUMBER_OF_PREDICTORS, 0, 1); } for (int i = 0; i < x.length; i++) { addData(x[i][0], y[i]); } }