You need to enable JavaScript to run this app.
ByteHouse Enterprise Edition

ByteHouse Enterprise Edition

Copy page
Download PDF
Aggregate function
mannwhitneyutest
Copy page
Download PDF
mannwhitneyutest

Applies the Mann-Whitney rank test to samples of two populations.
Syntax

mannWhitneyUTest[(alternative[, continuity_correction])](sample_data, sample_index)

The values for both samples are in the sample_data column. If sample_index equals to 0, then the value in that row belongs to the sample of the first population. Otherwise, it belongs to the sample of the second population.
The null hypothesis is that the two populations are randomly equal. One-sided hypotheses can also be tested. This test does not assume that the data has a normal distribution.
Param
sample_data— Sample data. Integer, Float, or Decimal.
sample_index— Sample index. Integer.
Param
alternative— Alternative hypothesis. (Optional; 'two-sided' is the default.) String.

'two-sided';
'greater';
'less'

continuity_correction: If not 0, a continuity correction is carried on for the normal approximation of the P-value. (Optional, Default: 1.) UInt64.
Return value
A tuple with two elements:

  • The U statistic calculated. Float64。
  • The calculated P-value. Float64。

Example
Input table:

┌─sample_data─┬─sample_index─┐ 
│          10 │            0 │ 
│          11 │            0 │ 
│          12 │            0 │ 
│           1 │            1 │ 
│           2 │            1 │ 
│           3 │            1 │ 
└─────────────┴──────────────┘

Search:

SELECT mannWhitneyUTest('greater')(sample_data, sample_index) FROM mww_ttest;

As a result:

┌─mannWhitneyUTest('greater')(sample_data, sample_index)─┐ 
│ (9,0.04042779918503192)                                │ 
└────────────────────────────────────────────────────────┘

See also
Mann–Whitney U test
Stochastic ordering

Last updated: 2026.03.31 11:50:00