本文整理汇总了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;
}
示例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;
}
示例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);
}