RePast
v. 2.0

uchicago.src.sim.analysis
Class HistogramStatistic

java.lang.Object
  |
  +--jclass.chart.ChartDataSupport
        |
        +--uchicago.src.sim.analysis.Statistics
              |
              +--uchicago.src.sim.analysis.HistogramStatistic
All Implemented Interfaces:
jclass.chart.Chartable, jclass.chart.ChartData, Graphable, Serializable

public class HistogramStatistic
extends Statistics

The Statistics class for histogram data. Operates as the backend for a Histogram, manipulating the HistogramItems. Can be created without a Histogram class to generate histogram data without displaying such.

See Also:
Histogram, HistogramItem, Serialized Form

Field Summary
 
Fields inherited from class uchicago.src.sim.analysis.Statistics
CSV, data, fileFormat, fileName, lastColUpdate, lastPrinted, model, title
 
Fields inherited from interface jclass.chart.Chartable
ARRAY, GENERAL
 
Constructor Summary
HistogramStatistic(int numBins, long lowerBound)
          Constructs a HistogramStatistic with the specified number of bins and the specified lower bound.
 
Method Summary
 void createHistogramItem(String name, List list, BinDataSource source)
          Creates a HistogramItem with specified name, list and BinDataSource.
 void record()
          Calculates a new histogram over the data supplied by a HistogramItem
 void setPointLabels(String[] labels)
          Sets the histogram labels (the x - axis legend).
 void step()
          Collects new statistics and updates the graph.
protected  void updateGraph()
          Updates the graph
 void writeToFile()
          Write the histogram data to a file.
 
Methods inherited from class uchicago.src.sim.analysis.Statistics
addChartAsListener, getDataInterpretation, getDataItem, getDataTable, getName, getNumRows, getPointLabels, getRow, getSeriesLabel, getSeriesName, renameFile, setSimModel
 
Methods inherited from class jclass.chart.ChartDataSupport
addChartDataListener, fireChartDataEvent, fireChartDataEvent, removeChartDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistogramStatistic

public HistogramStatistic(int numBins,
                          long lowerBound)
Constructs a HistogramStatistic with the specified number of bins and the specified lower bound.

Parameters:
numBins - the number of bins
lowerBound - the lower bound
Method Detail

createHistogramItem

public void createHistogramItem(String name,
                                List list,
                                BinDataSource source)
Creates a HistogramItem with specified name, list and BinDataSource. The HistogramItem iterates over the specified list passing each Object in the list as argument to the getBinValue method of the BinDataSource. This getBinValue method returns a double. All these doubles are then distributed across the bins according to the number of bins, the lower bound, and the maximum value. For example, given 2 bins, a lower bound of 0 and a maximum value of 4. The first bin will contain all the values from 0 up to but not including 2, and the final bin will contain all the values from 2 up to and including 4. The displayed bin value (i.e. the height of the bar in the chart) is the number of values that fall within this bin.

Note: This creates a Histogram that updates faster than those created with createHistogramItem(String name, List list, String methodName). Consequently, it should be preferred over the other method.

Parameters:
name - the name of the item
list - the list of objects that provided the data for the item
source - the BinDataSource used to get the data from the objects in the list.

step

public void step()
Collects new statistics and updates the graph.

Specified by:
step in class Statistics

record

public void record()
Calculates a new histogram over the data supplied by a HistogramItem

Specified by:
record in class Statistics

updateGraph

protected void updateGraph()
Description copied from class: Statistics
Updates the graph

Overrides:
updateGraph in class Statistics

setPointLabels

public void setPointLabels(String[] labels)
Sets the histogram labels (the x - axis legend).


writeToFile

public void writeToFile()
Write the histogram data to a file. This method is not yet implemented.

Specified by:
writeToFile in class Statistics

RePast
v. 2.0

Bug reports and feature requests to RePast