/** * Returns the y-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The y-value. * * @see #getAdjustForBinSize() */ @Override public double getYValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); if (this.adjustForBinSize) { return bin.getItemCount() / (bin.getUpperBound() - bin.getLowerBound()); } else { return bin.getItemCount(); } }
/** * Returns the x-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The x-value. */ @Override public double getXValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); return (bin.getLowerBound() + bin.getUpperBound()) / 2.0; }
public static SimulatorHistogramDataSet getHistogramDataSet(Histogram histogram, int accuracy, double scalingPercentile) { if (histogram == null) { return null; } SimulatorHistogramDataSet histogramDataSet = new SimulatorHistogramDataSet("key"); histogramDataSet.setAdjustForBinSize(false); for (HistogramIterationValue value : histogram.linearBucketValues(accuracy)) { int values = (int) value.getCountAddedInThisIterationStep(); if (values > 0) { long lowerBound = value.getValueIteratedFrom(); long upperBound = value.getValueIteratedTo(); SimpleHistogramBin bin = new SimpleHistogramBin(lowerBound, upperBound, true, false); bin.setItemCount(values); histogramDataSet.addBin(bin); } } histogramDataSet.setAutoScaleValue(histogram.getValueAtPercentile(scalingPercentile * PERCENTILE_FACTOR)); return histogramDataSet; } }
private static SimpleHistogramDataSetContainer calcSingleProbeDataSet(LatencyDistributionResult probeData, long accuracy, double scalingPercentile) { SimpleHistogramDataSetContainer histogramDataSet = new SimpleHistogramDataSetContainer("key"); histogramDataSet.setAdjustForBinSize(false); LinearHistogram histogram = probeData.getHistogram(); int histogramStep = histogram.getStep(); int lowerBound = 0; SimpleHistogramBin bin = new SimpleHistogramBin(0, accuracy, true, false); for (int values : histogram.getBuckets()) { if (lowerBound % accuracy == 0 && lowerBound > 0) { addBinIfNotEmpty(histogramDataSet, bin); bin = new SimpleHistogramBin(lowerBound, lowerBound + accuracy, true, false); } if (values > 0) { bin.setItemCount(bin.getItemCount() + values); } lowerBound += histogramStep; } addBinIfNotEmpty(histogramDataSet, bin); histogramDataSet.setAutoScaleValue(histogram.getPercentile(scalingPercentile).getBucket()); return histogramDataSet; }
/** * Adds an observation to the dataset (by incrementing the item count for * the appropriate bin). A runtime exception is thrown if the value does * not fit into any bin. * * @param value the value. * @param notify send {@link DatasetChangeEvent} to listeners? */ public void addObservation(double value, boolean notify) { boolean placed = false; Iterator iterator = this.bins.iterator(); while (iterator.hasNext() && !placed) { SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next(); if (bin.accepts(value)) { bin.setItemCount(bin.getItemCount() + 1); placed = true; } } if (!placed) { throw new RuntimeException("No bin."); } if (notify) { notifyListeners(new DatasetChangeEvent(this, this)); } }
/** * Removes all current observation data and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @since 1.0.6 * * @see #addObservations(double[]) * @see #removeAllBins() */ public void clearObservations() { Iterator iterator = this.bins.iterator(); while (iterator.hasNext()) { SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next(); bin.setItemCount(0); } notifyListeners(new DatasetChangeEvent(this, this)); }
dataset.addBin(new SimpleHistogramBin(lv+(i*bsize), lv+((i+1)*bsize), true, false)); dataset.addBin(new SimpleHistogramBin(lb.doubleValue(), hb.doubleValue(), true, false));
private static void addBinIfNotEmpty(SimpleHistogramDataSetContainer histogramDataSet, SimpleHistogramBin bin) { if (bin != null && bin.getItemCount() > 0) { histogramDataSet.addBin(bin); } } }
/** * Returns the end x-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The end x-value. */ public double getEndXValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); return bin.getUpperBound(); }
/** * Returns the start x-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The start x-value. */ @Override public double getStartXValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); return bin.getLowerBound(); }
/** * Adds a bin to the dataset. An exception is thrown if the bin overlaps * with any existing bin in the dataset. * * @param bin the bin (<code>null</code> not permitted). * * @see #removeAllBins() */ public void addBin(SimpleHistogramBin bin) { // check that the new bin doesn't overlap with any existing bin Iterator iterator = this.bins.iterator(); while (iterator.hasNext()) { SimpleHistogramBin existingBin = (SimpleHistogramBin) iterator.next(); if (bin.overlapsWith(existingBin)) { throw new RuntimeException("Overlapping bin"); } } this.bins.add(bin); Collections.sort(this.bins); }
private static SimpleHistogramDataSetContainer calcSingleProbeDataSet(HdrLatencyDistributionResult probeData, long accuracy, double scalingPercentile) { SimpleHistogramDataSetContainer histogramDataSet = new SimpleHistogramDataSetContainer("key"); histogramDataSet.setAdjustForBinSize(false); Histogram histogram = probeData.getHistogram(); for (HistogramIterationValue value : histogram.linearBucketValues(accuracy)) { int values = (int) value.getCountAddedInThisIterationStep(); if (values > 0) { long lowerBound = value.getValueIteratedFrom(); long upperBound = value.getValueIteratedTo(); SimpleHistogramBin bin = new SimpleHistogramBin(lowerBound, upperBound, true, false); bin.setItemCount(values); histogramDataSet.addBin(bin); } } histogramDataSet.setAutoScaleValue(histogram.getValueAtPercentile(scalingPercentile * 100)); return histogramDataSet; }
/** * Adds an observation to the dataset (by incrementing the item count for * the appropriate bin). A runtime exception is thrown if the value does * not fit into any bin. * * @param value the value. * @param notify send {@link DatasetChangeEvent} to listeners? */ public void addObservation(double value, boolean notify) { boolean placed = false; Iterator iterator = this.bins.iterator(); while (iterator.hasNext() && !placed) { SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next(); if (bin.accepts(value)) { bin.setItemCount(bin.getItemCount() + 1); placed = true; } } if (!placed) { throw new RuntimeException("No bin."); } if (notify) { notifyListeners(new DatasetChangeEvent(this, this)); } }
/** * Removes all current observation data and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @since 1.0.6 * * @see #addObservations(double[]) * @see #removeAllBins() */ public void clearObservations() { Iterator iterator = this.bins.iterator(); while (iterator.hasNext()) { SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next(); bin.setItemCount(0); } notifyListeners(new DatasetChangeEvent(this, this)); }
/** * Returns the x-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The x-value. */ public double getXValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); return (bin.getLowerBound() + bin.getUpperBound()) / 2.0; }
/** * Returns the end x-value (as a double primitive) for an item within a * series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The end x-value. */ @Override public double getEndXValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); return bin.getUpperBound(); }
/** * Returns the start x-value (as a double primitive) for an item within a * series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The start x-value. */ public double getStartXValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); return bin.getLowerBound(); }
/** * Adds a bin to the dataset. An exception is thrown if the bin overlaps * with any existing bin in the dataset. * * @param bin the bin ({@code null} not permitted). * * @see #removeAllBins() */ public void addBin(SimpleHistogramBin bin) { // check that the new bin doesn't overlap with any existing bin Iterator iterator = this.bins.iterator(); while (iterator.hasNext()) { SimpleHistogramBin existingBin = (SimpleHistogramBin) iterator.next(); if (bin.overlapsWith(existingBin)) { throw new RuntimeException("Overlapping bin"); } } this.bins.add(bin); Collections.sort(this.bins); }
/** * performs the data extraction and quantification. * * @return a histogram dataset. */ private SimpleHistogramDataset createDataset() { SimpleHistogramDataset set = new SimpleHistogramDataset("empty"); if (targetAttributeName != null) { Extractor extractor = new Extractor(targetAttributeName); double resolution = getResolution(extractor); Statistic statistic = new Statistic(extractor.getDataSet(), resolution); set = new SimpleHistogramDataset(targetAttributeName.getId()); set.setAdjustForBinSize(false); SimpleHistogramBin bin; double[][] his = statistic.getHistogramValues(); double x_start, x_end; int count = 0; for (int i = 0; i < his.length; i++) { x_start = his[i][0]; x_end = his[i][0] + resolution; count = (int) his[i][1]; bin = new SimpleHistogramBin(x_start, x_end, true, false); bin.setItemCount(count); set.addBin(bin); } } return set; }
/** * Returns the y-value (as a double primitive) for an item within a series. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The y-value. * * @see #getAdjustForBinSize() */ public double getYValue(int series, int item) { SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); if (this.adjustForBinSize) { return bin.getItemCount() / (bin.getUpperBound() - bin.getLowerBound()); } else { return bin.getItemCount(); } }