@Test public void testCalculateQ3() { try { BoxAndWhiskerCalculator.calculateQ3(null); fail("IllegalArgumentException should have been thrown on a null key"); } catch (IllegalArgumentException e) { assertEquals("Null 'values' argument.", e.getMessage()); } List<Number> values = new ArrayList<Number>(); double q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertTrue(Double.isNaN(q3)); values.add(1.0); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 1.0, EPSILON); values.add(2.0); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 2.0, EPSILON); values.add(3.0); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 2.5, EPSILON); values.add(4.0); q3 = BoxAndWhiskerCalculator.calculateQ3(values); assertEquals(q3, 3.5, EPSILON); }
public static double calculateQ3(List<Number> values) { if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } double result = Double.NaN; int count = values.size(); if (count > 0) { if (count % 2 == 1) { if (count > 1) { result = Statistics.calculateMedian(values, count / 2, count - 1); } else { result = Statistics.calculateMedian(values, 0, 0); } } else { result = Statistics.calculateMedian(values, count / 2, count - 1); } } return result; }
BoxAndWhiskerCalculator { public static double calculateQ3(List<Number> values) { if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } double result = Double.NaN; int count = values.size(); if (count > 0) { if (count % 2 == 1) { if (count > 1) { result = Statistics.calculateMedian(values, count / 2, count - 1); } else { result = Statistics.calculateMedian(values, 0, 0); } } else { result = Statistics.calculateMedian(values, count / 2, count - 1); } } return result; } }
BoxAndWhiskerCalculator { public static double calculateQ3(List<Number> values) { if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } double result = Double.NaN; int count = values.size(); if (count > 0) { if (count % 2 == 1) { if (count > 1) { result = Statistics.calculateMedian(values, count / 2, count - 1); } else { result = Statistics.calculateMedian(values, 0, 0); } } else { result = Statistics.calculateMedian(values, count / 2, count - 1); } } return result; }  }
BoxAndWhiskerCalculator { public static double calculateQ3(List<Number> values) { if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } double result = Double.NaN; int count = values.size(); if (count > 0) { if (count % 2 == 1) { if (count > 1) { result = Statistics.calculateMedian(values, count / 2, count - 1); } else { result = Statistics.calculateMedian(values, 0, 0); } } else { result = Statistics.calculateMedian(values, count / 2, count - 1); } } return result; }  static BoxAndWhiskerItem calculateBoxAndWhiskerStatistics(
                                        List<Number> values); static BoxAndWhiskerItem calculateBoxAndWhiskerStatistics(
            List<Number> values, boolean stripNullAndNaNItems); static double calculateQ1(List<Number> values); static double calculateQ3(List<Number> values); }
BoxAndWhiskerCalculator { public static double calculateQ3(List<Number> values) { if (values == null) { throw new IllegalArgumentException("Null 'values' argument."); } double result = Double.NaN; int count = values.size(); if (count > 0) { if (count % 2 == 1) { if (count > 1) { result = Statistics.calculateMedian(values, count / 2, count - 1); } else { result = Statistics.calculateMedian(values, 0, 0); } } else { result = Statistics.calculateMedian(values, count / 2, count - 1); } } return result; }  static BoxAndWhiskerItem calculateBoxAndWhiskerStatistics(
                                        List<Number> values); static BoxAndWhiskerItem calculateBoxAndWhiskerStatistics(
            List<Number> values, boolean stripNullAndNaNItems); static double calculateQ1(List<Number> values); static double calculateQ3(List<Number> values);  }