當前位置: 首頁>>代碼示例>>Java>>正文


Java SimpleRegression.getR方法代碼示例

本文整理匯總了Java中org.apache.commons.math3.stat.regression.SimpleRegression.getR方法的典型用法代碼示例。如果您正苦於以下問題:Java SimpleRegression.getR方法的具體用法?Java SimpleRegression.getR怎麽用?Java SimpleRegression.getR使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.math3.stat.regression.SimpleRegression的用法示例。


在下文中一共展示了SimpleRegression.getR方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: correlation

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
public static double correlation(IDoubleVector x, IDoubleVector y) {
    final int len = x.getLength();
    if (len != y.getLength()) {
        throw new AdeCoreIllegalArgumentException("Mismatching lengths");
    }
    if (len < 2) {
        throw new AdeCoreIllegalArgumentException("Vectors must have length >=2");
    }
    final SimpleRegression regression = new SimpleRegression();
    for (int i = 0; i < len; i++) {
        regression.addData(x.get(i), y.get(i));
    }
    return regression.getR();
}
 
開發者ID:openmainframeproject,項目名稱:ade,代碼行數:15,代碼來源:BasicStatistics.java

示例2: correlation

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
/**
 * Computes the Pearson's product-moment correlation coefficient between two arrays.
 *
 * <p>Throws MathIllegalArgumentException if the arrays do not have the same length
 * or their common length is less than 2.  Returns {@code NaN} if either of the arrays
 * has zero variance (i.e., if one of the arrays does not contain at least two distinct
 * values).</p>
 *
 * @param xArray first data array
 * @param yArray second data array
 * @return Returns Pearson's correlation coefficient for the two arrays
 * @throws DimensionMismatchException if the arrays lengths do not match
 * @throws MathIllegalArgumentException if there is insufficient data
 */
public double correlation(final double[] xArray, final double[] yArray) {
    SimpleRegression regression = new SimpleRegression();
    if (xArray.length != yArray.length) {
        throw new DimensionMismatchException(xArray.length, yArray.length);
    } else if (xArray.length < 2) {
        throw new MathIllegalArgumentException(LocalizedFormats.INSUFFICIENT_DIMENSION,
                                               xArray.length, 2);
    } else {
        for(int i=0; i<xArray.length; i++) {
            regression.addData(xArray[i], yArray[i]);
        }
        return regression.getR();
    }
}
 
開發者ID:biocompibens,項目名稱:SME,代碼行數:29,代碼來源:PearsonsCorrelation.java

示例3: correlation

import org.apache.commons.math3.stat.regression.SimpleRegression; //導入方法依賴的package包/類
/**
 * Computes the Pearson's product-moment correlation coefficient between the two arrays.
 *
 * </p>Throws IllegalArgumentException if the arrays do not have the same length
 * or their common length is less than 2</p>
 *
 * @param xArray first data array
 * @param yArray second data array
 * @return Returns Pearson's correlation coefficient for the two arrays
 * @throws DimensionMismatchException if the arrays lengths do not match
 * @throws MathIllegalArgumentException if there is insufficient data
 */
public double correlation(final double[] xArray, final double[] yArray) {
    SimpleRegression regression = new SimpleRegression();
    if (xArray.length != yArray.length) {
        throw new DimensionMismatchException(xArray.length, yArray.length);
    } else if (xArray.length < 2) {
        throw new MathIllegalArgumentException(LocalizedFormats.INSUFFICIENT_DIMENSION,
                                               xArray.length, 2);
    } else {
        for(int i=0; i<xArray.length; i++) {
            regression.addData(xArray[i], yArray[i]);
        }
        return regression.getR();
    }
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:27,代碼來源:PearsonsCorrelation.java


注:本文中的org.apache.commons.math3.stat.regression.SimpleRegression.getR方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。