#include "histogram.h" #include #include using namespace std; bool find_minmax(const vector& numbers, double& min, double& max) { if(numbers.empty()) return false; min = numbers[0]; max = numbers[0]; for ( size_t i=0; i < numbers.size(); i++) { if (numbers[i] > max) max=numbers[i]; if (numbers[i] < min) min=numbers[i]; } return true; }; std::vector make_histogram(const vector &numbers,size_t bin_count) { float lo,hi,dif; double min, max; if(!find_minmax(numbers, min, max)) return 1; vector bins(bin_count) ; dif=(max - min)/bin_count; for(int i=0; i < numbers.size(); i++) { bool found = false; for (size_t j=0; (j < bin_count-1)&&(!found); j++) { lo= min + j*dif; hi= min + (j+1)*dif; if ((lo <= numbers[i]) && (numbers[i]