AnyLogic 9
Expand
Font size

Histogram2D data

Histogram2D data elements collect statistical data (PDF, CDF, etc.) from an array of histograms, where each histogram corresponds to a specific range of X-axis (base) values and contains Y-axis (data) values. When an (x, y) data point is added to Histogram2D Data, AnyLogic first determines which histogram bin the point belongs to based on its x value, then adds the y value to that histogram. The PDF and CDF are calculated independently for each histogram in the array. Additionally, Histogram2D Data elements can calculate envelopes — regions that contain a specified percentage of the data within each histogram.

Histogram2D Data is especially useful for analyzing multiple stochastic datasets, such as multiple realizations of a stochastic process over time obtained from different simulation runs.

The collected statistics can be visualized using the Histogram2D chart.

To add a Histogram2D Data element

  1. Drag the  Histogram2D Data element from the  Analysis palette into the graphical editor.
  2. Go to the Properties view.
  3. Select Use time as X value to store time samples as base values or specify the expression that will be dynamically evaluated to obtain the current X-value for the histograms in the X value box.
  4. In the Y value box, specify the expression that will be dynamically evaluated to obtain the current Y-value for the histograms.
  5. If you want to calculate and display confidence envelopes, specify a comma-separated list of lower bounds for them (the regions containing a given percentage of data) in the Envelopes box.
  6. Specify the horizontal and vertical intervals for each histogram in the X values range and Y values range sections, respectively.
  7. In the Data update section, specify how you want this data element to be updated.

Properties

General

Name — The name of the data item. The name is used to identify and access the element from code.

Show name — If selected, the name of the element is displayed in the presentation diagram.

Ignore — If selected, the element is excluded from the model.

Use time as X value — If selected, the Histogram2D data is timed, meaning that when new samples are added, the Y-value is evaluated using the specified Y value expression, while the X-value uses the current model time. If not selected, the data is phased, meaning that both X- and Y-values are evaluated using the specified expressions (X value and Y value, respectively).

X value — [Enabled if Use time as X value is not selected] The expression that will be dynamically evaluated to obtain the current X-value for the histograms.

Y value — The expression that will be dynamically evaluated to obtain the current Y-value for the histograms.

Envelopes — Specify a comma-separated list of lower bounds for confidence envelopes — the regions containing a given percentage of data.

X and Y axis values range

Number of intervals — The number of intervals for the X& or Y axis.

From and To — Define the range for the X& or Y axis values.

Data update

Update data automatically — If selected, new data samples will be added automatically.

Use model time — [Visible if Update data automatically is selected] If selected, the event will occur at the specified model time.

Use calendar dates — [Visible if Update data automatically is selected] If selected, the event will occur at the specified calendar date.

First update time — [Visible if Update data automatically and Use model time are selected] The time of the first update defined as a number of model time units that must pass from the model start.

Update date — [Visible if Update data automatically and Use calendar dates are selected] The calendar date and time of the event.

Recurrence time — [Visible if Update data automatically is selected] The time that must pass between recurring updates.

Expert

Visible — The visibility of the element during runtime.

Visualizing histogram2D data

To visualize histogram2D data with a chart

  1. Right-click the histogram2D data element in the graphical editor and select Create Chart from the context menu. A histogram2D will appear in the graphical editor.
  2. Configure your histogram in the Properties section.

API for working with collected data

The Histogram2D Data element is represented in AnyLogic as an instance of the Histogram2DData class. This class provides a number of functions described below.

Functions
Function Description
void add(DataSet dataset) Adds the whole contents of a given data set to the histogram data, updates PDF, CDF, and count.
void add(double xval, double yval) Adds a sample data item to the histogram data, updates PDF, CDF, and count.
int count(int xindex) Returns the number of samples added to the histogram with xindex.
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. the number of individual histograms.
int getNumberOfYIntervals() Returns the number of data (y) intervals in each individual histogram.
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.
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.
String toString() Returns a tab-separated multi-line textual representation of the histogram data.
How can we improve this article?