Statistics.Histogram Method

Overload List

#SignatureDescription
1procedure Histogram(const Data: TVec; const Bins: TVec; const results: TVec);Histogram.
2procedure Histogram(const Data: TVec; const NumBins: Integer; const results: TVec; const Bins: TVec; CenterBins: Boolean);Divide the Data vector elements into NumBins equal intervals.
3procedure Histogram(const Data: TVec; const NumBins: Integer; const results: TVec; const Bins: TVec; CenterBins: Boolean; Max: Double; Min: Double);Same as above, but here only values between Min and Max parameters will be counted.
4procedure Histogram(const Data: TVec; const NumBins: Integer; const results: TVecInt; const Bins: TVec; CenterBins: Boolean);Divide the Data vector elements into NumBins equal intervals.
5procedure Histogram(const Data: TVec; const NumBins: Integer; const results: TVecInt; const Bins: TVec; CenterBins: Boolean; Max: Double; Min: Double);Same as above, but here only values between Min and Max parameters will be counted.

Overload 1: procedure Histogram(const Data: TVec; const Bins: TVec; const results: TVec);

Histogram.

#NameTypeDescription
1DataTVec
2BinsTVec
3resultsTVec

Result: stored in self (calling object)

Remarks:

Divide the Data vector elements into intervals, specified by the Bins vector. The Bins elements define the center points for the intervals. The Bins elements must be sorted in ascending order. The number of elements falling in each interval is counted and the result for each interval (frequency distribution) is written to the Results vector. The Length and Complex properties of the Results vector are adjusted automatically.

Note
Use this version if you need non-equidistant histogram.

Examples
Uses MtxExpr,Statistics;
procedure Example;
var Data, Bins, Freq: Vector;
begin
    Data.SetIt(false,[1,2,3,4,5,6,7,8,9,10]);
    Bins.SetIt(false,[1.5, 2, 6, 9]); // define centerpoints, note that values are sorted!
    Histogram(Data,Bins, Freq);
    // Freq holds the count of elements in each bin
end;

Overload 2: procedure Histogram(const Data: TVec; const NumBins: Integer; const results: TVec; const Bins: TVec; CenterBins: Boolean);

Divide the Data vector elements into NumBins equal intervals.

#NameTypeDescription
1DataTVec
2NumBinsInteger
3resultsTVec
4BinsTVec
5CenterBinsBoolean

Result: stored in self (calling object)

Remarks:

The number of elements falling in each interval is counted and the result for each interval (frequency distribution) is written to the Results vector. if CenterBins is true then Bins will store bins center points. If CenterBins is false, Bins will store bins edges.The Length and Complex properties of the Results and Bins vectors are adjusted automatically.

Note
Use this version if you need equidistant histogram.

Examples
Uses MtxExpr, Statistics, StatRandom;
procedure Example;
var Data, Bins, Freq: Vector;
begin
    Data.Size(1000);
    RandomNormal(-3,0.2,Data); // generate some normaly distributed data
    // Now, divide the data into 15 equal intervals
    Histogram(Data,15,Freq,Bins,true);
    // Bins holds the 15 intervals centerpoints
    // and Freq holds the count of elements in each bin
end;

Overload 3: procedure Histogram(const Data: TVec; const NumBins: Integer; const results: TVec; const Bins: TVec; CenterBins: Boolean; Max: Double; Min: Double);

Same as above, but here only values between Min and Max parameters will be counted.

#NameTypeDescription
1DataTVec
2NumBinsInteger
3resultsTVec
4BinsTVec
5CenterBinsBoolean
6MaxDoublescalar
7MinDoublescalar

Result: stored in self (calling object)

See Also: Statistics.CumulativeHist

Overload 4: procedure Histogram(const Data: TVec; const NumBins: Integer; const results: TVecInt; const Bins: TVec; CenterBins: Boolean);

Divide the Data vector elements into NumBins equal intervals.

#NameTypeDescription
1DataTVec
2NumBinsInteger
3resultsTVecInt
4BinsTVec
5CenterBinsBoolean

Result: stored in self (calling object)

Remarks:

The number of elements falling in each interval is counted and the result for each interval (frequency distribution) is written to the Results vector. if CenterBins is true then Bins will store bins center points. If CenterBins is false, Bins will store bins edges.The Length and Complex properties of the Results and Bins vectors are adjusted automatically.

See Also: Statistics.CumulativeHist

Overload 5: procedure Histogram(const Data: TVec; const NumBins: Integer; const results: TVecInt; const Bins: TVec; CenterBins: Boolean; Max: Double; Min: Double);

Same as above, but here only values between Min and Max parameters will be counted.

#NameTypeDescription
1DataTVec
2NumBinsInteger
3resultsTVecInt
4BinsTVec
5CenterBinsBoolean
6MaxDoublescalar
7MinDoublescalar

Result: stored in self (calling object)

See Also: Statistics.CumulativeHist