16 std::string
const& data_set_name,
17 std::string
const& param_name)
const
19 if (file_name.empty())
21 ERR(
"No file name specified.");
25 std::ofstream out(file_name);
28 ERR(
"Error writing histogram: Could not open file.");
32 out <<
"# Histogram for parameter " << param_name <<
" of data set "
33 << data_set_name <<
"\n";
35 std::vector<std::size_t>
const& bin_cnts(this->
getBinCounts());
39 for (std::size_t k(0); k < n_bins; k++)
41 out << min + k * bin_width <<
" " << bin_cnts[k] <<
"\n";
49 const unsigned int line_width)
const
51 const std::size_t count_max =
53 for (
unsigned int bin = 0; bin <
nr_bins_; ++bin)
59 const int n_stars =
static_cast<int>(
60 std::ceil(line_width * ((
double)
histogram_[bin] / count_max)));
61 for (
int star = 0; star < n_stars; star++)
75 std::ostream_iterator<std::size_t>(os,
" "));
76 return os << std::endl;
79template class Histogram<double>;
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
const T & getBinWidth() const
const T & getMinimum() const
const unsigned int & getNumberOfBins() const
const std::vector< std::size_t > & getBinCounts() const
void prettyPrint(std::ostream &os, const unsigned int line_width=16) const
const T & getMaximum() const
std::vector< std::size_t > histogram_
const unsigned int nr_bins_
int write(std::string const &file_name, std::string const &data_set_name, std::string const ¶m_name) const
std::ostream & operator<<(std::ostream &os, const Histogram< T > &h)