Java Code Examples for org.apache.commons.math3.exception.util.LocalizedFormats#INVALID_REGRESSION_OBSERVATION

The following examples show how to use org.apache.commons.math3.exception.util.LocalizedFormats#INVALID_REGRESSION_OBSERVATION . 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: MillerUpdatingRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an observation to the regression model.
 * @param x the array with regressor values
 * @param y  the value of dependent variable given these regressors
 * @exception ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x, final double y)
throws ModelSpecificationException {

    if ((!this.hasIntercept && x.length != nvars) ||
           (this.hasIntercept && x.length + 1 != nvars)) {
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                x.length, nvars);
    }
    if (!this.hasIntercept) {
        include(MathArrays.copyOf(x, x.length), 1.0, y);
    } else {
        final double[] tmp = new double[x.length + 1];
        System.arraycopy(x, 0, tmp, 1, x.length);
        tmp[0] = 1.0;
        include(tmp, 1.0, y);
    }
    ++nobs;

}
 
Example 2
Source File: MillerUpdatingRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an observation to the regression model.
 * @param x the array with regressor values
 * @param y  the value of dependent variable given these regressors
 * @exception ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x, final double y)
throws ModelSpecificationException {

    if ((!this.hasIntercept && x.length != nvars) ||
           (this.hasIntercept && x.length + 1 != nvars)) {
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                x.length, nvars);
    }
    if (!this.hasIntercept) {
        include(MathArrays.copyOf(x, x.length), 1.0, y);
    } else {
        final double[] tmp = new double[x.length + 1];
        System.arraycopy(x, 0, tmp, 1, x.length);
        tmp[0] = 1.0;
        include(tmp, 1.0, y);
    }
    ++nobs;

}
 
Example 3
Source File: MillerUpdatingRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an observation to the regression model.
 * @param x the array with regressor values
 * @param y  the value of dependent variable given these regressors
 * @exception ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x, final double y) {

    if ((!this.hasIntercept && x.length != nvars) ||
           (this.hasIntercept && x.length + 1 != nvars)) {
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                x.length, nvars);
    }
    if (!this.hasIntercept) {
        include(MathArrays.copyOf(x, x.length), 1.0, y);
    } else {
        double[] tmp = new double[x.length + 1];
        System.arraycopy(x, 0, tmp, 1, x.length);
        tmp[0] = 1.0;
        include(tmp, 1.0, y);
    }
    ++nobs;

}
 
Example 4
Source File: MillerUpdatingRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an observation to the regression model.
 * @param x the array with regressor values
 * @param y  the value of dependent variable given these regressors
 * @exception ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x, final double y) {

    if ((!this.hasIntercept && x.length != nvars) ||
           (this.hasIntercept && x.length + 1 != nvars)) {
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                x.length, nvars);
    }
    if (!this.hasIntercept) {
        include(MathArrays.copyOf(x, x.length), 1.0, y);
    } else {
        double[] tmp = new double[x.length + 1];
        System.arraycopy(x, 0, tmp, 1, x.length);
        tmp[0] = 1.0;
        include(tmp, 1.0, y);
    }
    ++nobs;

}
 
Example 5
Source File: MillerUpdatingRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an observation to the regression model.
 * @param x the array with regressor values
 * @param y  the value of dependent variable given these regressors
 * @exception ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x, final double y)
throws ModelSpecificationException {

    if ((!this.hasIntercept && x.length != nvars) ||
           (this.hasIntercept && x.length + 1 != nvars)) {
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                x.length, nvars);
    }
    if (!this.hasIntercept) {
        include(MathArrays.copyOf(x, x.length), 1.0, y);
    } else {
        final double[] tmp = new double[x.length + 1];
        System.arraycopy(x, 0, tmp, 1, x.length);
        tmp[0] = 1.0;
        include(tmp, 1.0, y);
    }
    ++nobs;

}
 
Example 6
Source File: MillerUpdatingRegression.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Adds an observation to the regression model.
 * @param x the array with regressor values
 * @param y  the value of dependent variable given these regressors
 * @exception ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x, final double y)
throws ModelSpecificationException {

    if ((!this.hasIntercept && x.length != nvars) ||
           (this.hasIntercept && x.length + 1 != nvars)) {
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                x.length, nvars);
    }
    if (!this.hasIntercept) {
        include(MathArrays.copyOf(x, x.length), 1.0, y);
    } else {
        final double[] tmp = new double[x.length + 1];
        System.arraycopy(x, 0, tmp, 1, x.length);
        tmp[0] = 1.0;
        include(tmp, 1.0, y);
    }
    ++nobs;

}
 
