Example 2: Wilcoxon Rank Sum Test

The following example uses the same data as in example 1. Now, all the statistics are displayed.

using System;
using Imsl.Stat;
using PrintMatrix = Imsl.Math.PrintMatrix;

public class WilcoxonRankSumEx2
{
	public static void  Main(String[] args)
	{
		double[] x = new double[]{7.3, 6.9, 7.2, 7.8, 7.2};
		double[] y = new double[]{7.4, 6.8, 6.9, 6.7, 7.1};
		String[] labels =new String[]{
                 "Wilcoxon W statistic ......................", 
                 "2*E(W) - W ................................", 
                 "p-value ................................... ",
				 "Adjusted Wilcoxon statistic ...............", 
                 "Adjusted 2*E(W) - W .......................",
				 "Adjusted p-value .......................... ",
				 "W statistics for averaged ranks............", 
                 "Standard error of W (averaged ranks) ...... ", 
                 "Standard normal score of W (averaged ranks) ", 
                 "Two-sided p-value of W (averaged ranks) ... "};
		
		WilcoxonRankSum wilcoxon = new WilcoxonRankSum(x, y);
		wilcoxon.Compute();
		double[] stat = wilcoxon.GetStatistics();
		
		for (int i = 0; i < 10; i++)
		{
			Console.Out.WriteLine
				(labels[i] + " " + stat[i].ToString("0.000"));
		}
	}
}

Output

Wilcoxon W statistic ...................... 34.000
2*E(W) - W ................................ 21.000
p-value ...................................  0.110
Adjusted Wilcoxon statistic ............... 35.000
Adjusted 2*E(W) - W ....................... 20.000
Adjusted p-value ..........................  0.075
W statistics for averaged ranks............ 34.500
Standard error of W (averaged ranks) ......  4.758
Standard normal score of W (averaged ranks)  1.471
Two-sided p-value of W (averaged ranks) ...  0.141
Imsl.Stat.WilcoxonRankSum: "x.length" = 5 and "y.length" = 5.  
Both sample sizes, "x.length" and "y.length", are less than 25.  
Significance levels should be obtained from tabled values. 
Imsl.Stat.WilcoxonRankSum: At least one tie is detected between the samples.

Link to C# source.