Example usage for org.apache.commons.math3.stat.inference MannWhitneyUTest MannWhitneyUTest

List of usage examples for org.apache.commons.math3.stat.inference MannWhitneyUTest MannWhitneyUTest

Introduction

In this page you can find the example usage for org.apache.commons.math3.stat.inference MannWhitneyUTest MannWhitneyUTest.

Prototype

public MannWhitneyUTest() 

Source Link

Document

Create a test instance using where NaN's are left in place and ties get the average of applicable ranks.

Usage

From source file:mase.spec.MannTest.java

public static void main(String[] args) {
    /*double[] b = new double[]{1,2,3,4,5};
    double[] a  = new double[]{6,7,8,9,10};*/
    /*double[] a = new double[]{1,2,3,4,5};
    double[] b  = new double[]{6,7,8,9,10};*/
    double[] a = new double[] { 1, 3, 5, 7, 9 };
    double[] b = new double[] { 0, 2, 4, 6, 8, 10 };
    MannWhitneyUTest test = new MannWhitneyUTest();
    double u1 = test.mannWhitneyU(a, b);
    double u2 = test.mannWhitneyU(b, a);
    System.out.println(u1 + " " + u2 + " Max: " + a.length * b.length);
}

From source file:exec.validate_evaluation.greedy_and_endgoal.GreedyAndEndGoalEval.java

public static void main(String[] args) {
    double[] a = new double[] { 1, 2, 3, 2, 2, 2, 2 };
    double[] b = new double[] { 2, 3.1, 4, 3, 3, 3, 3, 3 };

    MannWhitneyUTest test = new MannWhitneyUTest();
    double pVal = test.mannWhitneyUTest(a, b);
    double pVal2 = test.mannWhitneyU(a, b);
    System.out.println("pval  = " + pVal + ";\nwert2: " + pVal2);
}

From source file:br.unicamp.ic.recod.gpsi.measures.gpsiWilcoxonRankSumTestScore.java

@Override
public double score(double[][][] samples) {
    double p_value;

    RealMatrix m0 = MatrixUtils.createRealMatrix(samples[0]);
    RealMatrix m1 = MatrixUtils.createRealMatrix(samples[1]);

    MannWhitneyUTest t = new MannWhitneyUTest();
    p_value = t.mannWhitneyUTest(m0.getColumn(0), m1.getColumn(0));

    return p_value;
}

From source file:megan.commands.ComputeMannWhitneyUCommand.java

public void apply(NexusStreamParser np) throws Exception {
    np.matchIgnoreCase(getSyntax());/*from w w w.jav a 2 s  .  co m*/

    final Document doc = getDir().getDocument();
    int numberSelectedNodes = ((ViewerBase) getViewer()).getNumberSelectedNodes();

    MannWhitneyUTest mannWhitneyUTest = new MannWhitneyUTest();

    double[] x = new double[numberSelectedNodes];
    double[] y = new double[numberSelectedNodes];

    ViewerBase viewer = (ViewerBase) getViewer();
    int count = 0;
    for (Node v : viewer.getSelectedNodes()) {
        if (v.getOutDegree() > 0) {
            x[count] = ((NodeData) v.getData()).getAssigned(0);
            y[count] = ((NodeData) v.getData()).getAssigned(1);
        } else {
            x[count] = ((NodeData) v.getData()).getSummarized(0);
            y[count] = ((NodeData) v.getData()).getSummarized(1);
        }
    }
    double p = mannWhitneyUTest.mannWhitneyUTest(x, y);
    final String message = "Mann Whitney U Test for " + doc.getNumberOfSamples() + " samples based on "
            + numberSelectedNodes + " selected nodes:\n" + "U value=" + mannWhitneyUTest.mannWhitneyU(x, y)
            + "\n" + "p-value=" + (float) p + "\n";
    //System.err.println(message);
    NotificationsInSwing.showInformation(getViewer().getFrame(), message);
}

From source file:ch.unil.genescore.pathway.test.RankSumTestTest.java

