This commit is contained in:
Nikita Mikhaylov 2021-04-26 21:07:30 +03:00
parent 1a5b18cf52
commit 7dc0f27c88
2 changed files with 6 additions and 0 deletions

View File

@ -48,6 +48,11 @@ std::pair<RanksArray, Float64> computeRanksAndTieCorrection(const Values & value
++right;
auto adjusted = (left + right + 1.) / 2.;
auto count_equal = right - left;
/// Scipy implementation throws exception in this case too.
if (count_equal == size)
throw Exception("All numbers in both samples are identical", ErrorCodes::BAD_ARGUMENTS);
tie_numenator += std::pow(count_equal, 3) - count_equal;
for (size_t iter = left; iter < right; ++iter)
out[indexes[iter]] = adjusted;

View File

@ -6,4 +6,5 @@ SELECT '223.0', '0.5426959774289482';
WITH mannWhitneyUTest(left, right) AS pair SELECT roundBankers(pair.1, 16) as t_stat, roundBankers(pair.2, 16) as p_value from mann_whitney_test;
WITH mannWhitneyUTest('two-sided', 1)(left, right) as pair SELECT roundBankers(pair.1, 16) as t_stat, roundBankers(pair.2, 16) as p_value from mann_whitney_test;
WITH mannWhitneyUTest('two-sided')(left, right) as pair SELECT roundBankers(pair.1, 16) as t_stat, roundBankers(pair.2, 16) as p_value from mann_whitney_test;
WITH mannWhitneyUTest('two-sided')(1, right) AS pair SELECT roundBankers(pair.1, 16) AS t_stat, roundBankers(pair.2, 16) AS p_value FROM mann_whitney_test; --{serverError 36}
DROP TABLE IF EXISTS mann_whitney_test;