Recent Changes - Search:

Information

Installation

Documentation

 

 « Points | Sitemap | Data raster » 

Histogram

A histogram is a drawable that displays the cumulative occurrences of given input values in the form of a histogram (a graph of bars or of points). The input values and its occurrences can be specified using the Input and Occurrences properties, or can be added to the histogram using the different forms of the append method.

 

A given input value creates a new bin (vertical bar or point) with the height of the given occurrence, or adds to the height of an existing bin if the input’s distance to the value of this bin is smaller than the bin width of the histogram. The occurrences can be normalized, in which case the values are taken as percentage of the sum of all input occurrences.

 

Click on the image to start the applet.

A simple Histogram example: the Input property of a normalized histogram is used to plot the probability mass function of the binomial distribution. Download this example.

 

If the simulation has Data processing tools added to it, an histogram will add an entry to the simulation menu.
If the simulation uses [n] array together with a slider for [n], initialize page may need to add code” if(n < nmax)speedarray=new double[n]; “ for histogram to display array correctly as [n]. Check out http://www.phy.ntnu.edu.tw/ntnujava/index.php?topic=1487.msg5607#msg5607 for in-depth discussion.

Properties

Property values in the Histogram inspector

 

Histogram  
Configuration
Points are usually added to the histogram using the Input and Occurrences properties. The input can be a single double value or an array of double values. This latter option is use typically when you compute the whole histogram in your code and want to update it all at once. In this case, you can set the Clear at Input property to true, so that adding the computed values clears first the previous histogram (instead of adding to the existing occurrences).
Name Description Values accepted Default
Input The double or double[] input value to append. A constant or variable of type int, double or double[].
Enabled Whether the histogram actually accepts input values. A boolean variable or one of the constants true or false. true
Occurrences The number of the occurrences of the input. A constant or variable of type int or double. 1
Clear at Input Whether to clear old data whenever new data gets in. A boolean variable or one of the constants true or false. false
Discrete Whether the bins are discrete or continuous. A discrete bin looks like a thin vertical line, a continuous one looks like a bar with the width of the bin. A boolean variable or one of the constants true or false. true
Normalized Whether the data are normalized to one. A boolean variable or one of the constants true or false. false
Graphical Aspect
Name Description Values accepted Default
Visible The visibility of the element. A boolean variable or one of the constants true or false.
Measured Whether the element affects its parent panel’s autoscaling. A boolean variable or one of the constants true or false.
Bin Offset The offset (horizontal displacement) for the bins. If the input value is, say, 1, the corresponding bin is displayed at 1+offset. A constant or variable of type int or double. 0
Bin Width The width of the bins. This is the maximum distance that makes two inputs contribute to the same bin height. As an example, is the with is 0.5, the inputs 1.1 and 1.4 will add their occurrences to the same bin. A constant or variable of type int or double. 1
Bin Style The style for the bins. Enter POINT (for a point plot) or BIN (for vertical bars) or use the editor provided to make a choice. You can also use the integer constants org.opensourcephysics.display.Histogram.DRAW_POINT and org.opensourcephysics.display.Histogram.DRAW_BIN. BIN
Bar Offset The offset for the bar. This adds a constant displacement to the input value. Hence, an input of 1 will add to the bin at 1+offset. A constant or variable of type int or double. 0
Line Color The color used for the lines of the element. Use the editor provided or read about colors. BLACK
Fill Color The color used to fill the points or bars of the histogram. Use the editor provided or read about colors. BLUE

 

Public methods of the Histogram element that can be invoked in a code page

 

Signature and description

void append(double value, double numberOfoccurrences). Append a value with number of occurrences to the Histogram.

void append(double value). Equivalent to void append(double value,1).

void append(double[] values). Appends an array of values with 1 occurrence.

void clear(). Clears all data from this histogram and resets min and max values.

 



 « Points | Sitemap | Data raster » 

Edit - History - Print - Recent Changes - Search
Page last modified on November 03, 2010, at 12:51 PM