@Test(expected = IllegalArgumentException.class) public void disallowsQuantileOverOne() { snapshot.getValue( 1.5 ); }
@Override public double getValue(double quantile) { if (quantile < 0.0 || quantile > 1.0 || Double.isNaN( quantile )) { throw new IllegalArgumentException(quantile + " is not in [0..1]"); } if (values.length == 0) { return 0.0; } final double pos = quantile * (values.length + 1); final int index = (int) pos; if (index < 1) { return values[0]; } if (index >= values.length) { return values[values.length - 1]; } final double lower = values[index - 1]; final double upper = values[index]; return lower + (pos - floor(pos)) * (upper - lower); }
UniformSnapshot extends AbstractSnapshot { @Override public double getValue(double quantile) { if (quantile < 0.0 || quantile > 1.0 || Double.isNaN( quantile )) { throw new IllegalArgumentException(quantile + " is not in [0..1]"); } if (values.length == 0) { return 0.0; } final double pos = quantile * (values.length + 1); final int index = (int) pos; if (index < 1) { return values[0]; } if (index >= values.length) { return values[values.length - 1]; } final double lower = values[index - 1]; final double upper = values[index]; return lower + (pos - floor(pos)) * (upper - lower); } }
UniformSnapshot extends AbstractSnapshot { @Override public double getValue(double quantile) { if (quantile < 0.0 || quantile > 1.0 || Double.isNaN( quantile )) { throw new IllegalArgumentException(quantile + " is not in [0..1]"); } if (values.length == 0) { return 0.0; } final double pos = quantile * (values.length + 1); final int index = (int) pos; if (index < 1) { return values[0]; } if (index >= values.length) { return values[values.length - 1]; } final double lower = values[index - 1]; final double upper = values[index]; return lower + (pos - floor(pos)) * (upper - lower); } UniformSnapshot(Collection<Long> values);  UniformSnapshot(long[] values); }
UniformSnapshot extends AbstractSnapshot { @Override public double getValue(double quantile) { if (quantile < 0.0 || quantile > 1.0 || Double.isNaN( quantile )) { throw new IllegalArgumentException(quantile + " is not in [0..1]"); } if (values.length == 0) { return 0.0; } final double pos = quantile * (values.length + 1); final int index = (int) pos; if (index < 1) { return values[0]; } if (index >= values.length) { return values[values.length - 1]; } final double lower = values[index - 1]; final double upper = values[index]; return lower + (pos - floor(pos)) * (upper - lower); } UniformSnapshot(Collection<Long> values);  UniformSnapshot(long[] 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); }
UniformSnapshot extends AbstractSnapshot { @Override public double getValue(double quantile) { if (quantile < 0.0 || quantile > 1.0 || Double.isNaN( quantile )) { throw new IllegalArgumentException(quantile + " is not in [0..1]"); } if (values.length == 0) { return 0.0; } final double pos = quantile * (values.length + 1); final int index = (int) pos; if (index < 1) { return values[0]; } if (index >= values.length) { return values[values.length - 1]; } final double lower = values[index - 1]; final double upper = values[index]; return lower + (pos - floor(pos)) * (upper - lower); } UniformSnapshot(Collection<Long> values);  UniformSnapshot(long[] 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);  }