/** * 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. */ public void addObservation(double value) { addObservation(value, true); }
/** * Returns the ending X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ @Override public Number getEndX(int series, int item) { return new Double(getEndXValue(series, item)); }
/** * Returns the starting X value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ @Override public Number getStartX(int series, int item) { return new Double(getStartXValue(series, item)); }
/** * 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; }
SimpleHistogramDataset dataset = new SimpleHistogramDataset(seriesname); dataset.addBin(new SimpleHistogramBin(lv+(i*bsize), lv+((i+1)*bsize), true, false)); dataset.addBin(new SimpleHistogramBin(lb.doubleValue(), hb.doubleValue(), true, false)); if(dataset.getItemCount(0)==0) throw new RuntimeException("No bins defined.");
/** * Adds a set of values to the dataset and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param values the values ({@code null} not permitted). * * @see #clearObservations() */ public void addObservations(double[] values) { for (int i = 0; i < values.length; i++) { addObservation(values[i], false); } notifyListeners(new DatasetChangeEvent(this, this)); }
/** * 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; }
/** * Removes all bins and sends a {@link DatasetChangeEvent} to all * registered listeners. * * @since 1.0.6 * * @see #addBin(SimpleHistogramBin) */ public void removeAllBins() { this.bins = new ArrayList(); notifyListeners(new DatasetChangeEvent(this, this)); }
/** * Returns the start 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 start y-value. */ @Override public double getStartYValue(int series, int item) { return getYValue(series, item); }
/** * Returns the starting Y value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ @Override public Number getStartY(int series, int item) { return getY(series, item); }
/** * Returns the x-value for an item within a series. The x-values may or * may not be returned in ascending order, that is up to the class * implementing the interface. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The x-value (never <code>null</code>). */ public Number getX(int series, int item) { return new Double(getXValue(series, item)); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } SimulatorHistogramDataSet that = (SimulatorHistogramDataSet) o; if (autoScaleValue != that.autoScaleValue) { return false; } return !(bins != null ? !bins.equals(that.bins) : that.bins != null); }
/** * Adds a set of values to the dataset and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param values the values (<code>null</code> not permitted). * * @see #clearObservations() */ public void addObservations(double[] values) { for (int i = 0; i < values.length; i++) { addObservation(values[i], false); } notifyListeners(new DatasetChangeEvent(this, this)); }
/** * Removes all bins and sends a {@link DatasetChangeEvent} to all * registered listeners. * * @since 1.0.6 * * @see #addBin(SimpleHistogramBin) */ public void removeAllBins() { this.bins = new ArrayList(); notifyListeners(new DatasetChangeEvent(this, this)); }
/** * Returns the start 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 start y-value. */ public double getStartYValue(int series, int item) { return getYValue(series, item); }
/** * Returns the ending Y value for the specified series and item. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The value. */ @Override public Number getEndY(int series, int item) { return getY(series, item); }
/** * Returns the x-value for an item within a series. The x-values may or * may not be returned in ascending order, that is up to the class * implementing the interface. * * @param series the series index (zero-based). * @param item the item index (zero-based). * * @return The x-value (never {@code null}). */ @Override public Number getX(int series, int item) { return new Double(getXValue(series, item)); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } SimpleHistogramDataSetContainer that = (SimpleHistogramDataSetContainer) o; if (autoScaleValue != that.autoScaleValue) { return false; } if (bins != null ? !bins.equals(that.bins) : that.bins != null) { return false; } return true; }
/** * Sets the flag that controls whether or not the bin count is divided by * the bin size in the {@link #getYValue(int, int)} method, and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param adjust the flag. * * @see #getAdjustForBinSize() */ public void setAdjustForBinSize(boolean adjust) { this.adjustForBinSize = adjust; 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. */ public void addObservation(double value) { addObservation(value, true); }