/** Test PathwayMain.run() */
@Test/*from   ww w  . j  av  a  2 s  . c o  m*/
public void testRankSumTest() {
    double[] testdata1 = { 0.8, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46 };
    double[] testdata2 = { 1.15, 0.88, 0.9, 0.74, 1.21 };

    // Null constructor
    RankSumTest testclass2 = new RankSumTest();
    double pValue = testclass2.pValue("equal", testdata1, testdata2);
    assertEquals(pValue, 0.2544, 0.001);//copied from R
    pValue = testclass2.pValue("greater", testdata1, testdata2);
    assertEquals(pValue, 1 - 0.1272, 0.001);//copied from R

    MannWhitneyUTest test = new MannWhitneyUTest();

    double pval = test.mannWhitneyUTest(testdata1, testdata2);
    System.out.println("");
    MannWhitneyTest test3 = new MannWhitneyTest(testdata1, testdata2);
    double pval3 = test3.approxSP();
    double pval4 = test3.exactSP();
    assertEquals(pval3, 0.2446, 0.001);
    assertEquals(pval4, 0.2544, 0.001);

    MannWhitneyTest test4 = new MannWhitneyTest(testdata1, testdata2, H1.GREATER_THAN);
    double pval5 = test4.approxSP();
    double pval6 = test4.exactSP();
    assertEquals(pval5, 0.1227, 0.001);
    assertEquals(pval6, 0.1272, 0.001);

    System.out.println("");

}

From source file:exec.validate_evaluation.greedy_and_endgoal.GreedyAndEndGoalEval.java

public void run() {

    BoxplotData bpdGreedy = new BoxplotData();
    BoxplotData bpdGoal = new BoxplotData();

    System.out.println();// w ww.  ja  v  a 2  s. c o  m
    System.out.println("reading histories...");
    Map<ICoReTypeName, List<List<Usage>>> histories = readHistories();

    System.out.println("finding usages...");
    Set<ICoReTypeName> findKeys = usages.findKeys();

    System.out.printf("finding type: ");
    for (ICoReTypeName type : findKeys) {

        if (!histories.containsKey(type)) {
            System.out.printf(".");
            continue;
        }
        System.out.println();

        System.out.printf("### %s ###\n", type);

        System.out.println("learning recommender...");
        ICallsRecommender<Query> rec = mh.get(type);

        System.out.printf("eval: ");
        for (List<Usage> hist : histories.get(type)) {
            System.out.printf("|");
            int lastIdx = hist.size() - 1;
            for (int i = 0; i < lastIdx; i++) {
                System.out.printf(".");
                Usage query = hist.get(i);

                Usage greedyExpectation = hist.get(i + 1);
                Usage goalExpectation = hist.get(lastIdx);

                if (shouldProcess(query, greedyExpectation)) {
                    bpdGreedy.add(measurePredictionQuality(rec, query, greedyExpectation));
                }

                if (shouldProcess(query, goalExpectation)) {
                    bpdGoal.add(measurePredictionQuality(rec, query, goalExpectation));
                }
            }
        }
        System.out.println();
        System.out.printf("finding type: ");
    }
    System.out.println();
    System.out.println();

    System.out.println("results:");
    System.out.printf("greedy: %s\n", bpdGreedy.getBoxplot());
    System.out.printf("goal: %s\n", bpdGoal.getBoxplot());

    MannWhitneyUTest mut = new MannWhitneyUTest();
    System.out.printf("p-value: %.3f\n",
            mut.mannWhitneyUTest(bpdGreedy.getRawValues(), bpdGoal.getRawValues()));
}

From source file:mase.spec.SafeHybridExchanger.java

private double fitnessDifference(MetaPopulation reference, MetaPopulation other, EvolutionState state) {
    // search foreign of reference in other
    Foreign f = null;//from  w w  w  .j av a  2  s.  c o m
    for (Foreign fOther : other.foreigns) {
        if (fOther.origin == reference) {
            f = fOther;
            break;
        }
    }
    if (f == null || f.inds == null) {
        return Double.POSITIVE_INFINITY;
    }

    // pick individuals from the reference population, using the same method used to pick the foreign individuals
    Individual[] refInds = pickIndividuals(reference.inds, f.inds.length, foreignMode, state);

    if (differenceMode == DifferenceMode.mean) {
        double refFit = 0;
        for (Individual i : refInds) {
            refFit += i.fitness.fitness();
        }
        double foreignFit = 0;
        for (Individual i : f.inds) {
            foreignFit += i.fitness.fitness();
        }
        return refFit == 0 ? Double.POSITIVE_INFINITY : Math.abs(refFit - foreignFit) / Math.abs(refFit);
    } else if (differenceMode == DifferenceMode.max) {
        double refFit = Double.NEGATIVE_INFINITY;
        for (Individual i : refInds) {
            refFit = Math.max(refFit, i.fitness.fitness());
        }
        double foreignFit = Double.NEGATIVE_INFINITY;
        for (Individual i : f.inds) {
            foreignFit = Math.max(foreignFit, i.fitness.fitness());
        }
        return refFit == 0 ? Double.POSITIVE_INFINITY : Math.abs(refFit - foreignFit) / Math.abs(refFit);
    } else if (differenceMode == DifferenceMode.utest) {
        double[] refFits = new double[refInds.length];
        double[] forFits = new double[f.inds.length];
        for (int i = 0; i < refFits.length; i++) {
            refFits[i] = refInds[i].fitness.fitness();
        }
        for (int i = 0; i < forFits.length; i++) {
            forFits[i] = f.inds[i].fitness.fitness();
        }
        MannWhitneyUTest test = new MannWhitneyUTest();
        return test.mannWhitneyU(refFits, forFits) / (refFits.length * forFits.length);
    } else {
        return Double.NaN;
    }
}

