package com.imsl.test.example.stat; import com.imsl.stat.*; /** *
* Performs a chi-squared test for independence.
** The data in this example is taken from Kendall and Stuart (1979) and involves * a 2-way contingency table of distance vision graded from best to worst, between * the right and left eyes. A test of independence is performed and a resulting * \(p\)-value is displayed. The small \(p\)-value is strong evidence that distance * vision between the left and right eye is not independent. *
* * @see Code * @see Output */ public class ContingencyTableEx1 { public static void main(String args[]) { double[][] table = { {821, 112, 85, 35}, {116, 494, 145, 27}, {72, 151, 583, 87}, {43, 34, 106, 331} }; ContingencyTable ct = new ContingencyTable(table); System.out.println("P-value = " + ct.getP()); } }