### Histogram

Category

Transformation

Function

Constructs a histogram from input data and computes the median.

Syntax

    histogram, median = Histogram(data, bins, min, max, out);

Inputs

Name | Type | Default | Description
--- | --- | --- | ---
`data` | scalar list or vector list or scalar field or vector field or series | none | field to be operated on
`bins` | integer or vector | 256 for bytes, 100 otherwise | number of bins in histogram
`min` | scalar or vector or field | min. of data | minimum value to operate on
`max` | scalar or vector or field | max. of data | maximum value to operate on
`out` | flag or vector | 0 | 0: exclude out-of-range values 1: include out-of-range values

Outputs

Name | Type | Description
--- | --- | ---
`histogram` | field or series | the histogram
`median` | scalar | median of the input data

Functional Details

The median is determined from an interpolation performed in the bin containing the median element (or elements, if there are an even number of samples).

`data` | is the data whose frequency distribution is to be computed and then represented in a histogram. `data` can consist of scalars, 2-vectors, or 3-vectors, with resulting one-dimensional, two-dimensional, or three-dimensional histograms, respectively.
`bins` | specifies the number of bins into which the range from `min` to `max` will be divided. If `data` consists of vectors, then `bins` can be a vector of the same length specifying the number of bins in each dimension.
`min` and `max` | specify the range of values for which the histogram is computed. If neither parameter is specified, the values used are the minimum and maximum of the input data values. If `min` is a scalar value, it is the value used. If `min` is a data field, the minimum data value of that field is used. `max` is similarly interpreted. If `min` is a data field and `max` is unspecified, the module uses the minimum and maximum values of that field. If `data` consists of vectors, then `min` and `max` may also consist of vectors of the same length to specify the range in each dimension. Otherwise, the values given for `min` and `max` will apply to each dimension.
`out` | specifies whether the module ignores data values outside the range of `min` and `max` or includes them in the first and last bins respectively. If `data` consists of vectors, then `out` may be a vector of the same length specifying how to treat each dimension.

Notes:

1. For the output, a "positions" component is constructed that consists of `bins` +1 points, corresponding to the boundaries between bins.

2. A regular "connections" component is constructed that consists of a set of line segments connecting the end points.

3. The "data" component, which is connection dependent, contains the counts for the corresponding bin.

4. The interval for each bin is closed on the `min` side and open on the `max` side. To include the maximum data value:
   - set `out` to include outlying values

     or

   - set `max` to a value slightly larger than the maximum data value.

To see the results of Histogram for scalar data, pass its output to the Plot module. For 2-vector data, pass its output to the RubberSheet module with a scale factor of 1. For 3-vector data, use either the Isolate module or use Include followed by ShowBoundary.

Components

Creates new "positions," "connections," and "data" components. The data, representing the number of items in each bin, is connections dependent.

Example Visual Program

    UsingEqualize.net
    SIMPLE/Histogram.net

See Also

Equalize, Plot, Scale

[ OpenDX Home at IBM | OpenDX.org ]