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


Java PearsonsCorrelation.correlation方法代码示例

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


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

示例1: getPearsonCorrelation

import org.apache.commons.math3.stat.correlation.PearsonsCorrelation; //导入方法依赖的package包/类
public static double getPearsonCorrelation(ArrayList<Integer> scores1,
		ArrayList<Integer> scores2) {
	PearsonsCorrelation pc = new PearsonsCorrelation();
	double[] sc1 = new double[scores1.size()];
	double[] sc2 = new double[scores2.size()];

	for (int i = 0; i < scores1.size(); i++)
		sc1[i] = scores1.get(i);

	for (int i = 0; i < scores2.size(); i++)
		sc2[i] = scores2.get(i);

	try {
		return pc.correlation(sc1, sc2);
	} catch (Exception ex) {
		return 0;
	}
}
 
开发者ID:transducens,项目名称:forecat,代码行数:19,代码来源:TestOutput.java

示例2: getExpectedValue

import org.apache.commons.math3.stat.correlation.PearsonsCorrelation; //导入方法依赖的package包/类
@Override
public Object getExpectedValue(int start, int length)
{
    if (length <= 1) {
        return null;
    }
    PearsonsCorrelation corr = new PearsonsCorrelation();
    return corr.correlation(constructDoublePrimitiveArray(start + 2, length), constructDoublePrimitiveArray(start, length));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:10,代码来源:TestCorrelationAggregation.java

示例3: testNonTrivialAggregation

import org.apache.commons.math3.stat.correlation.PearsonsCorrelation; //导入方法依赖的package包/类
private void testNonTrivialAggregation(double[] y, double[] x)
{
    PearsonsCorrelation corr = new PearsonsCorrelation();
    double expected = corr.correlation(x, y);
    checkArgument(Double.isFinite(expected) && expected != 0.0 && expected != 1.0, "Expected result is trivial");
    testAggregation(expected, createDoublesBlock(box(y)), createDoublesBlock(box(x)));
}
 
开发者ID:y-lan,项目名称:presto,代码行数:8,代码来源:TestCorrelationAggregation.java

示例4: getPearson

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

示例5: CheckTimeSeriesSimularityPearson

import org.apache.commons.math3.stat.correlation.PearsonsCorrelation; //导入方法依赖的package包/类
private double CheckTimeSeriesSimularityPearson(double[] r_generated, double[] java_generated) {
    PearsonsCorrelation pearson = new PearsonsCorrelation();
    double pearson_correlation = pearson.correlation(r_generated, java_generated);
    return pearson_correlation;

}
 
开发者ID:ruananswer,项目名称:twitter-anomalyDetection-java,代码行数:7,代码来源:STLTest.java

示例6: calculatePearson

import org.apache.commons.math3.stat.correlation.PearsonsCorrelation; //导入方法依赖的package包/类
public void calculatePearson(double[] x, double[] y){
	PearsonsCorrelation pCorrelation = new PearsonsCorrelation();
	double cor = pCorrelation.correlation(x, y);//take out false too
	System.out.println(cor);
}
 
开发者ID:PacktPublishing,项目名称:Java-Data-Science-Cookbook,代码行数:6,代码来源:PearsonTest.java

示例7: CheckTimeSeriesSimularityPearson

import org.apache.commons.math3.stat.correlation.PearsonsCorrelation; //导入方法依赖的package包/类
private double CheckTimeSeriesSimularityPearson(double[] r_generated, double[] java_generated) {
   PearsonsCorrelation pearson = new PearsonsCorrelation();
   double pearson_correlation = pearson.correlation(r_generated, java_generated);
   return pearson_correlation;

}
 
开发者ID:Hanmourang,项目名称:Pinot,代码行数:7,代码来源:STLTest.java

示例8: getPearsonDouble

import org.apache.commons.math3.stat.correlation.PearsonsCorrelation; //导入方法依赖的package包/类
private static double getPearsonDouble(double[] partOfOriginal, double[] componentPeriod) {
    PearsonsCorrelation pearsonCorr = new PearsonsCorrelation();
    return pearsonCorr.correlation(partOfOriginal, componentPeriod);
}
 
开发者ID:kevoree,项目名称:kevoree-brain,代码行数:5,代码来源:JavaPeriodCalculatorPearson.java

示例9: computeCorrelation

import org.apache.commons.math3.stat.correlation.PearsonsCorrelation; //导入方法依赖的package包/类
private double computeCorrelation(String pFirstAttributeId, String pSecondAttributeId, double pThreshold)
{
	List<Double> firstValues = new ArrayList<Double>();
	List<Double> secondValues = new ArrayList<Double>();
	
	double existingCount = 0.0;
	double nonNumericCount = 0.0;
	
	for (Product product : aCategory.getProducts())
	{
		Attribute firstAttribute = product.getAttribute(pFirstAttributeId);
		Attribute secondAttribute = product.getAttribute(pSecondAttributeId);
		
		// Skip the product if it's missing either attribute
		if( missing(firstAttribute) || missing(secondAttribute))
		{
			continue;
		}
		//add if the value is not missing
		existingCount++;
		//if the attribute is not numeric keep count
		if (!firstAttribute.getTypedValue().isNumeric() ||
				!secondAttribute.getTypedValue().isNumeric())
		{
			nonNumericCount++;
		}
		//else add the values to the correlation array
		else
		{
			double firstValue = firstAttribute.getTypedValue().getNumeric();
			double secondValue = secondAttribute.getTypedValue().getNumeric();
			
			if (firstValue > 0)
			{
				firstValues.add(firstValue);
				secondValues.add(secondValue);
			}
		}
		
		
	}
	double ratio = 1 - nonNumericCount/existingCount;
	if(ratio < pThreshold)
	{
		throw new IllegalArgumentException("Threshold for correlation was not met: "
				+ ratio + "<" + pThreshold + " count: " + existingCount + " NNcount: " + nonNumericCount);
	}
	
	double[] firstArray = ArrayUtils.toPrimitive(firstValues.toArray(new Double[0]));
	double[] secondArray = ArrayUtils.toPrimitive(secondValues.toArray(new Double[0]));
	
	PearsonsCorrelation pearsonsCorrelation = new PearsonsCorrelation();
	
	if(firstArray.length < 2 || secondArray.length < 2)
	{
		return 0;
	}
	return pearsonsCorrelation.correlation(firstArray, secondArray);
}
 
开发者ID:prmr,项目名称:Creco,代码行数:60,代码来源:NumericCorrelator.java

示例10: correlate

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

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

示例11: computeCorrelations

import org.apache.commons.math3.stat.correlation.PearsonsCorrelation; //导入方法依赖的package包/类
private void computeCorrelations() {
    log.info("Filling repository with most correlated profiles");

    List<String> referenceProfile;

    for (AssayType assayType : AssayType.values()) {


        referenceProfile = getReferenceProfile(assayType);
        List<Profile> profiles = profileRepository.findByAssayType(assayType);

        String[] profileNames = new String[profiles.size()];
        double[][] distanceMatrix = new double[profiles.size()][profiles.size()];

        int i = 0;

        for (Profile profileA : profiles) {

            profileNames[i] = profileA.getId().toString();


            Double maxPearson = Double.MIN_VALUE;
            Profile maxProfile = profileA;

            int j = 0;

            for (Profile profileB : profiles) {
                if (profileA.equals(profileB)) {
                    distanceMatrix[i][j] = 0;
                    j++;
                    continue;
                }

                double[] vectorA = profileA.getVector();
                double[] vectorB = profileB.getVector();

                PearsonsCorrelation pearson = new PearsonsCorrelation();
                Double pearsonCorrelation = pearson.correlation(vectorA, vectorB);

                if (pearsonCorrelation >= maxPearson) {
                    maxPearson = pearsonCorrelation;
                    maxProfile = profileB;
                }

                double[] profileAasDouble = UtilsTransform.intArrayToDouble(profileA.getColors());
                double[] profileBasDouble = UtilsTransform.intArrayToDouble(profileB.getColors());

                Double pearsonOfColors = pearson.correlation(profileAasDouble, profileBasDouble);
                distanceMatrix[i][j] = pearsonOfColors;
                j++;
            }

            profileA.setCorrelatedVector(maxProfile.getListWrapper());

            SortedSet<StringDouble> positivePeptides = UtilsStatistics.influentialPeptides(
                    profileA.getVector(), maxProfile.getVector(), referenceProfile, true);

            profileA.setPositivePeptides(UtilsTransform.SortedSetToHTML(positivePeptides, false));

            DecimalFormat df = new DecimalFormat("0.0000");
            String peptideCorrelation = " <br/><br/><b style=\"color: #23527c;\">%s</b>";

            profileA.setPositiveCorrelation(maxProfile.toString() + String.format(peptideCorrelation, df.format(maxPearson)));

            profileRepository.save(profileA);
            i++;
        }
    }
}
 
开发者ID:uc-bd2k,项目名称:Pilincs,代码行数:70,代码来源:DatabaseLoader.java


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