congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
MannWhitneyUTest.mannWhitneyUTest
Code IndexAdd Tabnine to your IDE (free)

How to use
mannWhitneyUTest
method
in
org.apache.commons.math3.stat.inference.MannWhitneyUTest

Best Java code snippets using org.apache.commons.math3.stat.inference.MannWhitneyUTest.mannWhitneyUTest (Showing top 2 results out of 315)

origin: org.apache.solr/solr-solrj

 @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{
   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()));
  }
 }
}
origin: SurveyMan/SurveyMan

/**
 * Mann-Whitney statistic, specialized for comparing survey questions.
 * @param q1
 * @param q2
 * @param list1
 * @param list2
 * @return
 */
public static ImmutablePair<Double, Double> mannWhitney(Question q1, Question q2, List<SurveyDatum> list1, List<SurveyDatum> list2) {
  if (list1.size()==0 || list2.size()==0) {
    SurveyMan.LOGGER.warn(String.format("Cannot compare response lists of sizes: %d and %d", list1.size(), list2.size()));
    return new ImmutablePair<>(-0.0, -0.0);
  }
  // make ranks on the basis of the source row index
  Collections.sort(list1);
  Collections.sort(list2);
  double[] list1ranks = new double[list1.size()];
  double[] list2ranks = new double[list2.size()];
  for (int i = 0 ; i < list1.size() ; i++)
    list1ranks[i] = (double) list1.get(i).getSourceRow() - q1.getSourceRow() + 1;
  for (int i = 0 ; i < list2.size() ; i++)
    list2ranks[i] = (double) list2.get(i).getSourceRow() - q2.getSourceRow() + 1;
  // default constructor for mann whitney averages ties.
  MannWhitneyUTest test = new MannWhitneyUTest();
  double testStatistic = test.mannWhitneyU(list1ranks, list2ranks);
  double pvalue = test.mannWhitneyUTest(list1ranks, list2ranks);
  return new ImmutablePair<>(testStatistic, pvalue);
}
org.apache.commons.math3.stat.inferenceMannWhitneyUTestmannWhitneyUTest

Javadoc

Returns the asymptotic observed significance level, or p-value, associated with a Mann-Whitney U statistic comparing mean for two independent samples.

Let Xi denote the i'th individual of the first sample and Yj the j'th individual in the second sample. Note that the samples would often have different length.

Preconditions:

  • All observations in the two samples are independent.
  • The observations are at least ordinal (continuous are also ordinal).
Ties give rise to biased variance at the moment. See e.g. http://mlsc.lboro.ac.uk/resources/statistics/Mannwhitney.pdf.

Popular methods of MannWhitneyUTest

  • mannWhitneyU
    Computes the Mann-Whitney U statistic [http://en.wikipedia.org/wiki/Mann%E2%80%93Whitney_U] comparin
  • calculateAsymptoticPValue
  • concatenateSamples
    Concatenate the samples into one array.
  • ensureDataConformance
    Ensures that the provided arrays fulfills the assumptions.
  • <init>
    Create a test instance using the given strategies for NaN's and ties. Only use this if you are sure

Popular in Java

  • Making http requests using okhttp
  • onCreateOptionsMenu (Activity)
  • setScale (BigDecimal)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now