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


Java SpearmansCorrelation.correlation方法代码示例

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


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

示例1: getSpearman

import org.apache.commons.math3.stat.correlation.SpearmansCorrelation; //导入方法依赖的package包/类
public static double getSpearman(List<Double> list1, List<Double> list2)
{
	SpearmansCorrelation correlation = new SpearmansCorrelation();
	double c = correlation.correlation(getArray(list1),getArray(list2));
		
	return c;
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:8,代码来源:CorrelationCalculator.java

示例2: CalcCorrV2

import org.apache.commons.math3.stat.correlation.SpearmansCorrelation; //导入方法依赖的package包/类
public double CalcCorrV2(XYPointCollection CollectionA, XYPointCollection CollectionB, int NoPointPerInterval) {
    SpearmansCorrelation pearsonsCorrelation = new SpearmansCorrelation();

    int num = Math.max(CollectionA.PointCount(), CollectionB.PointCount()) / 2;
    float timeinterval = 2f / (float) NoPointPerInterval;
    if (num < 6) {
        return 0f;
    }

    double[] arrayA = new double[num];
    double[] arrayB = new double[num];

    float start = Math.max(CollectionA.Data.get(0).getX(), CollectionB.Data.get(0).getX());

    int i = 0;
    float low = start;
    float up = start + timeinterval;

    for (int j = 0; j < CollectionA.PointCount(); j++) {
        while (CollectionA.Data.get(j).getX() > up) {
            i++;
            low = up;
            up = low + timeinterval;
        }
        if (i >= num) {
            break;
        }
        if (CollectionA.Data.get(j).getX() >= low && CollectionA.Data.get(j).getX() < up) {
            if (CollectionA.Data.get(j).getY() > arrayA[i]) {
                arrayA[i] = CollectionA.Data.get(j).getY();
            }
        }
    }
    i = 0;
    low = start;
    up = start + timeinterval;
    for (int j = 0; j < CollectionB.PointCount(); j++) {
        while (CollectionB.Data.get(j).getX() > up) {
            i++;
            low = up;
            up = low + timeinterval;
        }
        if (i >= num) {
            break;
        }
        if (CollectionB.Data.get(j).getX() >= low && CollectionB.Data.get(j).getX() < up) {
            if (CollectionB.Data.get(j).getY() > arrayB[i]) {
                arrayB[i] = CollectionB.Data.get(j).getY();
            }
        }
    }

    if (arrayA[0] == 0f) {
        arrayA[0] = arrayA[1];
    }
    if (arrayB[0] == 0f) {
        arrayB[0] = arrayB[1];
    }
    for (int idx = 1; idx < num - 1; idx++) {
        if (arrayA[idx] == 0f) {
            arrayA[idx] = (arrayA[idx - 1] + arrayA[idx + 1]) / 2;
        }
        if (arrayB[idx] == 0f) {
            arrayB[idx] = (arrayB[idx - 1] + arrayB[idx + 1]) / 2;
        }
    }

    if (arrayA[num - 1] == 0f) {
        arrayA[num - 1] = arrayA[num - 2];
    }
    if (arrayB[num - 1] == 0f) {
        arrayB[num - 1] = arrayB[num - 2];
    }
    double R2 = pearsonsCorrelation.correlation(arrayA, arrayB);
    return R2;
}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:77,代码来源:PearsonCorr.java

示例3: correlate

import org.apache.commons.math3.stat.correlation.SpearmansCorrelation; //导入方法依赖的package包/类
@Override
public double correlate(double[] val1, double[] val2) {
	
	SpearmansCorrelation correlation = new SpearmansCorrelation();
	return correlation.correlation(val1, val2);

}
 
开发者ID:rwth-acis,项目名称:REST-OCD-Services,代码行数:8,代码来源:SpearmanCalculator.java


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