KrisLibrary  1.0.0
HistogramND.h
1 #ifndef STATISTICS_HISTOGRAMND_H
2 #define STATISTICS_HISTOGRAMND_H
3 
4 #include "statistics.h"
5 #include <KrisLibrary/utils/stl_tr1.h>
6 
7 namespace Statistics {
8 
9 struct IndexHash
10 {
11  IndexHash(size_t pow=257);
12  size_t operator () (const std::vector<int>& x) const;
13  size_t pow;
14 };
15 
22 {
23  public:
24  typedef Vector Point;
25  typedef std::vector<int> Index;
26  typedef std::vector<size_t> Size;
27 
28  HistogramND(int numDims=0);
30  void Resize(int numDims);
32  void Clear();
34  void Resize(const Size& dims,const Point& min,const Point& max);
35  void Resize(const Index& dims,const Point& min,const Point& max);
37  void ResizeToFit(const std::vector<Point>& data,const Size& dims);
39  void Fill(Real val=0);
41  void Calculate(const std::vector<Point>& data);
42 
44  void GetRange(const Index& bucket,Point& min,Point& max) const;
45  void GetBucket(const Point& val,Index& bucket) const;
46  void AddBucket(const Point& val,Real num=1);
47  Real GetBucketCount(const Index& bucket) const;
48  Real NumObservations() const;
49 
50  std::vector<std::vector<Real> > divs;
51  typedef UNORDERED_MAP_TEMPLATE<Index,Real,IndexHash> BucketHash;
52  BucketHash buckets;
53 };
54 
55 } //namespace Statistics
56 
57 #endif
N-D histogram class.
Definition: HistogramND.h:21
Definition: HistogramND.h:9
Contains all definitions in the statistics directory.
Definition: BernoulliDistribution.h:6
Basic statistical utilities.