#include <iostream>
#include <vector>

#include "histogram.h"
#include "histogram_internal.h"


using namespace std;




vector <size_t> make_histogram(const vector<double>& numbers, const size_t bin_count) {

	vector <size_t> bins(bin_count);

	double min_in_numbers, max_in_numbers;
	find_minmax(numbers, min_in_numbers, max_in_numbers);
	double bin_size = (max_in_numbers - min_in_numbers) / bin_count;

	for (size_t i = 0; i < numbers.size(); i++) {
		int to_bin = int((numbers[i]) - min_in_numbers) / bin_size;
		if (to_bin >= bin_count) {
			bins[to_bin - 1]++;
		}
		else {
			bins[to_bin]++;
		}
	}

	return bins;
}