To perform a Mann-Whitney test in MATLAB, you can use the ranksum
function, which performs a two-sample Wilcoxon rank-sum test (equivalent to Mann-Whitney test).
The syntax for ranksum
is as follows:
main.m27 chars2 lines
where x
and y
are the vectors of the two samples being compared, p
is the p-value of the test, h
is the test decision (0 for non-rejection of the null hypothesis at the 5% significance level, 1 for rejection), and stats
is a structure containing additional statistical information.
Here's an example usage of ranksum
to compare two sets of data (x
and y
):
main.m72 chars4 lines
This will output the p-value, test decision, and stats structure for the test.
Note that ranksum
assumes that the two samples are independent and have similar distributions (i.e. if they have different medians, they have similar shapes). If this assumption is violated, the test may not be appropriate and alternatives may be needed.
gistlibby LogSnag