AnyLogic
Expand
Font size
All Implemented Interfaces:
Serializable

public class Histogram2DData
extends ChartItem
Data (PDF, CDF, etc.) of an array of histograms, each having a certain range of base (x) values and a range of data - y values. When an item (x,y) is added to Histogram2DData, it first finds which individual histogram this item belongs to (this depends on the x value) and then adds y value to that histigram. The PDF and CDF are calculated for each individual histogram in the array. In addition, Histogram2DData is capable of calculating envelopes - the areas containing a given percent of data in each simple histogram.
Histogram2DData is particularly useful for analyzing a number of stochastic data sets, e.g. a number of realizations of a stochastic process in time obtained in different simulation runs.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Constructor Summary

ConstructorDescription
Histogram2DData(int nXIntervals, double xmin, double xmax, int nYIntervals, double ymin, double ymax, double[] env)
Constructs a Histigram2DData with a given number of individual historgams each having a given number of intervals, and sets x and y ranges.
Histogram2DData(int nXIntervals, double xmin, double xmax, int nYIntervals, double ymin, double ymax, double[] env, DataUpdater_xjal updater)
Constructs a Histigram2DData with a given number of individual historgams each having a given number of intervals, and sets x and y ranges.

Method Summary

Modifier and TypeMethodDescription
voidadd(double xval, double yval)
Adds a sample data item to the histogram data, updates PDF, CDF and count.
voidadd(BasicDataSet dataset)
Adds the whole contents of a given dataset to the histogram data, updates PDF, CDF and count.
intcount(int xindex)
Returns the number of samples added to the histogram with xindex.
voiddestroyUpdater_xjal()
This method is used to 'disconnect' this data class from the agent/experiment this object was defined in.
It is usually called on agent destroy so that experiment could use this data object e.g.
doublegetCDF(int xindex, int yindex)
Returns the CDF (cumulative distribution function) at the END of the interval yindex of the histogram with xindex.
intgetNumberOfXIntervals()
Returns the number of base (x) intervals, i.e.
intgetNumberOfYIntervals()
Returns the number of data (y) intervals in each individual historgam.
doublegetPDF(int xindex, int yindex)
Returns the PDF (probability distribution function) of the histogram with xindex at the interval yindex.
doublegetPDFOutsideHigh(int xindex)
Returns the percent of samples (0..1) in the histogram xindex higher than the specified maximum.
doublegetPDFOutsideLow(int xindex)
Returns the percent of samples (0..1) in the histogram xindex lower than the specified data (y) minimum.
List<List<Object>>getPlainDataTable() 
doublegetXMax()
Returns the maximum x (base) value.
doublegetXMin()
Returns the minimum x (base) value.
doublegetYMax()
Returns the maximum y (data) value.
doublegetYMin()
Returns the minimum y (data) value.
voidreset()
Fully resets the histogram data: discards all PDF/CDF data and statistics.
voidsetEnvelopes(double[] env)
Sets the array of envelopes to calculate.
StringtoString()
Returns a tab-separated multi-line textual representation of the histogram data.
voidupdate()
Should be overridden and call add( xval, yval ) if the user has specified the values to add.

Methods inherited from class com.anylogic.engine.analysis.ChartItem

getVersion

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Details

Histogram2DData

public Histogram2DData(int nXIntervals,
 double xmin,
 double xmax,
 int nYIntervals,
 double ymin,
 double ymax,
 double[] env)
Constructs a Histigram2DData with a given number of individual historgams each having a given number of intervals, and sets x and y ranges.
Parameters:
nXIntervals - the number of base (x) intervals, i.e. the number of individual historgams
xmin - the minimum x value
xmax - the maximum x value
nYIntervals - the number of data intervals in each individual historgam
ymin - the lower bound of the range covered by the histogram intervals
ymax - the upper bound of the range covered by the histogram intervals
env - the array of envelopes to calculate. For example, the array { 0.4, 0.6, 0.8 } (this is the default array) means the histogram should calculate 40%, 60% and 80% envelopes for each x interval. If null, the default array is used

Histogram2DData

public Histogram2DData(int nXIntervals,
 double xmin,
 double xmax,
 int nYIntervals,
 double ymin,
 double ymax,
 double[] env,
 DataUpdater_xjal updater)
