@Test public void calculatesTheStdDev() throws Exception { assertThat(snapshot.getStdDev()) .isEqualTo(1.2688, offset(0.0001)); }
@Override public double getStdDev() { if (values.length <= 1) { return 0; } final double mean = getMean(); double variance = 0; for (int i = 0; i < values.length; i++) { final double diff = values[i] - mean; variance += normWeights[i] * diff*diff; } return Math.sqrt(variance); }
WeightedSnapshot extends AbstractSnapshot { @Override public double getStdDev() { if (values.length <= 1) { return 0; } final double mean = getMean(); double variance = 0; for (int i = 0; i < values.length; i++) { final double diff = values[i] - mean; variance += normWeights[i] * diff*diff; } return Math.sqrt(variance); } }
WeightedSnapshot extends AbstractSnapshot { @Override public double getStdDev() { if (values.length <= 1) { return 0; } final double mean = getMean(); double variance = 0; for (int i = 0; i < values.length; i++) { final double diff = values[i] - mean; variance += normWeights[i] * diff*diff; } return Math.sqrt(variance); } WeightedSnapshot(Collection<WeightedSample> values); }
WeightedSnapshot extends AbstractSnapshot { @Override public double getStdDev() { if (values.length <= 1) { return 0; } final double mean = getMean(); double variance = 0; for (int i = 0; i < values.length; i++) { final double diff = values[i] - mean; variance += normWeights[i] * diff*diff; } return Math.sqrt(variance); } WeightedSnapshot(Collection<WeightedSample> values); @Override double getValue(double quantile); @Override int size(); @Override long[] getValues(); @Override long getMax(); @Override long getMin(); @Override double getMean(); @Override double getStdDev(); @Override void dump(OutputStream output); }
WeightedSnapshot extends AbstractSnapshot { @Override public double getStdDev() { if (values.length <= 1) { return 0; } final double mean = getMean(); double variance = 0; for (int i = 0; i < values.length; i++) { final double diff = values[i] - mean; variance += normWeights[i] * diff*diff; } return Math.sqrt(variance); } WeightedSnapshot(Collection<WeightedSample> values); @Override double getValue(double quantile); @Override int size(); @Override long[] getValues(); @Override long getMax(); @Override long getMin(); @Override double getMean(); @Override double getStdDev(); @Override void dump(OutputStream output);  }