-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhistogram.h
More file actions
31 lines (27 loc) · 845 Bytes
/
histogram.h
File metadata and controls
31 lines (27 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef RIBI_HISTOGRAM_H
#define RIBI_HISTOGRAM_H
#include <vector>
struct HistogramCategory
{
HistogramCategory(const double min, const double max, const int cnt);
int GetCnt() const noexcept { return m_cnt; }
double GetMid() const noexcept { return (m_min + m_max) / 2.0; }
double GetMin() const noexcept { return m_min; }
double GetMax() const noexcept { return m_max; }
bool IsInRange(const double x) { return x >= m_min && x < m_max; }
private:
const double m_min;
const double m_max; //Non inclusive
const int m_cnt;
};
struct Histogram
{
Histogram(
const std::vector<double>& v,
const double lowest, const double highest, const int n
);
const std::vector<HistogramCategory>& GetHistogram() const noexcept { return m_v; }
private:
std::vector<HistogramCategory> m_v;
};
#endif // RIBI_HISTOGRAM_H