You are here: Symbol Reference > Statistics Namespace > Functions > Statistics.CumulativeHist Function
Stats Master VCL
ContentsIndex
PreviousUpNext
Statistics.CumulativeHist Function

Divide the Data vector elements into NumBins equal intervals.

Pascal
procedure CumulativeHist(const Data: TVec; const NumBins: Integer; const Results: TVec; const Bins: TVec; CenterBins: boolean = false); overload;

The number of elements falling in each interval is counted and the relative cumulative frequency for each interval 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.

Use this version if you need equidistant cumulative histogram.

Equal bins -> faster algorithm.

Uses MtxExpr, Statistics, StatRandom;
procedure Example;
  var Data, Bins, CumRelFreq: Vector;
begin
  Data.Size(1000);
  RandomNormal(-3,0.2,Data); // generate some normally distributed data
  // Now, divide the data into 15 equal intervals
  CumulativeHist(Data,15,CumRelFreq,Bins);
  // Bins holds the 15 intervals centerpoints
  // and CumRelFreq holds the relative cumulative count of
  // elements in each bin.
end;
#include "MtxExpr.hpp"
#include "StatRandom.hpp"
#include "Statistics.hpp"
void __fastcall Example()
{
  sVector Data, Bins, CumRelFreq;
  Data.Size(1000,false);
  RandomNormal(-3,0.2, Data);  // generate some normally distributed data
  // Now, divide the data into 15 equal intervals
  CumulativeHist(Data,15,CumRelFreq,Bins);
  // Bins holds the 15 intervals centerpoints
  // and CumRelFreq holds the relative cumulative count of
  // elements in each bin.
}
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!