Recent Changes - Search:

Information

Installation

Documentation

ElementsHistogram

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.

(:applet clickimg="Histogram.jpg" clickalt="" clickcaption="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." code="HistogramExample_pkg.HistogramExampleApplet.class" codebase="http://www.um.es/fem/EjsDL/Examples/Elements/Drawables2D" archive="ejs_Histogram.jar" width="528" height="366" draggable="true" :)

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

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).
NameDescriptionValues acceptedDefault
InputThe double or double[] input value to append.A constant or variable of type int, double or double[]. 
EnabledWhether the histogram actually accepts input values.A boolean variable or one of the constants true or false.true
OccurrencesThe number of the occurrences of the input.A constant or variable of type int or double.1
Clear at InputWhether to clear old data whenever new data gets in.A boolean variable or one of the constants true or false.false
DiscreteWhether 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
NormalizedWhether the data are normalized to one.A boolean variable or one of the constants true or false.false
Graphical Aspect
NameDescriptionValues acceptedDefault
VisibleThe visibility of the element.A boolean variable or one of the constants true or false. 
MeasuredWhether the element affects its parent panel's autoscaling.A boolean variable or one of the constants true or false. 
Bin OffsetThe 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 WidthThe 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 StyleThe 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 OffsetThe 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 ColorThe color used for the lines of the element.Use the editor provided or read about colors.BLACK
Fill ColorThe 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.

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