package com.imsl.test.example.stat; import java.text.*; import com.imsl.stat.*; /** *
Performs the sign test on a small data set.
* *This example tests the null hypothesis that at least \(75\) percent of a population is negative. Because \(0.923 \lt 0.95\), the null hypothesis at the \(5\)-percent level of significance is rejected.
* * @see Code * @see Output */ public class SignTestEx2 { public static void main(String args[]) { double[] x = { 92.0, 139.0, -6.0, 10.0, 81.0, -11.0, 45.0, -25.0, -4.0, 22.0, 2.0, 41.0, 13.0, 8.0, 33.0, 45.0, -33.0, -45.0, -12.0 }; SignTest st = new SignTest(x); NumberFormat nf = NumberFormat.getInstance(); nf.setMaximumFractionDigits(6); st.setPercentage(0.75); st.setPercentile(0.0); System.out.println("Probability = " + nf.format(st.compute())); System.out.println("Number of positive deviations = " + st.getNumPositiveDev()); System.out.println("Number of ties = " + st.getNumZeroDev()); } }