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