histogram
Functions
-
int main(int argc, char *argv[])
histogram [ option ] [ infile ]
-t int
output interval \((1 \le T)\)
-b int
number of bins \((1 \le N)\)
-l double
lower bound \((y_L < y_U)\)
-u double
upper bound \((y_L < y_U)\)
-n
perform normalization
infile str
double-type data sequence
stdout
double-type histogram
# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ramp -l 10 | histogram -b 4 -l 0 -u 9 | x2x +da # 3, 2, 2, 3 ramp -l 10 | histogram -b 4 -l 0 -u 9 -n | x2x +da # 0.3, 0.2, 0.2, 0.3 ramp -l 10 | histogram -b 4 -l 0 -u 9 -t 5 | x2x +da # 3, 2, 0, 0, 0, 0, 2, 3
See also
-
class HistogramCalculation
Calculate histogram.
The input is a data sequence:
\[ \begin{array}{ccc} x(0), & x(1), & \ldots, \end{array} \]and the output is the histogram of data:\[ \begin{array}{cccc} b(1), & b(2), & \ldots, & b(N), \end{array} \]where \(N\) is the number of bins.The width of the bin is calculated as
\[ \frac{y_U - y_L}{N}, \]where \(y_U\) and \(y_L\) are the upper bound and the lower bound of the histogram. The data that satisfies \(x(t) > y_U\) or \(x(t) < y_L\) is not contributed to any bins.Public Functions
-
HistogramCalculation(int num_bin, double lower_bound, double upper_bound)
- Parameters:
num_bin – [in] Number of bins, \(N\).
lower_bound – [in] Lower bound, \(y_L\).
upper_bound – [in] Upper bound, \(y_U\).
-
inline int GetNumBin() const
- Returns:
Number of bins.
-
inline double GetLowerBound() const
- Returns:
Lower bound.
-
inline double GetUpperBound() const
- Returns:
Upper bound.
-
inline bool IsValid() const
- Returns:
True if this object is valid.
-
bool Run(const std::vector<double> &data, std::vector<double> *histogram) const
- Parameters:
data – [in] Input data.
histogram – [out] Histogram.
- Returns:
True on success, false on failure.
-
HistogramCalculation(int num_bin, double lower_bound, double upper_bound)