@Test public void testGetStdDev() { try { Statistics.getStdDev(null); fail("IllegalArgumentException should have been thrown on null key"); } catch (IllegalArgumentException e) { assertEquals("Null 'data' array.", e.getMessage()); } try { Statistics.getStdDev(new Double[0]); fail("IllegalArgumentException should have been thrown on empty key"); } catch (IllegalArgumentException e) { assertEquals("Zero length 'data' array.", e.getMessage()); } assertTrue(Double.isNaN(Statistics.getStdDev(new Double[] {1.0}))); }
public static double getStdDev(Number[] data) { if (data == null) { throw new IllegalArgumentException("Null 'data' array."); } if (data.length == 0) { throw new IllegalArgumentException("Zero length 'data' array."); } double avg = calculateMean(data); double sum = 0.0; for (Number aData : data) { double diff = aData.doubleValue() - avg; sum = sum + diff * diff; } return Math.sqrt(sum / (data.length - 1)); }
Statistics { public static double getStdDev(Number[] data) { if (data == null) { throw new IllegalArgumentException("Null 'data' array."); } if (data.length == 0) { throw new IllegalArgumentException("Zero length 'data' array."); } double avg = calculateMean(data); double sum = 0.0; for (Number aData : data) { double diff = aData.doubleValue() - avg; sum = sum + diff * diff; } return Math.sqrt(sum / (data.length - 1)); } }
Statistics { public static double getStdDev(Number[] data) { if (data == null) { throw new IllegalArgumentException("Null 'data' array."); } if (data.length == 0) { throw new IllegalArgumentException("Zero length 'data' array."); } double avg = calculateMean(data); double sum = 0.0; for (Number aData : data) { double diff = aData.doubleValue() - avg; sum = sum + diff * diff; } return Math.sqrt(sum / (data.length - 1)); }  }
Statistics { public static double getStdDev(Number[] data) { if (data == null) { throw new IllegalArgumentException("Null 'data' array."); } if (data.length == 0) { throw new IllegalArgumentException("Zero length 'data' array."); } double avg = calculateMean(data); double sum = 0.0; for (Number aData : data) { double diff = aData.doubleValue() - avg; sum = sum + diff * diff; } return Math.sqrt(sum / (data.length - 1)); }  static double calculateMean(Number[] values); static double calculateMean(Number[] values,
            boolean includeNullAndNaN); static double calculateMean(Collection<Number> values); static double calculateMean(Collection<Number> values,
            boolean includeNullAndNaN); static double calculateMedian(List<Number> values); static double calculateMedian(List<Number> values,
            boolean copyAndSort); static double calculateMedian(List<Number> values, int start, int end); static double calculateMedian(List<Number> values,
            int start, int end, boolean copyAndSort); static double getStdDev(Number[] data); static double[] getLinearFit(Number[] xData, Number[] yData); static double getSlope(Number[] xData, Number[] yData); static double getCorrelation(Number[] data1, Number[] data2); static double[][] getMovingAverage(Number[] xData,
                                              Number[] yData,
                                              int period); }
Statistics { public static double getStdDev(Number[] data) { if (data == null) { throw new IllegalArgumentException("Null 'data' array."); } if (data.length == 0) { throw new IllegalArgumentException("Zero length 'data' array."); } double avg = calculateMean(data); double sum = 0.0; for (Number aData : data) { double diff = aData.doubleValue() - avg; sum = sum + diff * diff; } return Math.sqrt(sum / (data.length - 1)); }  static double calculateMean(Number[] values); static double calculateMean(Number[] values,
            boolean includeNullAndNaN); static double calculateMean(Collection<Number> values); static double calculateMean(Collection<Number> values,
            boolean includeNullAndNaN); static double calculateMedian(List<Number> values); static double calculateMedian(List<Number> values,
            boolean copyAndSort); static double calculateMedian(List<Number> values, int start, int end); static double calculateMedian(List<Number> values,
            int start, int end, boolean copyAndSort); static double getStdDev(Number[] data); static double[] getLinearFit(Number[] xData, Number[] yData); static double getSlope(Number[] xData, Number[] yData); static double getCorrelation(Number[] data1, Number[] data2); static double[][] getMovingAverage(Number[] xData,
                                              Number[] yData,
                                              int period);  }