double p = getSignificance(correlation1, correlation2, n1, n2);
public void addXValue(final String id, final double value) { ValuesAndRanks vr = data.get(id); if (vr == null) { vr = new ValuesAndRanks(); data.put(id, vr); } vr.xData = value; }
@Override public int compare(final ValuesAndRanks o1, final ValuesAndRanks o2) { final Object data1 = o1.getData(dataType); final Object data2 = o2.getData(dataType); int result = 0; if (sortDescending) { result = ((Comparable) data2).compareTo(data1); } else { result = ((Comparable) data1).compareTo(data2); } return result; }
/** * 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. */ public static double computeCorrelation(List<Double> list1, List<Double> list2) { SpearmansRankCorrelation_old src = new SpearmansRankCorrelation_old(); for (int i=0; i< list1.size(); i++) { src.addXValue(new Integer(i).toString(), list1.get(i)); src.addYValue(new Integer(i).toString(), list2.get(i)); i++; } return src.calculate(); }
private Correction setRanks(int dataType, List<ValuesAndRanks> valueList) { Correction correction = new Correction(); Collections.sort(valueList, new Comp(dataType, sortDescending)); int tmp = start+1; int tmpRank = rank; Object startValue = valueList.get(start).getData(dataType); while(tmp < valueList.size()) { if(!startValue.equals(valueList.get(tmp).getData(dataType))) { break; valueList.get(i).setRank(dataType, realRank);
/** * 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. */ public static double computeCorrelation(final List<Double> list1, final List<Double> list2) { final double[] doubleArray1 = new double[list1.size()]; final double[] doubleArray2 = new double[list2.size()]; int off1 = 0; for (final double item : list1) { doubleArray1[off1] = item; off1++; } int off2 = 0; for (final double item : list2) { doubleArray2[off2] = item; off2++; } final double correlation = computeCorrelation(doubleArray1, doubleArray2); return correlation; }
/** * Computes the significance of the difference between two correlations. * @see org.tud.sir.util.statistics.Significance.testCorrelations */ public static double getSignificance(double correlation1, double correlation2, int n1, int n2) throws MathException { // transform to Fisher Z-values double zv1 = getZValue(correlation1); double zv2 = getZValue(correlation2); // difference of the Z-values double zDifference = (zv1 - zv2) / Math.sqrt( (double)1/(n1-3) + (double)1/(n2-3)); // get p value from the normal distribution NormalDistribution normal = new NormalDistributionImpl(); double p = 2 * (1 - normal.cumulativeProbability( Math.abs(zDifference))); return p; }
public static Map<String, Double> calculate(Id2Outcome id2Outcome) { Map<String, Double> results = new HashMap<String, Double>(); Double[] goldstandard = ArrayUtils.toObject(id2Outcome.getGoldValues()); Double[] prediction = ArrayUtils.toObject(id2Outcome.getPredictions()); results.put(SpearmanCorrelation.class.getSimpleName(), SpearmansRankCorrelation.computeCorrelation(Arrays.asList(goldstandard), Arrays.asList(prediction))); return results; } }
/** * 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. */ public static double computeCorrelation(final List<Double> list1, final List<Double> list2) { final SpearmansRankCorrelation_old src = new SpearmansRankCorrelation_old(); for (int i = 0; i < list1.size(); i++) { src.addXValue(new Integer(i).toString(), list1.get(i)); src.addYValue(new Integer(i).toString(), list2.get(i)); i++; } return src.calculate(); }
private Correction setRanks(final int dataType, final List<ValuesAndRanks> valueList) final Correction correction = new Correction(); Collections.sort(valueList, new Comp(dataType, sortDescending)); int tmp = start + 1; int tmpRank = rank; final Object startValue = valueList.get(start).getData(dataType); while (tmp < valueList.size()) { if (!startValue.equals(valueList.get(tmp).getData(dataType))) { break; valueList.get(i).setRank(dataType, realRank);
/** * 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. */ public static double computeCorrelation(List<Double> list1, List<Double> list2) { double[] doubleArray1 = new double[list1.size()]; double[] doubleArray2 = new double[list2.size()]; int off1 = 0; for (double item : list1) { doubleArray1[off1] = item; off1++; } int off2 = 0; for (double item : list2) { doubleArray2[off2] = item; off2++; } double correlation = computeCorrelation(doubleArray1, doubleArray2); return correlation; }
public void addXValue(String id, double value) { ValuesAndRanks vr = data.get(id); if(vr == null) { vr = new ValuesAndRanks(); data.put(id, vr); } vr.xData = value; }
public int compare(ValuesAndRanks o1, ValuesAndRanks o2) { Object data1 = o1.getData(dataType); Object data2 = o2.getData(dataType); int result = 0; if(sortDescending) { result = ((Comparable)data2).compareTo(data1); } else { result = ((Comparable)data1).compareTo(data2); } /* if(result==0) nTiedRanks++; */ return result; }
/** * @throws MathException * @throws IllegalArgumentException * @see org.tud.sir.util.statistics.Significance#getSignificance(double[], double[]) */ public static double getSignificance(List<Double> list1, List<Double> list2) throws IllegalArgumentException, MathException { double[] doubleArray1 = new double[list1.size()]; double[] doubleArray2 = new double[list2.size()]; int off1 = 0; for (double item : list1) { doubleArray1[off1] = item; off1++; } int off2 = 0; for (double item : list2) { doubleArray2[off2] = item; off2++; } return getSignificance(doubleArray1, doubleArray2); }
public static Map<String, Double> calculate(Id2Outcome id2Outcome) { Map<String, Double> results = new HashMap<String, Double>(); double[] goldstandard = id2Outcome.getGoldValues(); double[] prediction = id2Outcome.getPredictions(); results.put( PearsonCorrelation.class.getSimpleName(), de.tudarmstadt.ukp.dkpro.statistics.correlation.PearsonCorrelation.computeCorrelation(goldstandard, prediction) ); return results; } }
public void addYValue(final String id, final double value) { ValuesAndRanks vr = data.get(id); if (vr == null) { vr = new ValuesAndRanks(); data.put(id, vr); } vr.yData = value; }
public void addYValue(String id, double value) { ValuesAndRanks vr = data.get(id); if(vr == null) { vr = new ValuesAndRanks(); data.put(id, vr); } vr.yData = value; }