double MannWhitneyTest(TVec *Data1, TVec *Data2, THypothesisResult &hRes, double &Signif, DewArray<double> &ConfInt, const THypothesisType hType = THypothesisType::htTwoTailed, const double Alpha = 0.05, const bool NormalApprox = true);
Two sample Mann-Whitney test.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Data1 | TVec * | First sample dataset. |
| 2 | Data2 | TVec * | Second sample dataset. |
| 3 | hRes | THypothesisResult & | Returns the result of the null hypothesis (default assumption is that there is no difference between samples). |
| 4 | Signif | double & | (Significance level) returns the probability of observing the given result |
| 5 | ConfInt | DewArray<double> & | Returns the 100*(1-Alpha) percent confidence interval for Mann-Whitney test. Valid only if normal approximation is used to calculate significance level. |
| 6 | hType = THypothesisType::htTwoTailed | const THypothesisType | Defines the type of the null hypothesis (left, right and two - tailed). |
| 7 | Alpha = 0.05 | const double | Defines the desired significance level. If the significance probability (Signif) is bellow the desired significance (Alpha), the null hypothesis is rejected. |
| 8 | NormalApprox = true | const bool | If either of the sample size is greater than 8, a z-value can be used to approximate the significance level for the test. In this case, the calculated z is compared to the standard normal significance levels. Set NormalApprox to true if you want normal approximation for significance level. |
Returns: The Mann-Whitney statistics (U, the smallest value of U1 and U2).
Performs two sample Mann-Whitney test. This is a method for the comparison of two independent random samples (Data1 and Data2). The Mann Whitney U statistic is defined as:
U1 = n1*n2 + 0.5*(n2+1)*n2 - sum (i=n1+1, n2) Ri
where samples of size n1 and n2 are pooled and Ri are the ranks. Actually, there are two versions of the U statistic calculated, where U2 = n1n2 - U1, where n1 and n2 are the sample sizes of the two groups. The smallest of U1 or U2 is compared to the critical value for the purpose of the test.
U can be resolved as the number of times observations in one sample precede observations in the other sample in the ranking. Wilcoxon rank sum, Kendall's S and the Mann-Whitney U test are exactly equivalent tests. In the presence of ties the Mann-Whitney test is also equivalent to a chi-square test for trend.
In most circumstances a two sided test is required; here the alternative hypothesis is that Data1 values tend to be distributed differently to Data2 values. For a lower side test the alternative hypothesis is that Data1 values tend to be smaller than Data2 values. For an upper side test the alternative hypothesis is that Data1 values tend to be larger than Data2 values.
Assumptions of the Mann-Whitney test:
- random samples from populations
- independence within samples and mutual independence between samples
- measurement scale is at least ordinal
A confidence interval for the difference between two measures of location is provided with the sample medians. The assumptions of this method are slightly different from the assumptions of the Mann-Whitney test:
- random samples from populations
- independence within samples and mutual independence between samples
- two population distribution functions are identical apart from a possible difference in location parameters