#include #include #include #include typedef boost::minstd_rand baseGenerator; class randomGenerator { public: virtual ~randomGenerator() { } virtual double operator()() = 0; }; class normalGenerator : public randomGenerator { private: typedef boost::normal_distribution<> normalDistribution; boost::variate_generator _gen; public: explicit normalGenerator(baseGenerator gen = baseGenerator(time(NULL))) : _gen(gen, normalDistribution()) { } inline virtual double operator()() { return _gen(); } }; #include #include typedef std::vector valueList; size_t problemFunction(const int& a, const int& b, const int& c) { return 0; } void printHistogram(valueList &values)/*{{{*/ { std::sort(values.begin(), values.end()); double min(values[0]), max(values[values.size() - 1]), step((max - min) / 100); size_t stepIndex(1), count(0); double nextStep(min + stepIndex * step); std::cout << min << ','; for(valueList::const_iterator i(values.begin()); i != values.end(); ++i) { double c(*i); if(c < nextStep) { ++count; } else { std::cout << count << '\n' << nextStep << ','; count = 1; ++stepIndex; nextStep = min + stepIndex * step; while(c >= nextStep) { std::cout << "0\n" << nextStep << ','; ++stepIndex; nextStep = min + stepIndex * step; } } } std::cout << count << '\n'; }/*}}}*/ int main(int argc, char** argv) { size_t count(1000); boost::minstd_rand gen(time(NULL)); boost::variate_generator > ng(gen, boost::normal_distribution<>()); randomGenerator *vg(new normalGenerator()); valueList values; for(size_t i(0); i < count; ++i) { //values.push_back(ng()); values.push_back((*vg)()); size_t cliqId(problemFunction(0,1,2)); } delete vg; printHistogram(values); return 0; }