Challenge - 5 Problems
Mann-Whitney U Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Mann-Whitney U test on two small samples
What is the output of the Mann-Whitney U test for the following two samples using scipy.stats.mannwhitneyu with default parameters?
SciPy
from scipy.stats import mannwhitneyu sample1 = [1, 3, 5] sample2 = [2, 4, 6] result = mannwhitneyu(sample1, sample2) print((result.statistic, round(result.pvalue, 4)))
Attempts:
2 left
💡 Hint
Remember that the Mann-Whitney U statistic counts how many times values in one sample exceed values in the other.
✗ Incorrect
The Mann-Whitney U statistic for these samples is 3.0, and the two-sided p-value is 0.5. The default alternative hypothesis is 'two-sided'.
❓ data_output
intermediate1:00remaining
Number of items in the output of mannwhitneyu
How many values are returned by scipy.stats.mannwhitneyu when called on two samples?
SciPy
from scipy.stats import mannwhitneyu sample1 = [10, 20, 30] sample2 = [15, 25, 35] result = mannwhitneyu(sample1, sample2) print(len(result))
Attempts:
2 left
💡 Hint
Check the type of the result and what attributes it has.
✗ Incorrect
The mannwhitneyu function returns an object with two main values: the U statistic and the p-value.
🔧 Debug
advanced1:30remaining
Identify the error in this Mann-Whitney U test code
What error does the following code raise when run?
SciPy
from scipy.stats import mannwhitneyu sample1 = [1, 2, 3] sample2 = [4, 5] result = mannwhitneyu(sample1, sample2, alternative='greater') print(result.statistic, result.pvalue)
Attempts:
2 left
💡 Hint
Check the scipy.stats.mannwhitneyu documentation for valid parameters.
✗ Incorrect
The 'alternative' parameter is valid and 'greater' is accepted. The code runs without error and prints the statistic and p-value.
🧠 Conceptual
advanced1:30remaining
Interpretation of Mann-Whitney U test p-value
If the Mann-Whitney U test returns a p-value of 0.03 for two independent samples, what does this mean?
Attempts:
2 left
💡 Hint
Recall that a p-value below 0.05 usually means rejecting the null hypothesis.
✗ Incorrect
A p-value of 0.03 means the observed difference is unlikely under the null hypothesis, so we reject it and conclude the distributions differ.
🚀 Application
expert2:00remaining
Choosing the correct Mann-Whitney U test alternative hypothesis
You want to test if sample A tends to have larger values than sample B. Which 'alternative' parameter should you use in scipy.stats.mannwhitneyu?
Attempts:
2 left
💡 Hint
Think about the direction of the hypothesis you want to test.
✗ Incorrect
The 'greater' alternative tests if values in sample A tend to be larger than those in sample B.