AnyLogic
Expand
Font size
All Implemented Interfaces:
java.io.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

Constructors 
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.
Constructor Description

Method Summary

All Methods Instance Methods Concrete Methods 
void add​(double xval, double yval)
Adds a sample data item to the histogram data, updates PDF, CDF and count.
void add​(DataSet dataset)
Adds the whole contents of a given dataset to the histogram data, updates PDF, CDF and count.
int count​(int xindex)
Returns the number of samples added to the histogram with xindex.
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.
double getCDF​(int xindex, int yindex)
Returns the CDF (cumulative distribution function) at the END of the interval yindex of the histogram with xindex.
int getNumberOfXIntervals()
Returns the number of base (x) intervals, i.e.
int getNumberOfYIntervals()
Returns the number of data (y) intervals in each individual historgam.
double getPDF​(int xindex, int yindex)
Returns the PDF (probability distribution function) of the histogram with xindex at the interval yindex.
double getPDFOutsideHigh​(int xindex)
Returns the percent of samples (0..1) in the histogram xindex higher than the specified maximum.
double getPDFOutsideLow​(int xindex)
Returns the percent of samples (0..1) in the histogram xindex lower than the specified data (y) minimum.
java.util.List<java.util.List<java.lang.Object>> getPlainDataTable()  
double getXMax()
Returns the maximum x (base) value.
double getXMin()
Returns the minimum x (base) value.
double getYMax()
Returns the maximum y (data) value.
double getYMin()
Returns the minimum y (data) value.
void reset()
Fully resets the histogram data: discards all PDF/CDF data and statistics.
void setEnvelopes​(double[] env)
Sets the array of envelopes to calculate.
java.lang.String toString()
Returns a tab-separated multi-line textual representation of the histogram data.
void update()
Should be overridden and call add( xval, yval ) if the user has specified the values to add.
Modifier and Type Method Description

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 Detail

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 Detail

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​(DataSet 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 java.lang.String toString()
Returns a tab-separated multi-line textual representation of the histogram data.
Overrides:
toString in class java.lang.Object
Returns:
the textual representation of the histogram data

getPlainDataTable

@AnyLogicInternalAPI
public java.util.List<java.util.List<java.lang.Object>> getPlainDataTable()
How can we improve this article?