Example 1: Wilcoxon Rank Sum Test

The following example is taken from Conover (1980, p. 224). It involves the mixing time of two mixing machines using a total of 10 batches of a certain kind of batter, five batches for each machine. The null hypothesis is not rejected at the 5-percent level of significance.

import java.text.*;
import com.imsl.*;
import com.imsl.stat.*;

public class WilcoxonRankSumEx1 {
    public static void main(String args[]) {
        double[] x = {7.3, 6.9, 7.2, 7.8, 7.2};
        double[] y = {7.4, 6.8, 6.9, 6.7, 7.1};
        
        WilcoxonRankSum wilcoxon = new WilcoxonRankSum(x, y);
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(4);
        
        // Trun off printing of warning messages.
        Warning.setOut(null);
        
        System.out.println("p-value = " + nf.format(wilcoxon.compute()));
    }
}

Output

p-value = 0.1412
Link to Java source.