
In statistics, the Mann-Whitney U test (also called the Wilcoxon rank-sum test), is a non-parametric test for assessing whether two samples of observations come from the same distribution.

|
Introduction: In statistics, the Mann-Whitney U test (also called the Wilcoxon rank-sum test), is a non-parametric test for assessing whether two samples of observations come from the same distribution. The null hypothesis is that the two samples are drawn from a single population, and therefore that their probability distributions are equal. It requires the two samples to be independent, and the observations to be ordinal (In this classification, the numbers assigned to represent the rank order (1st, 2nd, 3rd etc.) of the entities measured. The numbers are called ordinals. The variables are called ordinal variables or rank variables). |
| Formula | ![]() |
![]() |
| Line | Command or Statement | Comments |
| 1. | ClrHome | Clear Screen |
| 2. | Disp "SELECT LIST OR", | Instructions |
| "DATA TO BEGIN -", | | | |
| "USE COMMAS BTWN", | | | |
| "NUMBERS IN LIST", | | | |
| "ENTER n1, n2, R", | | | |
| "FOR DATA | End Instructions | |
| 3. | Pause | |
| 4. | ClrHome | |
| 5. | Float | |
| 6. | Menu("RANK SUM","LIST",L,"DATA",D | |
| 7. | Lbl D | Data Input |
| 8. | Input "n1=",L | L = sample size group A |
| 9. | Input "n2=",O | O = sample size group B |
| 10. | Input "R=,R | R = Rank sum |
| 11. | L+O->N | N = total sample size |
| 12. | Goto X | |
| 13. | Lbl L | |
| 14. | Input "L1=",Str1 | L1 |
| 15. | expr("{"+Str1->L1 | |
| 16. | Input "L2=",Str2 | L2 |
| 17. | expr("{"+Str2->L2 | |
| 18. | dim(L1)->L : dim(L2)->O | L = sample size L1; O = sample size L2 |
| 19. | L+O->N | N = total sample size (sample size L3) |
| 20. | L+1->A : N->B | |
| 21. | augment(L1, L2->L3 | L3 = combined data |
| 22. | If L≤O:Then | select smaller length list |
| 23. | Disp "L1 USED" | |
| 24. | 1 -> A: L -> B | |
| 25. | Else | |
| 26. | Disp "L2 USED" | |
| 27. | End | |
| 28. | N->dim( L4) | |
| 29. | Fill(0, L4 | |
| 30. | For(I,A,B) | |
| 31. | 1-L4(I) | |
| 32. | End | |
| 33. | SortA(L3, L4 | sort L3 |
| 34. | seq(X,X,1,N)->L5 | sequence 1 thru N (or total sample size) |
| 35. | Goto S | Sort Rank |
| 36. | Lbl R | |
| 37. | sum(L4L5)->R: √(LO(N+1)/12)->S | formula std dev = √(n1n2(N + 1)/12) |
| 38. | Lbl X | Display |
| 39. | min(L,O)->A | |
| 40. | Disp "SUM OF RANKS R=",R | |
| 41. | A(N+1)/2->M : Disp "MEAN R=",M | formula mean = N (N + 1)/2 |
| 42. | Disp "STD DEV R=",S | |
| 43. | Pause | |
| 44. | Disp "Z SCORE R",(R-M)/S | formula z score |
| 45. | R-A(A+1)/2->U | |
| 46. | Disp "TEST STAT "MEAN U=",M | |
| 47. | LO/2->M : Disp "MEAN U=",M | |
| 48. | Pause | |
| 49. | Disp "STD DEV U=",S | |
| 50. | Disp "Z SCORE U=",(U-M)/S | |
| 51. | Goto E | End routine |
| 52. | Lbl S | |
| 53. | 1->I | |
| 54. | While I< N | N = n1 + n2 or size L3 |
| 55. | I+1->J | increment by 1 |
| 56. | If L3 (I) = L3(I+1) | elements have equal value |
| 57. | Then | |
| 58. | I ->J | |
| 59. | Lbl A : J+1->J | |
| 60. | If J< N : Goto B | |
| 61. | If L3 (J) ≠ L3(I) | elements not equal |
| 62. | Goto B : Goto A | |
| 63. | Lbl B | |
| 64. | (L5 (I) + L5 (J-1))/2 | average value of rank |
| 65. | For (X,I,J-1) : Ans -> L5 (K) : End | |
| 66. | End | |
| 67. | J ->I | |
| 68. | End | |
| 69. | Goto R | |
| 70. | Lbl E | Clear Screen |
| 71. | DelVar L3 : DelVar L1 | Clear variables |
| 72. | DelVar L2 : DelVar L4 : DelVar L5 |