OneWayAnova { public double anovaFValue(final Collection<double[]> categoryData) throws NullArgumentException, DimensionMismatchException { AnovaStats a = anovaStats(categoryData); return a.F; } OneWayAnova(); double anovaFValue(final Collection<double[]> categoryData); double anovaPValue(final Collection<double[]> categoryData); double anovaPValue(final Collection<SummaryStatistics> categoryData,
                              final boolean allowOneElementData); boolean anovaTest(final Collection<double[]> categoryData,
                             final double alpha);  }
@Test public void testAnovaFValue() { List<double[]> threeClasses = new ArrayList<double[]>(); threeClasses.add(classA); threeClasses.add(classB); threeClasses.add(classC); Assert.assertEquals("ANOVA F-value", 24.67361709460624, testStatistic.anovaFValue(threeClasses), 1E-12); List<double[]> twoClasses = new ArrayList<double[]>(); twoClasses.add(classA); twoClasses.add(classB); Assert.assertEquals("ANOVA F-value", 0.0150579150579, testStatistic.anovaFValue(twoClasses), 1E-12); List<double[]> emptyContents = new ArrayList<double[]>(); emptyContents.add(emptyArray); emptyContents.add(classC); try { testStatistic.anovaFValue(emptyContents); Assert.fail("empty array for key classX, MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { } List<double[]> tooFew = new ArrayList<double[]>(); tooFew.add(classA); try { testStatistic.anovaFValue(tooFew); Assert.fail("less than two classes, MathIllegalArgumentException expected"); } catch (MathIllegalArgumentException ex) { } }