Commit 3586673a authored by Guolin Ke's avatar Guolin Ke
Browse files

clean code

parent 2a5d7abe
...@@ -96,10 +96,7 @@ void BinMapper::FindBin(std::vector<double>* values, size_t total_sample_cnt, in ...@@ -96,10 +96,7 @@ void BinMapper::FindBin(std::vector<double>* values, size_t total_sample_cnt, in
} else { } else {
// mean size for one bin // mean size for one bin
double mean_bin_size = sample_size / static_cast<double>(max_bin); double mean_bin_size = sample_size / static_cast<double>(max_bin);
std::vector<bool> is_big_count_value(num_values, false); double static_mean_bin_size = mean_bin_size;
for (int i = 0; i < num_values; ++i) {
if (counts[i] >= mean_bin_size) { is_big_count_value[i] = true; }
}
std::vector<double> upper_bounds(max_bin, std::numeric_limits<double>::infinity()); std::vector<double> upper_bounds(max_bin, std::numeric_limits<double>::infinity());
std::vector<double> lower_bounds(max_bin, std::numeric_limits<double>::infinity()); std::vector<double> lower_bounds(max_bin, std::numeric_limits<double>::infinity());
...@@ -111,8 +108,8 @@ void BinMapper::FindBin(std::vector<double>* values, size_t total_sample_cnt, in ...@@ -111,8 +108,8 @@ void BinMapper::FindBin(std::vector<double>* values, size_t total_sample_cnt, in
rest_sample_cnt -= counts[i]; rest_sample_cnt -= counts[i];
cur_cnt_inbin += counts[i]; cur_cnt_inbin += counts[i];
// need a new bin // need a new bin
if (is_big_count_value[i] || cur_cnt_inbin >= mean_bin_size || if (counts[i] >= static_mean_bin_size || cur_cnt_inbin >= mean_bin_size ||
(is_big_count_value[i + 1] && cur_cnt_inbin >= std::max(1.0, mean_bin_size * 0.5f))) { (counts[i + 1] >= static_mean_bin_size && cur_cnt_inbin >= std::max(1.0, mean_bin_size * 0.5f))) {
upper_bounds[bin_cnt] = distinct_values[i]; upper_bounds[bin_cnt] = distinct_values[i];
if (bin_cnt == 0) { if (bin_cnt == 0) {
cnt_in_bin0 = cur_cnt_inbin; cnt_in_bin0 = cur_cnt_inbin;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment