how to perform a mann-whitney test in matlab

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.m
[p,h,stats] = ranksum(x,y)
27 chars
2 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.m
x = [2, 7, 6, 4, 5];
y = [10, 8, 12, 11, 9];
[p,h,stats] = ranksum(x,y)
72 chars
4 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