The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



Histogram


Unit:SDL_vector
Class: TVector, TIntVector
Declaration: [1] function Histogram (FirstElem, LastElem: longint; FirstBin, LastBin, BinWidth: double; var Histo: TIntArray; var Underflow, Overflow, MaxCnt: longint): boolean; { class TVector }
[2] function Histogram (FirstElem, LastElem: longint; FirstBin, LastBin, BinWidth: double; Histo: TIntVector; var Underflow, Overflow, MaxCnt: longint): boolean; { class TVector }

[3] function Histogram (FirstElem, LastElem: longint; FirstBin, LastBin, BinWidth: integer; var Histo: TIntArray; var Underflow, Overflow, MaxCnt: longint): boolean; { class TIntVector }
[4] function Histogram (FirstElem, LastElem: longint; FirstBin, LastBin, BinWidth: integer; Histo: TIntVector; var Underflow, Overflow, MaxCnt: longint): boolean; { class TIntVector }

The function Histogram calculates a histogram of the data in the vector. The range of the included data is determined by the parameters FirstElem, and LastElem.

HISTOVEC.gif

The parameters FirstBin, and LastBin specify the left (lower) boundary of the first and the last histogram bin. The parameter BinWidths defines the width of the bins. A particular bin of the histogram spans the range from FirstBin + (i-1)*BinWidth to FirstBin + i*BinWidth, with i being the bin number (starting from one). The integer vector Histo contains the counts of the histogram. Histo is automatically resized to fit all histogram cells. Values which don't fit into the histogram (i.e. values which are less than FirstBin, or greater than LastBin +BinWidths ) are counted in the variable parameters UnderFlow and OverFlow. The variable parameter MaxCnt contains the maximum count over all histogram bins.

The function returns TRUE if it has been carried out successfully. If a FALSE value is returned, the parameter BinWidth was too small, therefore resulting in too many bins (maximum of 500).

Hint: The two overlaid versions [1] and [2] for the class TVector and [3] and [4] for TIntVector are basically identical except for the type of the variable parameter Histo. Versions [1] and [3] are slightly faster than versions [2] and [4].

Example: This method is used in the following example program (see http://www.lohninger.com/examples.html for downloading the code): percentile



Last Update: 2023-Feb-06