List of usage examples for org.apache.commons.math.stat.correlation SpearmansCorrelation correlation
public double correlation(final double[] xArray, final double[] yArray) throws IllegalArgumentException
From source file:cal.binBased.Calculate_BinSpectrum_Similarity.java
/** * This method calculates correlation coefficients between two MSnSpectrum * object while taking into account of intensities of the mutual peaks. A * perfect score is 1 (or -1). And value range is [-1:1] * *///from ww w . j a v a 2s. co m public void calculateCorrelation() { // TODO: Make sure if any of binSpectra is empty, score i NaN! if (sim_method.equals(SimilarityMethods.SPEARMANS_CORRELATION)) { SpearmansCorrelation sc = new SpearmansCorrelation(); score = sc.correlation(bin_specA.getBin_spectrum(), bin_specB.getBin_spectrum()); } else if (sim_method.equals(SimilarityMethods.PEARSONS_CORRELATION)) { PearsonsCorrelation pc = new PearsonsCorrelation(); score = pc.correlation(bin_specA.getBin_spectrum(), bin_specB.getBin_spectrum()); } }
From source file:org.dkpro.statistics.correlation.SpearmansRankCorrelation.java
/** * Computes the correlation between two datasets. * @param list1 The first dataset as a list. * @param list2 The second dataset as a list. * @return The correlation between the two datasets. *//*from ww w. j a v a 2 s .co m*/ public static double computeCorrelation(List<Double> list1, List<Double> list2) { double[] l1 = new double[list1.size()]; double[] l2 = new double[list2.size()]; for (int i = 0; i < list1.size(); i++) { l1[i] = list1.get(i); } for (int i = 0; i < list2.size(); i++) { l2[i] = list2.get(i); } SpearmansCorrelation sc = new SpearmansCorrelation(); return sc.correlation(l1, l2); }