From source file:gedi.riboseq.inference.orf.OrfFinder.java

public MemoryIntervalTreeStorage<Orf> computeChunk(int index, ReferenceSequence ref, int start, int end,
        Consumer<ImmutableReferenceGenomicRegion<IntervalTreeSet<Codon>>> codonOutProc) { //DiskGenomicNumericBuilder codon, DiskGenomicNumericBuilder[] perCondCodon

    MutableMonad<ToDoubleFunction<Collection<Codon>>> gofComp = new MutableMonad<ToDoubleFunction<Collection<Codon>>>();
    ImmutableReferenceGenomicRegion<IntervalTreeSet<Codon>> codons = inference.inferCodons(reads, ref, start,
            end, maxAminoDist * 3, gofComp);

    if (codonOutProc != null)
        codonOutProc.accept(codons);//w ww .j  av a  2  s.c  o m

    //      if (codon!=null) {
    //         synchronized (codon) {
    //            float[] data = new float[3];
    //            for (Codon c : codons.getData()) {
    //               if (c.getTotalActivity()==0) continue;
    //               
    //               setRmq(codon, ref, 
    //                     codons.map(c.map(ref.getStrand().equals(Strand.Minus)?2:0)),0,
    //                     c.getTotalActivity(), data);
    //               setRmq(codon, ref, 
    //                     codons.map(c.map(1)),1,
    //                     c.getTotalActivity(), data);
    //               setRmq(codon, ref, 
    //                     codons.map(c.map(ref.getStrand().equals(Strand.Minus)?0:2)),2,
    //                     c.getTotalActivity(), data);
    //               
    ////               int genomic = codons.map(ref.getStrand().equals(Strand.Minus)?c.getStop():c.getStart());
    ////               data[genomic%3] = (float) c.getTotalActivity();
    ////               codon.addValueEx(ref, genomic, data); // FIX: spliced codons!
    ////               codon.addValueEx(ref, genomic+1, data);
    ////               codon.addValueEx(ref, genomic+2, data);
    ////               data[genomic%3] = 0;
    //            }            
    //         }
    //      }
    //      
    //      if (perCondCodon!=null) {
    //         synchronized (perCondCodon) {
    //            float[] data = new float[3];
    //            for (int i=0; i<perCondCodon.length; i++) {
    //               for (Codon c : codons.getData()) {
    //                  if (c.getActivity()[i]==0) continue;
    //                  
    //                  setRmq(perCondCodon[i], ref, 
    //                        codons.map(c.map(ref.getStrand().equals(Strand.Minus)?2:0)),0,
    //                        c.getActivity()[i], data);
    //                  setRmq(perCondCodon[i], ref, 
    //                        codons.map(c.map(1)),1,
    //                        c.getActivity()[i], data);
    //                  setRmq(perCondCodon[i], ref, 
    //                        codons.map(c.map(ref.getStrand().equals(Strand.Minus)?0:2)),2,
    //                        c.getActivity()[i], data);
    //                  
    ////                  int genomic = codons.map(ref.getStrand().equals(Strand.Minus)?c.getStop():c.getStart());
    ////                  data[genomic%3] = (float) c.getActivity()[i];
    ////                  perCondCodon[i].addValueEx(ref, genomic, data);
    ////                  perCondCodon[i].addValueEx(ref, genomic+1, data);
    ////                  perCondCodon[i].addValueEx(ref, genomic+2, data);
    ////                  data[genomic%3] = 0;
    //               }
    //            }
    //         }
    //      }

    SpliceGraph sg = new SpliceGraph(0, end - start);

    CharSequence sequence = inference.getGenome().getSequence(codons);

    if (useReadSplits)
        reads.iterateIntersectingMutableReferenceGenomicRegions(ref, start, end)
                .forEachRemaining(read -> sg.addIntrons(codons.induce(read.getRegion())));
    annotation.iterateIntersectingMutableReferenceGenomicRegions(ref, start, end).forEachRemaining(tr -> {
        sg.addIntrons(codons.induce(tr.getRegion()));
    });

    if (!useReadSplits) {
        Iterator<Codon> it = codons.getData().iterator();
        while (it.hasNext()) {
            Codon c = it.next();
            for (int i = 1; i < c.getNumParts(); i++) {
                if (!sg.contains(c.getEnd(i - 1), c.getStart(i))) {
                    it.remove();
                    break;
                }
            }
        }
    }

    //      // codons region spans 1 - l-1
    //      double[] codTotal = new double[codons.getRegion().getTotalLength()+2];
    //      for (Codon c : codons.getData())
    //         codTotal[c.getStart()+1]+=c.getTotalActivity();

    RiboModel scoring = inference.getModels()[0];

    MemoryIntervalTreeStorage<Orf> re = new MemoryIntervalTreeStorage<Orf>(Orf.class);
    ArrayList<OrfWithCodons> orfs = findOrfs(index, sequence.toString(), sg, codons);

    // stitch orfs if all of them have a coverage of minStitchCoverage and are minStichDistance away from each other (and there is no stop codon...)
    tryToStitch(orfs, sg, sequence.toString());

    double totalClu = EI.wrap(codons.getData()).mapToDouble(m -> m.getTotalActivity()).sum();

    for (OrfWithCodons orf : orfs) {

        //         if (codons.map(orf.getRegion()).getStart()==143233)
        //            System.out.println(codons.map(orf.getRegion()));
        Orf oorf = orf.toOrf();
        oorf.clusterFraction = oorf.getActivityUnique() / totalClu;

        oorf.sequence = SequenceUtils.extractSequence(orf.getRegion(), sequence);

        oorf.hasStop = orf.hasStopCodon();

        oorf.startScores = new double[orf.getRegion().getTotalLength() / 3];
        oorf.changePointScores = new double[orf.getRegion().getTotalLength() / 3];
        double[][] accc = oorf.uniquePval < 0.01 ? oorf.estCodonsEach : oorf.estCodonsUnique;
        double[] ccc = null;
        for (int c = 0; c < accc.length; c++)
            ccc = ArrayUtils.add(ccc, accc[c]);
        double[] cccc = ccc.clone();
        ArrayUtils.cumSumInPlace(cccc, 1);

        for (int p = 0; p < accc[0].length; p++) {
            //            oorf.startScores[p] = scoring.computeStartScore(accc,p,accc[0].length-1, useSingleStartScores);
            if (!scoring.hasLfc())
                oorf.startScores[p] = scoring.computeSvmStartProbability(accc, p, accc[0].length - 1);
            oorf.changePointScores[p] = scoring.computeChangePointScore(ccc, p, ccc.length - 1);
        }

        if (scoring.hasLfc())
            oorf.startScores = scoring.computeSvmLfcProbabilities(accc);

        GenomicRegion eorf = orf.getRegion().extendFront(1).extendBack(1);
        double[] codTotal = new double[eorf.getTotalLength()];
        for (Codon c : codons.getData())
            if (eorf.containsUnspliced(c))
                codTotal[eorf.induce(c.getStart())] += c.getTotalActivity();

        BitVector disallowed = new BitVector(accc[0].length);
        oorf.inferredStartPosition = -1;
        boolean thisistheend = false;
        while (oorf.inferredStartPosition < 0 && !thisistheend) {

            int startCand = inferStart(oorf, ccc, cccc, disallowed, scoring.hasLfc());

            if (startCand == -1) {
                // try first and exit
                disallowed.clear();
                startCand = inferStart(oorf, ccc, cccc, disallowed, scoring.hasLfc());
                thisistheend = true;
            }

            if (startCand >= 0) {

                oorf.tmCov = NumericArrayFunction.trimmedMean(scoring.getTrim())
                        .applyAsDouble(NumericArray.wrap(ccc, startCand, ccc.length));//,ngaps,ccc.length));

                double[] sccc = ArrayUtils.slice(ccc, startCand, ccc.length);

                DoubleArrayList x = new DoubleArrayList(sccc.length);
                DoubleArrayList y = new DoubleArrayList(sccc.length);
                for (int i = 0; i < sccc.length; i++)
                    if (sccc[i] > scoring.getThreshold())
                        x.add(i);
                    else
                        y.add(i);
                double uniformity = x.isEmpty() || y.isEmpty() ? 1
                        : new MannWhitneyUTest().mannWhitneyUTest(x.toDoubleArray(), y.toDoubleArray());

                boolean stopPresent = sccc[sccc.length - 1] > scoring.getThreshold();
                Arrays.sort(sccc);
                int ngaps = 0;
                for (; ngaps < sccc.length && sccc[ngaps] <= scoring.getThreshold(); ngaps++)
                    ;

                //               double tmCov = NumericArrayFunction.trimmedMean(model.getTrim()).applyAsDouble(NumericArray.wrap(ccc,ngaps,ccc.length));
                double meanCov = ArrayUtils.sum(sccc) / sccc.length;

                int present = sccc.length - 1 - ngaps + (stopPresent ? 1 : 0);

                oorf.internalPval = scoring.computeErrorOrf(codTotal, startCand * 3 + 1, codTotal.length - 3);
                oorf.uniformityPval = uniformity;
                oorf.gapPval = (ngaps - 1.0) / (oorf.startScores.length - 1 - startCand) > scoring
                        .getGapThreshold(meanCov) ? 0 : 1;//getGapPvalue(oorf.startScores.length-1-startCand, meanCov, ngaps-1);
                oorf.presentPval = scoring.getPresentPvalue(sccc.length - 1, present);
                oorf.stopScore = scoring.computeStopScore(accc, startCand, accc[0].length - 1);

                double total = ArrayUtils.sum(sccc);
                boolean allok = //orf.getRegion().getTotalLength()/3-1-startCand>=minAaLength &&
                        total > minOrfTotalActivity && oorf.hasStop
                                && oorf.activityFraction > minIsoformFraction && oorf.tmCov > minTmCov
                                && (!filterByInternal || oorf.internalPval < 0.01);

                if (thisistheend && startCand >= 0 && total <= minOrfTotalActivity)
                    startCand = -1;

                if (allok || thisistheend)
                    oorf.inferredStartPosition = startCand;
                else
                    disallowed.putQuick(startCand, true);
            } else {
                oorf.tmCov = 0;
                oorf.internalPval = 1;
                oorf.presentPval = 1;
                oorf.gapPval = 1;
                oorf.stopScore = 0;
            }

        }

        if (oorf.inferredStartPosition > -1) {
            // recompute actitivies!
            oorf.activityUnique = ArrayUtils.sum(ccc, oorf.inferredStartPosition, ccc.length);
            for (int c = 0; c < oorf.estCodonsEach.length; c++)
                oorf.activities[c] = ArrayUtils.sum(oorf.estCodonsEach[c], oorf.inferredStartPosition,
                        oorf.estCodonsEach[c].length);
        }
        oorf.ri = 0;
        for (int c = 0; c < oorf.estCodonsEach.length; c++)
            if (oorf.activities[c] >= minOrfExperimentActivity)
                oorf.ri++;

        int bigger1 = 0;
        int missedgof = 0;
        double total = 0;
        ArrayList<Codon> orfCodons = new ArrayList<Codon>();
        for (Codon c : orf.getEstCodons())
            if (orf.getRegion().induce(c.getStart()) / 3 >= oorf.inferredStartPosition) {
                orfCodons.add(new Codon(codons.map(c), c));
                total += c.getTotalActivity();
                if (c.getTotalActivity() >= 1) {
                    bigger1++;
                    if (c.getGoodness() > scoring.getCodonGofThreshold(c.getTotalActivity()))
                        missedgof++;
                }
            }

        double gof = gofComp.Item.applyAsDouble(orfCodons);
        oorf.gof = Binomial.cumulative(missedgof, bigger1, 0.01, false, false);
        oorf.gof = gof > scoring.getOrfGofThreshold(total) ? 0 : 1;

        //         System.out.println(codons.map(orf.getRegion()));
        // odds scores are not filtered!
        oorf.passesAllFilters = orf.getRegion().getTotalLength() / 3 - 1
                - oorf.inferredStartPosition >= minAaLength && oorf.inferredStartPosition >= 0 && oorf.hasStop
                && oorf.activityFraction > minIsoformFraction && oorf.tmCov > minTmCov
                && (!filterByInternal || oorf.internalPval < 0.01) && (!filterByGap || oorf.gapPval > 0.01)
                && oorf.presentPval < 0.01 &&
                //               oorf.clusterFraction>minClusterFraction &&
                oorf.ri >= minRi
                && (!scoring.hasLfc() || oorf.startScores[oorf.inferredStartPosition] > inference.getModels()[0]
                        .getSvmLfcCutoff());

        double offframe = 0;
        double inframe = 0;

        ArrayGenomicRegion cds = orf.getRegion()
                .map(new ArrayGenomicRegion(oorf.inferredStartPosition * 3, orf.getRegion().getTotalLength()));
        for (Codon c : codons.getData().getIntervalsIntersecting(cds.getStart(), cds.getStop(),
                new ArrayList<Codon>())) {
            if (cds.containsUnspliced(c)) {
                int frame = cds.induce(c).getStart() % 3;
                if (frame == 0)
                    inframe += c.getTotalActivity();
                else
                    offframe += c.getTotalActivity();
            }
        }
        oorf.inframefraction = inframe / (inframe + offframe);

        ImmutableReferenceGenomicRegion<Orf> r = new ImmutableReferenceGenomicRegion<Orf>(ref,
                codons.map(orf.getRegion()), oorf);

        annotate(r);
        re.add(r);

        //         if (codOut!=null && r.getData().getOrfType()==OrfType.CDS) {
        //            double[] d = ArrayUtils.slice(codTotal, r.getData().getInferredStartPosition()*3+1, codTotal.length-1);
        //            try {
        //               codOut.writef("%s\t%s\t%.1f\t%s\n", r.getData().getReference().getData().getTranscriptId(),r.toLocationString(), r.getData().getActivityUnique(), StringUtils.concat(",", d));
        //            } catch (IOException e) {
        //               throw new RuntimeException("Could not write codons!",e);
        //            }
        //         }
    }

    return re;
}