Example 7
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds one observation to the regression model.
 *
 * @param x the independent variables which form the design matrix
 * @param y the dependent or response variable
 * @throws ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x,final double y)
throws ModelSpecificationException {
    if( x == null || x.length == 0 ){
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,x!=null?x.length:0, 1);
    }
    addData( x[0], y );
}
 
Example 8
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds one observation to the regression model.
 *
 * @param x the independent variables which form the design matrix
 * @param y the dependent or response variable
 * @throws ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x,final double y)
throws ModelSpecificationException {
    if( x == null || x.length == 0 ){
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,x!=null?x.length:0, 1);
    }
    addData( x[0], y );
}
 
Example 9
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds the observations represented by the elements in
 * <code>data</code>.
 * <p>
 * <code>(data[0][0],data[0][1])</code> will be the first observation, then
 * <code>(data[1][0],data[1][1])</code>, etc.</p>
 * <p>
 * This method does not replace data that has already been added.  The
 * observations represented by <code>data</code> are added to the existing
 * dataset.</p>
 * <p>
 * To replace all data, use <code>clear()</code> before adding the new
 * data.</p>
 *
 * @param data array of observations to be added
 * @throws ModelSpecificationException if the length of {@code data[i]} is not
 * greater than or equal to 2
 */
public void addData(final double[][] data) throws ModelSpecificationException {
    for (int i = 0; i < data.length; i++) {
        if( data[i].length < 2 ){
           throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                data[i].length, 2);
        }
        addData(data[i][0], data[i][1]);
    }
}
 
Example 10
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds one observation to the regression model.
 *
 * @param x the independent variables which form the design matrix
 * @param y the dependent or response variable
 * @throws ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x,final double y)
throws ModelSpecificationException {
    if( x == null || x.length == 0 ){
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,x!=null?x.length:0, 1);
    }
    addData( x[0], y );
}
 
Example 11
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds the observations represented by the elements in
 * <code>data</code>.
 * <p>
 * <code>(data[0][0],data[0][1])</code> will be the first observation, then
 * <code>(data[1][0],data[1][1])</code>, etc.</p>
 * <p>
 * This method does not replace data that has already been added.  The
 * observations represented by <code>data</code> are added to the existing
 * dataset.</p>
 * <p>
 * To replace all data, use <code>clear()</code> before adding the new
 * data.</p>
 *
 * @param data array of observations to be added
 * @throws ModelSpecificationException if the length of {@code data[i]} is not
 * greater than or equal to 2
 */
public void addData(final double[][] data) throws ModelSpecificationException {
    for (int i = 0; i < data.length; i++) {
        if( data[i].length < 2 ){
           throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                data[i].length, 2);
        }
        addData(data[i][0], data[i][1]);
    }
}
 
Example 12
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds the observations represented by the elements in
 * <code>data</code>.
 * <p>
 * <code>(data[0][0],data[0][1])</code> will be the first observation, then
 * <code>(data[1][0],data[1][1])</code>, etc.</p>
 * <p>
 * This method does not replace data that has already been added.  The
 * observations represented by <code>data</code> are added to the existing
 * dataset.</p>
 * <p>
 * To replace all data, use <code>clear()</code> before adding the new
 * data.</p>
 *
 * @param data array of observations to be added
 * @throws ModelSpecificationException if the length of {@code data[i]} is not
 * greater than or equal to 2
 */
public void addData(final double[][] data) throws ModelSpecificationException {
    for (int i = 0; i < data.length; i++) {
        if( data[i].length < 2 ){
           throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                data[i].length, 2);
        }
        addData(data[i][0], data[i][1]);
    }
}
 
Example 13
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds the observations represented by the elements in
 * <code>data</code>.
 * <p>
 * <code>(data[0][0],data[0][1])</code> will be the first observation, then
 * <code>(data[1][0],data[1][1])</code>, etc.</p>
 * <p>
 * This method does not replace data that has already been added.  The
 * observations represented by <code>data</code> are added to the existing
 * dataset.</p>
 * <p>
 * To replace all data, use <code>clear()</code> before adding the new
 * data.</p>
 *
 * @param data array of observations to be added
 * @throws ModelSpecificationException if the length of {@code data[i]} is not
 * greater than or equal to 2
 */
public void addData(final double[][] data) {
    for (int i = 0; i < data.length; i++) {
        if( data[i].length < 2 ){
           throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                data[i].length, 2);
        }
        addData(data[i][0], data[i][1]);
    }
    return;
}
 
