当前位置: 首页>>代码示例>>Java>>正文


Java LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE属性代码示例

本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE属性的具体用法?Java LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE怎么用?Java LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.math3.exception.util.LocalizedFormats的用法示例。


在下文中一共展示了LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: covariance

/**
 * Computes the covariance between the two arrays.
 *
 * <p>Array lengths must match and the common length must be at least 2.</p>
 *
 * @param xArray first data array
 * @param yArray second data array
 * @param biasCorrected if true, returned value will be bias-corrected
 * @return returns the covariance for the two arrays
 * @throws  MathIllegalArgumentException if the arrays lengths do not match or
 * there is insufficient data
 */
public double covariance(final double[] xArray, final double[] yArray, boolean biasCorrected)
    throws MathIllegalArgumentException {
    Mean mean = new Mean();
    double result = 0d;
    int length = xArray.length;
    if (length != yArray.length) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, length, yArray.length);
    } else if (length < 2) {
        throw new MathIllegalArgumentException(
              LocalizedFormats.INSUFFICIENT_OBSERVED_POINTS_IN_SAMPLE, length, 2);
    } else {
        double xMean = mean.evaluate(xArray);
        double yMean = mean.evaluate(yArray);
        for (int i = 0; i < length; i++) {
            double xDev = xArray[i] - xMean;
            double yDev = yArray[i] - yMean;
            result += (xDev * yDev - result) / (i + 1);
        }
    }
    return biasCorrected ? result * ((double) length / (double)(length - 1)) : result;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:34,代码来源:Covariance.java

示例2: addObservations

/**
 * 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
 */
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] );
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:32,代码来源:SimpleRegression.java

示例3: addObservations

/**
 * Adds multiple observations to the model.
 * @param x observations on the regressors
 * @param y observations on the regressand
 * @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
 */
public void addObservations(double[][] x, 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);
    }
    if (x.length == 0) {  // Must be no y data either
        throw new ModelSpecificationException(
                LocalizedFormats.NO_DATA);
    }
    if (x[0].length + 1 > x.length) {
        throw new ModelSpecificationException(
              LocalizedFormats.NOT_ENOUGH_DATA_FOR_NUMBER_OF_PREDICTORS,
              x.length, x[0].length);
    }
    for (int i = 0; i < x.length; i++) {
        addObservation(x[i], y[i]);
    }
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:27,代码来源:MillerUpdatingRegression.java

示例4: solveLowerTriangularSystem

/**Solve  a  system of composed of a Lower Triangular Matrix
 * {@link RealMatrix}.
 * <p>
 * This method is called to solve systems of equations which are
 * of the lower triangular form. The matrix {@link RealMatrix}
 * is assumed, though not checked, to be in lower triangular form.
 * The vector {@link RealVector} is overwritten with the solution.
 * The matrix is checked that it is square and its dimensions match
 * the length of the vector.
 * </p>
 * @param rm RealMatrix which is lower triangular
 * @param b  RealVector this is overwritten
 * @exception IllegalArgumentException if the matrix and vector are not conformable
 * @exception ArithmeticException there is a zero or near zero on the diagonal of rm
 */
public static void solveLowerTriangularSystem( RealMatrix rm, RealVector b){
    if ((rm == null) || (b == null) || ( rm.getRowDimension() != b.getDimension())) {
        throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
                (rm == null) ? 0 : rm.getRowDimension(),
                (b == null) ? 0 : b.getDimension());
    }
    if( rm.getColumnDimension() != rm.getRowDimension() ){
        throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
                rm.getRowDimension(),rm.getRowDimension(),
                rm.getRowDimension(),rm.getColumnDimension());
    }
    int rows = rm.getRowDimension();
    for( int i = 0 ; i < rows ; i++ ){
        double diag = rm.getEntry(i, i);
        if( FastMath.abs(diag) < Precision.SAFE_MIN ){
            throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
        }
        double bi = b.getEntry(i)/diag;
        b.setEntry(i,  bi );
        for( int j = i+1; j< rows; j++ ){
            b.setEntry(j, b.getEntry(j)-bi*rm.getEntry(j,i)  );
        }
    }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:39,代码来源:MatrixUtils.java

示例5: solveUpperTriangularSystem

/** Solver a  system composed  of an Upper Triangular Matrix
 * {@link RealMatrix}.
 * <p>
 * This method is called to solve systems of equations which are
 * of the lower triangular form. The matrix {@link RealMatrix}
 * is assumed, though not checked, to be in upper triangular form.
 * The vector {@link RealVector} is overwritten with the solution.
 * The matrix is checked that it is square and its dimensions match
 * the length of the vector.
 * </p>
 * @param rm RealMatrix which is upper triangular
 * @param b  RealVector this is overwritten
 * @exception IllegalArgumentException if the matrix and vector are not conformable
 * @exception ArithmeticException there is a zero or near zero on the diagonal of rm
 */
public static void solveUpperTriangularSystem( RealMatrix rm, RealVector b){
    if ((rm == null) || (b == null) || ( rm.getRowDimension() != b.getDimension())) {
        throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE,
                (rm == null) ? 0 : rm.getRowDimension(),
                (b == null) ? 0 : b.getDimension());
    }
    if( rm.getColumnDimension() != rm.getRowDimension() ){
        throw new MathIllegalArgumentException(LocalizedFormats.DIMENSIONS_MISMATCH_2x2,
                rm.getRowDimension(),rm.getRowDimension(),
                rm.getRowDimension(),rm.getColumnDimension());
    }
    int rows = rm.getRowDimension();
    for( int i = rows-1 ; i >-1 ; i-- ){
        double diag = rm.getEntry(i, i);
        if( FastMath.abs(diag) < Precision.SAFE_MIN ){
            throw new MathArithmeticException(LocalizedFormats.ZERO_DENOMINATOR);
        }
        double bi = b.getEntry(i)/diag;
        b.setEntry(i,  bi );
        for( int j = i-1; j>-1; j-- ){
            b.setEntry(j, b.getEntry(j)-bi*rm.getEntry(j,i)  );
        }
    }
}
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:39,代码来源:MatrixUtils.java

示例6: DimensionMismatchException

/**
 * Construct an exception from the mismatched dimensions.
 *
 * @param wrong Wrong dimension.
 * @param expected Expected dimension.
 */
public DimensionMismatchException(int wrong,
                                  int expected) {
    this(LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE, wrong, expected);
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:10,代码来源:DimensionMismatchException.java


注:本文中的org.apache.commons.math3.exception.util.LocalizedFormats.DIMENSIONS_MISMATCH_SIMPLE属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。