KrisLibrary  1.0.0
Histogram3D.h
1 #ifndef STATISTICS_HISTOGRAM3D_H
2 #define STATISTICS_HISTOGRAM3D_H
3 
4 #include "statistics.h"
5 #include <KrisLibrary/structs/array3d.h>
6 
7 namespace Statistics {
8 
13 {
14  public:
15  typedef Real Point[3]; //Point[0] = x, Point[1] = y, Point[2] = z
16  typedef int Index[3]; //Index[0] = i, Index[1] = j, Index[2] = k
17  typedef size_t Size[3]; //Size[0] = m, Size[1] = n, Size[2] = p
18 
19  Histogram3D();
21  void Clear();
23  void Resize(const Size dims,const Point min,const Point max);
25  void ResizeToFit(const std::vector<Point>& data,const Size dims);
27  void Fill(Real val=0);
29  void Calculate(const std::vector<Point>& data);
31  void Calculate(const std::vector<Real>& data1,const std::vector<Real>& data2,const std::vector<Real>& data3);
32 
34  void GetRange(const Index bucket,Point min,Point max) const;
35  void GetBucket(const Point val,Index bucket) const;
36  void AddBucket(const Point val,Real num=1);
37  void AddBucket(Real v1,Real v2,Real v3,Real num=1);
38  Real GetBucketCount(Index bucket) const { return buckets(bucket[0],bucket[1],bucket[2]); }
39  Real NumObservations() const;
40 
41  std::vector<Real> div1, div2, div3;
44 };
45 
46 } //namespace Statistics
47 
48 #endif
Array3D< Real > buckets
(div1.size()+1) x (div2.size()+1) x (div3.size()+1 buckets
Definition: Histogram3D.h:43
void Fill(Real val=0)
Fills all buckets with the given value.
Definition: Histogram.cpp:324
void Clear()
Creates one big bucket.
Definition: Histogram.cpp:269
Contains all definitions in the statistics directory.
Definition: BernoulliDistribution.h:6
Basic statistical utilities.
An integer tuple class.
Definition: IntTuple.h:14
void Calculate(const std::vector< Point > &data)
Calculates the histogram of the data.
Definition: Histogram.cpp:329
void Resize(const Size dims, const Point min, const Point max)
Creates mxnxp uniformly spaced buckets between min,max.
Definition: Histogram.cpp:277
void GetRange(const Index bucket, Point min, Point max) const
Gets the range of the given bucket.
Definition: Histogram.cpp:357
void ResizeToFit(const std::vector< Point > &data, const Size dims)
Creates mxnxp uniformly spaced buckets between the min/max of data.
Definition: Histogram.cpp:308
3-D histogram class
Definition: Histogram3D.h:12