Example 14
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds the observations represented by the elements in
 * <code>data</code>.
 * <p>
 * <code>(data[0][0],data[0][1])</code> will be the first observation, then
 * <code>(data[1][0],data[1][1])</code>, etc.</p>
 * <p>
 * This method does not replace data that has already been added.  The
 * observations represented by <code>data</code> are added to the existing
 * dataset.</p>
 * <p>
 * To replace all data, use <code>clear()</code> before adding the new
 * data.</p>
 *
 * @param data array of observations to be added
 * @throws ModelSpecificationException if the length of {@code data[i]} is not
 * greater than or equal to 2
 */
public void addData(final double[][] data) throws ModelSpecificationException {
    for (int i = 0; i < data.length; i++) {
        if( data[i].length < 2 ){
           throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                data[i].length, 2);
        }
        addData(data[i][0], data[i][1]);
    }
}
 
Example 15
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds the observations represented by the elements in
 * <code>data</code>.
 * <p>
 * <code>(data[0][0],data[0][1])</code> will be the first observation, then
 * <code>(data[1][0],data[1][1])</code>, etc.</p>
 * <p>
 * This method does not replace data that has already been added.  The
 * observations represented by <code>data</code> are added to the existing
 * dataset.</p>
 * <p>
 * To replace all data, use <code>clear()</code> before adding the new
 * data.</p>
 *
 * @param data array of observations to be added
 * @throws ModelSpecificationException if the length of {@code data[i]} is not
 * greater than or equal to 2
 */
public void addData(final double[][] data) throws ModelSpecificationException {
    for (int i = 0; i < data.length; i++) {
        if( data[i].length < 2 ){
           throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                data[i].length, 2);
        }
        addData(data[i][0], data[i][1]);
    }
}
 
Example 16
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds one observation to the regression model.
 *
 * @param x the independent variables which form the design matrix
 * @param y the dependent or response variable
 * @throws ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x,final double y) throws ModelSpecificationException{
    if( x == null || x.length == 0 ){
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,x!=null?x.length:0, 1);
    }
    addData( x[0], y );
}
 
Example 17
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds the observations represented by the elements in
 * <code>data</code>.
 * <p>
 * <code>(data[0][0],data[0][1])</code> will be the first observation, then
 * <code>(data[1][0],data[1][1])</code>, etc.</p>
 * <p>
 * This method does not replace data that has already been added.  The
 * observations represented by <code>data</code> are added to the existing
 * dataset.</p>
 * <p>
 * To replace all data, use <code>clear()</code> before adding the new
 * data.</p>
 *
 * @param data array of observations to be added
 * @throws ModelSpecificationException if the length of {@code data[i]} is not
 * greater than or equal to 2
 */
public void addData(final double[][] data) {
    for (int i = 0; i < data.length; i++) {
        if( data[i].length < 2 ){
           throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                data[i].length, 2);
        }
        addData(data[i][0], data[i][1]);
    }
}
 
Example 18
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds one observation to the regression model.
 *
 * @param x the independent variables which form the design matrix
 * @param y the dependent or response variable
 * @throws ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x,final double y) throws ModelSpecificationException{
    if( x == null || x.length == 0 ){
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,x!=null?x.length:0, 1);
    }
    addData( x[0], y );
}
 
Example 19
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds the observations represented by the elements in
 * <code>data</code>.
 * <p>
 * <code>(data[0][0],data[0][1])</code> will be the first observation, then
 * <code>(data[1][0],data[1][1])</code>, etc.</p>
 * <p>
 * This method does not replace data that has already been added.  The
 * observations represented by <code>data</code> are added to the existing
 * dataset.</p>
 * <p>
 * To replace all data, use <code>clear()</code> before adding the new
 * data.</p>
 *
 * @param data array of observations to be added
 * @throws ModelSpecificationException if the length of {@code data[i]} is not
 * greater than or equal to 2
 */
public void addData(final double[][] data) {
    for (int i = 0; i < data.length; i++) {
        if( data[i].length < 2 ){
           throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,
                data[i].length, 2);
        }
        addData(data[i][0], data[i][1]);
    }
}
 
Example 20
Source File: SimpleRegression.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Adds one observation to the regression model.
 *
 * @param x the independent variables which form the design matrix
 * @param y the dependent or response variable
 * @throws ModelSpecificationException if the length of {@code x} does not equal
 * the number of independent variables in the model
 */
public void addObservation(final double[] x,final double y)
throws ModelSpecificationException {
    if( x == null || x.length == 0 ){
        throw new ModelSpecificationException(LocalizedFormats.INVALID_REGRESSION_OBSERVATION,x!=null?x.length:0, 1);
    }
    addData( x[0], y );
}