本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.INVALID_REGRESSION_OBSERVATION属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.INVALID_REGRESSION_OBSERVATION属性的具体用法?Java LocalizedFormats.INVALID_REGRESSION_OBSERVATION怎么用?Java LocalizedFormats.INVALID_REGRESSION_OBSERVATION使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.INVALID_REGRESSION_OBSERVATION属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addObservation
/**
* 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;
}
示例2: addData
/**
* 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]);
}
}
示例3: addObservation
/**
* 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 );
}