Java Code Examples for org.apache.commons.math3.stat.inference.MannWhitneyUTest#mannWhitneyU()
The following examples show how to use
org.apache.commons.math3.stat.inference.MannWhitneyUTest#mannWhitneyU() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MannWhitneyUEvaluator.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public Object doWork(Object... values) throws IOException { @SuppressWarnings({"unchecked"}) 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)); Tuple tuple = new Tuple(); tuple.put("u-statistic", u); tuple.put(StreamParams.P_VALUE, p); return tuple; }else{ 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())); } }
Example 2
Source File: ComputeMannWhitneyUCommand.java From megan-ce with GNU General Public License v3.0 | 5 votes |
public void apply(NexusStreamParser np) throws Exception { np.matchIgnoreCase(getSyntax()); 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); }