Constructs a Histigram2DData with a given number of individual historgams each having a given number of intervals, and sets x and y ranges.
Parameters:
nXIntervals - the number of base (x) intervals, i.e. the number of individual historgams
xmin - the minimum x value
xmax - the maximum x value
nYIntervals - the number of data intervals in each individual historgam
ymin - the lower bound of the range covered by the histogram intervals
ymax - the upper bound of the range covered by the histogram intervals
env - the array of envelopes to calculate. For example, the array { 0.4, 0.6, 0.8 } (this is the default array) means the histogram should calculate 40%, 60% and 80% envelopes for each x interval. If null, the default array is used
updater - updater which may be used instead of overriding update() method

Method Details

destroyUpdater_xjal

@AnyLogicInternalCodegenAPI
public void destroyUpdater_xjal()
This method is used to 'disconnect' this data class from the agent/experiment this object was defined in.
It is usually called on agent destroy so that experiment could use this data object e.g. in its charts.

reset

public void reset()
Fully resets the histogram data: discards all PDF/CDF data and statistics.

add

public void add(double xval,
 double yval)
Adds a sample data item to the histogram data, updates PDF, CDF and count.
Parameters:
xval - the base (x) value used to determine the target individual histogram
yval - the data (y) value that is added to the target individual histogram

add

public void add(BasicDataSet dataset)
Adds the whole contents of a given dataset to the histogram data, updates PDF, CDF and count.
Parameters:
dataset - the dataset to add from

update

public void update()
Should be overridden and call add( xval, yval ) if the user has specified the values to add. By default does nothing or uses updater if was created with appropriate constructor.
Overrides:
update in class ChartItem

setEnvelopes

public void setEnvelopes(double[] env)
Sets the array of envelopes to calculate. For example, the array { 0.4, 0.6, 0.8 } (this is the default array) means the histogram should calculate 40%, 60% and 80% envelopes for each x interval.
Parameters:
env - the array of envelope values in ascending order, each within [0..1]

getNumberOfXIntervals

public int getNumberOfXIntervals()
Returns the number of base (x) intervals, i.e. the number of individual historgams.
Returns:
the number of base (x) intervals, i.e. the number of individual historgams

getNumberOfYIntervals

public int getNumberOfYIntervals()
Returns the number of data (y) intervals in each individual historgam.
Returns:
the number of data (y) intervals in each individual historgam

getPDF

public double getPDF(int xindex,
 int yindex)
Returns the PDF (probability distribution function) of the histogram with xindex at the interval yindex. The PDF is calculated as (number of samples within the interval) / (total number of samples in the histigram)
Parameters:
xindex - the index of the histogram
yindex - the index of the interval in the histogram
Returns:
the PDF of the given interval

getCDF

public double getCDF(int xindex,
 int yindex)
Returns the CDF (cumulative distribution function) at the END of the interval yindex of the histogram with xindex. The CDF is calculated as (number of samples lower than the end of the interval) / (total number of samples in the histigram).
Parameters:
xindex - the index of the histogram
yindex - the index of the interval in the histogram
Returns:
the CDF at the END of the interval

getPDFOutsideLow

public double getPDFOutsideLow(int xindex)
Returns the percent of samples (0..1) in the histogram xindex lower than the specified data (y) minimum. It equals the CDF at the point of minimum.
Parameters:
xindex - the index of the histogram
Returns:
the percent of samples lower than the specified minimum

getPDFOutsideHigh

public double getPDFOutsideHigh(int xindex)
Returns the percent of samples (0..1) in the histogram xindex higher than the specified maximum.
Parameters:
xindex - the index of the histogram
Returns:
the percent of samples lower higher the specified maximum

count

public int count(int xindex)
Returns the number of samples added to the histogram with xindex.
Returns:
the number of samples added to the histogram with xindex

getXMin

public double getXMin()
Returns the minimum x (base) value.
Returns:
the minimum x (base) value

getXMax

public double getXMax()
Returns the maximum x (base) value.
Returns:
the maximum x (base) value

getYMin

public double getYMin()
Returns the minimum y (data) value.
Returns:
the minimum y (data) value

getYMax

public double getYMax()
Returns the maximum y (data) value.
Returns:
the maximum y (data) value

toString

public String toString()
Returns a tab-separated multi-line textual representation of the histogram data.
Overrides:
toString in class Object
Returns:
the textual representation of the histogram data

getPlainDataTable

@AnyLogicInternalAPI
public List<List<Object>> getPlainDataTable()