/** * 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)); }
/** * 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)); }
/** * 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)); } }
/** * 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)); } }
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(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; }
/** * 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; }
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; }
/** * performs the data extraction and quantification. * * @return a histogram dataset. */ private SimpleHistogramDataset createDataset() { Statistic statistic = new Statistic(extractor.getDataSet(), getResolution()); setAverage(statistic.getAverage()); setDeviation(statistic.getStandardDeviation()); setNumConcepts(extractor.getNumConcepts()); setNumRelations(extractor.getNumRelations()); SimpleHistogramDataset set = new SimpleHistogramDataset(extractor.getVariableName()); SimpleHistogramBin bin; double[][] his = statistic.getHistogramValues(); double x_start, x_end, y; for (int i = 0; i < his.length; i++) { x_start = his[i][0]; x_end = his[i][0] + getResolution(); y = his[i][1]; bin = new SimpleHistogramBin(x_start, x_end, true, false); bin.setItemCount((int) y); set.addBin(bin); } return set; }