Dew Stats Master .NET
Histogram Routines
Summary
Histogram.

Unit
Statistics

Declaration
Procedure Histogram(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 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. Use this version if you need non-equidistant histogram.

Example 1

This example constructs 4 unequal bins and counts the frequencies.

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;
#include "MtxVecCpp.h" #include "Statistics.hpp" void __fastcall Example() { Vector data, bins, freq; data->SetIt(false,OPENARRAY(double,(1,2,3,4,5,6,7,8,9,10))); // Centerpoints, note that values are sorted! bins->SetIt(false,OPENARRAY(double,(1.5, 2.0, 6.0, 9.0))); Histogram(data,bins,freq); // Freq holds the 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 Vector(0); Vector freq = new Vector(0); data.SetIt(false, new double[] {1,2,3,4,5,6,7,8,9,10}); // Centerpoints, note that values are sorted! bins.SetIt(false, new double[] {1.5, 2.0, 6.0, 9.0}); Statistics.Histogram(data,bins,freq); // Freq holds the count of elements in each bin } }



Declaration
Procedure Histogram(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 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. Use this version if you need equidistant histogram.

Example 1

Equal bins -> faster algorithm.

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;
#include "MtxVecCpp.h" #include "Statistics.hpp" #include "StatRandom.hpp" void __fastcall Example(); { Vector Data, Bins, Freq; Data->Size(1000,false); 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 }
using Dew.Math; using Dew.Stats; using Dew.Stats.Units; namespace Dew.Examples { private void Example() { Vector Data = new Vector(0); Vector Bins = new Vector(0); Vector Freq = new Vector(0); StatRandom.RandomNormal(-3,0.2,Data); // generate some normaly distributed data // Now, divide the data into 15 equal intervals Statistics.Histogram(Data,15,Freq,Bins,true); // Bins holds the 15 intervals centerpoints // and Freq holds the count of elements in each bin } }



Declaration
Procedure Histogram(Data: TVec; const NumBins: Integer; Results: TVec; Bins: TVec; CenterBins: boolean; Max, Min: TSample);

Description
Same as above, but here only values between Min and Max parameters will be counted.)
Categories
Descriptive statistics routines
 See Also 
CumulativeHist 

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