### Question:
Statistics { public static double anova(double sumOfSquaresModelA, double sumOfSquaresModelB, int degreesOfFreedomA, int degreesOfFreedomB, Boolean no_intercept) { if (no_intercept) { ++degreesOfFreedomA; ++degreesOfFreedomB; } double meanSquareError = sumOfSquaresModelA / degreesOfFreedomA; int degreesOfFreedomDifference = Math.abs(degreesOfFreedomB - degreesOfFreedomA); double meanSquareErrorDiff = Math.abs((sumOfSquaresModelA - sumOfSquaresModelB) / (degreesOfFreedomDifference)); if(meanSquareError == 0){ throw new RuntimeException("meanSquareError should not be 0, no variance in the data?"); } double Fval = meanSquareErrorDiff / meanSquareError; FDistribution Fdist = new FDistribution(degreesOfFreedomDifference, degreesOfFreedomB); double pval = 1 - Fdist.cumulative(Fval); return pval; }  static double calculateSpearmanTwoTailedPvalue(double spearmanCorrelation, int sampleSize); static double anova(double sumOfSquaresModelA, double sumOfSquaresModelB, int degreesOfFreedomA,
			int degreesOfFreedomB, Boolean no_intercept);  }### Answer:
@Test public void anovaTest() throws Exception { double expectedPval = 4.09E-7; double observedPval = Statistics.anova(31, 22, 100, 101, true); assertEquals(expectedPval, observedPval, 0.000000001); expectedPval = 4.67E-7; observedPval = Statistics.anova(31, 22, 100, 101, false); assertEquals(expectedPval, observedPval, 0.000000001); }
@Test public void anovaErrorTest() throws Exception { try { Statistics.anova(0, 10, 100, 100, true); fail( "My method didn't throw when I expected it to" ); } catch (RuntimeException expectedException) { assertEquals(expectedException.getMessage(), "meanSquareError should not be 0, no variance in the data?"); } }