0
$\begingroup$

I am using scipy.stats.mannwhitneyu to apply mann-whitney test to check my hypothesis on two categories. However, I am interested in finding the median values which are computed to apply mann-whitney. Is there any way I can print those values in the aforementioned library?

Thanking in anticipation.

$\endgroup$
2
  • $\begingroup$ How are your values for the array-like stored? lists? $\endgroup$ – chemicalwill May 3 at 19:57
  • 1
    $\begingroup$ How about printing medians directly from data. Are you sure samples are of comparable shape so you can view M-W as a test of diff btw 2 medians? [In R, anyhow, medians are not part of the output for two-sample 'wilcox.test'.] $\endgroup$ – BruceET May 3 at 21:26
2
$\begingroup$

Mann-Whitney $U$ test is not a test of median, but rather a more general test on whether the two sample distributions are different - see this BMJ article for a discussion.

Thus, it is unlikely for an implementation of the Mann-Whitney test to compute the median of the two samples and run any direct comparisons between them, as there is no need to do that to calculate the test statistic. The implementation in SciPy is no exception.

Having that said, given you are using scipy.stats.mannwhitneyu, which requires two array-like arguments that represent the two samples. You can simply calculate the medians by running each argument through any library that calculate the median of an array, e.g. numpy.median.

$\endgroup$
1
  • $\begingroup$ Okay. It clarifies everything. Thank you so much :) $\endgroup$ – Anees May 4 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.