Package org.apache.commons.math3.exception

Examples of org.apache.commons.math3.exception.NoDataException


            if (column > 0) {
                throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
            }
            final int nRows = subMatrix.length;
            if (nRows == 0) {
                throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
            }

            final int nCols = subMatrix[0].length;
            if (nCols == 0) {
                throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
            }
            data = buildArray(getField(), subMatrix.length, nCols);
            for (int i = 0; i < data.length; ++i) {
                if (subMatrix[i].length != nCols) {
                    throw new DimensionMismatchException(nCols, subMatrix[i].length);
View Full Code Here


    protected static <T extends FieldElement<T>> Field<T> extractField(final T[][] d) {
        if (d == null) {
            throw new NullArgumentException();
        }
        if (d.length == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
        }
        if (d[0].length == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
        }
        return d[0][0].getField();
    }
View Full Code Here

     * @return the field to which the array elements belong.
     * @throws NoDataException if array is empty.
     */
    protected static <T extends FieldElement<T>> Field<T> extractField(final T[] d) {
        if (d.length == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
        }
        return d[0].getField();
    }
View Full Code Here

        if (subMatrix == null) {
            throw new NullArgumentException();
        }
        final int nRows = subMatrix.length;
        if (nRows == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
        }

        final int nCols = subMatrix[0].length;
        if (nCols == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
        }

        for (int r = 1; r < nRows; ++r) {
            if (subMatrix[r].length != nCols) {
                throw new DimensionMismatchException(nCols, subMatrix[r].length);
View Full Code Here

            selectedColumns == null) {
            throw new NullArgumentException();
        }
        if (selectedRows.length == 0 ||
            selectedColumns.length == 0) {
            throw new NoDataException();
        }

        for (final int row : selectedRows) {
            checkRowIndex(row);
        }
View Full Code Here

    public void setSubMatrix(final T[][] subMatrix, final int row, final int column) {
        // safety checks
        MathUtils.checkNotNull(subMatrix);
        final int refLength = subMatrix[0].length;
        if (refLength == 0) {
            throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
        }
        final int endRow    = row + subMatrix.length - 1;
        final int endColumn = column + refLength - 1;
        checkSubMatrixIndex(row, endRow, column, endColumn);
        for (final T[] subRow : subMatrix) {
View Full Code Here

            if (d == null) {
                throw new NullArgumentException();
            }
            final int nRows = d.length;
            if (nRows == 0) {
                throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
            }
            final int nCols = d[0].length;
            if (nCols == 0) {
                throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
            }
            for (int r = 1; r < nRows; r++) {
                if (d[r].length != nCols) {
                    throw new DimensionMismatchException(d[r].length, nCols);
                }
View Full Code Here

                throw new MathIllegalStateException(LocalizedFormats.FIRST_COLUMNS_NOT_INITIALIZED_YET, column);
            }
            MathUtils.checkNotNull(subMatrix);
            final int nRows = subMatrix.length;
            if (nRows == 0) {
                throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_ROW);
            }

            final int nCols = subMatrix[0].length;
            if (nCols == 0) {
                throw new NoDataException(LocalizedFormats.AT_LEAST_ONE_COLUMN);
            }
            data = new double[subMatrix.length][nCols];
            for (int i = 0; i < data.length; ++i) {
                if (subMatrix[i].length != nCols) {
                    throw new DimensionMismatchException(subMatrix[i].length, nCols);
View Full Code Here

     * estimate the regression parameters
     */
    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(
View Full Code Here

    protected void newYSampleData(double[] y) {
        if (y == null) {
            throw new NullArgumentException();
        }
        if (y.length == 0) {
            throw new NoDataException();
        }
        this.yVector = new ArrayRealVector(y);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.math3.exception.NoDataException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.