Dew Stats Master .NET
CumulativeHist Routines
Summary
Cumulative histogram.

Unit
Statistics

Declaration
Procedure CumulativeHist(Data: TVec; const NumBins: Integer; Results: TVec; Bins: TVec; CenterBins: boolean = false);

Description
Divide the Data vector elements into NumBins equal intervals. 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.
Categories
Descriptive statistics routines
 See Also 
Histogram 

Example 1

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 "MtxVecCpp.h" #include "StatRandom.hpp" #include "Statistics.hpp" void __fastcall Example(); { Vector 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. }
using Dew.Math; using Dew.Stats; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Vector Data = new Vector(1000,false); Vector Bins = new Vecttor(0); Vector CumRelFreq = new Vector(0); // generate some normally distributed data StatRandom.RandomNormal(-3.0, 0.2, Data); Statistics.CumulativeHist(Data,15,CumRelFreq,Bins); // Bins holds the 15 intervals centerpoints // and CumRelFreq holds the relative cumulative count of // elements in each bin. } }



Declaration
Procedure CumulativeHist(Data, Bins: TVec; Results: TVec);

Description
Divide the Data vector elements into intervals, specified by the Bins vector. The Bins elements define the center points for the individual intervals. The Bins elements must be sorted in ascending order. The number of elements falling in each interval is counted and the relative cumulative frequency for each interval is written to the Results vector. The Length and Complex properties of the Results vector are adjusted automatically. Use this version if you need non-equidistant histogram.

Example 1

Unequal bins -> slower that equidistant bins algorithm.

Uses MtxExpr, Statistics; procedure Example; var Data, Bins,CumRelFreq: Vector; begin Data.SetIt(10,false,[1,2,3,4,5,6,7,8,9,10]); Bins.Size(4); // define 4 intervals - centerpoints // define centerpoints, note that values are sorted! Bins.SetIt([1.5, 2, 6, 9]); CumulativeHist(Data,Bins, CumRelFreq); // Freq holds the relative cumulative count of // elements in each bin. end;
#include "MtxVecCpp.h" #include "Statistics.hpp" void __fastcall Example(); { Vector Data, Bins, CumRelFreq; Data->SetIt(false,OPENARRAY(double,(1,2,3,4,5,6,7,8,9,10))); // define centerpoints, note that values are sorted! Bins->SetIt(false, OPENARRAY(double,(1.5, 2, 6, 9))); CumulativeHist(Data,Bins, CumRelFreq); // CumRelFreq holds the relative cumulative count of // elements in each bin. }
using Dew.Math; using Dew.Stats; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Vector Data = new Vector(0); Vector Bins = new Vecttor(0); Vector CumRelFreq = new Vector(0); Data.SetIt(false, new double[] {1,2,3,4,5,6,7,8,9,10}); // define centerpoints, note that values are sorted! Bins.SetIt(false, new double[] {1.5, 2, 6, 9}); Statistics.CumulativeHist(Data,Bins, CumRelFreq); // CumRelFreq holds the relative cumulative count of // elements in each bin. } }


Copyright 2008 Dew Research
http://www.dewresearch.com