Search in sources :

Example 1 with SpearmansCorrelation

use of org.apache.commons.math3.stat.correlation.SpearmansCorrelation in project gdsc by aherbert.

the class ParticleCorrelation_PlugIn method addSummary.

private void addSummary(String title, double[] sum1, double[] sum2) {
    final BlockRealMatrix rm = new BlockRealMatrix(sum1.length, 2);
    rm.setColumn(0, sum1);
    rm.setColumn(1, sum2);
    final SpearmansCorrelation sr = new SpearmansCorrelation(rm);
    final PearsonsCorrelation p1 = sr.getRankCorrelation();
    final PearsonsCorrelation p2 = new PearsonsCorrelation(rm);
    final StringBuilder sb = new StringBuilder(title);
    sb.append(sum1.length).append('\t');
    sb.append(MathUtils.rounded(p1.getCorrelationMatrix().getEntry(0, 1))).append('\t');
    sb.append(MathUtils.rounded(p1.getCorrelationPValues().getEntry(0, 1))).append('\t');
    sb.append(MathUtils.rounded(p2.getCorrelationMatrix().getEntry(0, 1))).append('\t');
    sb.append(MathUtils.rounded(p2.getCorrelationPValues().getEntry(0, 1)));
    twSummary.append(sb.toString());
}
Also used : SpearmansCorrelation(org.apache.commons.math3.stat.correlation.SpearmansCorrelation) BlockRealMatrix(org.apache.commons.math3.linear.BlockRealMatrix) PearsonsCorrelation(org.apache.commons.math3.stat.correlation.PearsonsCorrelation)

Aggregations

BlockRealMatrix (org.apache.commons.math3.linear.BlockRealMatrix)1 PearsonsCorrelation (org.apache.commons.math3.stat.correlation.PearsonsCorrelation)1 SpearmansCorrelation (org.apache.commons.math3.stat.correlation.SpearmansCorrelation)1