From source file:ch.unil.genescore.pathway.GeneSetLibrary.java

License:asdf

/** Compute enrichment for the given set using rank-sum-Test */
private void computeRankSumPvalue(GeneSet set) {

    Set<Gene> complementSet = new HashSet<Gene>(genesForSimulation_);
    complementSet.removeAll(set.genes_);
    double[] complementVals = new double[complementSet.size()];
    double[] setVals = new double[set.genes_.size()];
    int count = 0;
    for (Gene g : set.genes_) {
        setVals[count] = g.getChi2Stat();
        count++;// www . j  a  va 2 s.c  o m
    }
    count = 0;
    for (Gene g : complementSet) {
        complementVals[count] = g.getChi2Stat();
        count++;
    }
    //   TODO cleanup
    double pval = 1;
    double pval6 = 1;

    MannWhitneyUTest test = new MannWhitneyUTest();
    try {
        pval = test.mannWhitneyUTest(setVals, complementVals);
        RankSumTest test2 = new RankSumTest();
        double pval2 = test2.pValue("greater", setVals, complementVals);
        double pval3 = test2.pValue("equal", setVals, complementVals);
        MannWhitneyTest test3 = new MannWhitneyTest(setVals, complementVals);
        double pval5 = test3.approxSP();
        MannWhitneyTest test4 = new MannWhitneyTest(setVals, complementVals, H1.GREATER_THAN);
        pval6 = test4.approxSP();
    } catch (Exception e) {

        System.out.println("Couldn't compute ManWhitneyU:" + e.getMessage());
    }

    set.setRankSumPvalue(pval6);
}

From source file:org.apache.solr.client.solrj.io.eval.MannWhitneyUEvaluator.java

@Override
public Object doWork(Object... values) throws IOException {
    List<double[]> mannWhitneyUInput = Arrays.stream(values)
            .map(value -> ((List<Number>) value).stream().mapToDouble(Number::doubleValue).toArray())
            .collect(Collectors.toList());
    if (mannWhitneyUInput.size() == 2) {
        MannWhitneyUTest mannwhitneyutest = new MannWhitneyUTest();
        double u = mannwhitneyutest.mannWhitneyU(mannWhitneyUInput.get(0), mannWhitneyUInput.get(1));
        double p = mannwhitneyutest.mannWhitneyUTest(mannWhitneyUInput.get(0), mannWhitneyUInput.get(1));
        Map<String, Number> m = new HashMap<>();
        m.put("u-statistic", u);
        m.put("p-value", p);
        return new Tuple(m);
    } else {//from  w  w w. java2 s  . com
        throw new IOException(String.format(Locale.ROOT,
                "%s(...) only works with a list of 2 arrays but a list of %d array(s) was provided.",
                constructingFactory.getFunctionName(getClass()), mannWhitneyUInput.size()));
    }
}