Commit 8ffd8d80 authored by Guolin Ke's avatar Guolin Ke
Browse files

fix overflow in WeightedPercentile

parent 5b5b9823
...@@ -65,7 +65,7 @@ namespace LightGBM { ...@@ -65,7 +65,7 @@ namespace LightGBM {
CHECK(threshold < weighted_cdf[pos]);\ CHECK(threshold < weighted_cdf[pos]);\
T v1 = data_reader(sorted_idx[pos - 1]);\ T v1 = data_reader(sorted_idx[pos - 1]);\
T v2 = data_reader(sorted_idx[pos]);\ T v2 = data_reader(sorted_idx[pos]);\
if (weighted_cdf[pos + 1] - weighted_cdf[pos] > kEpsilon) {\ if (weighted_cdf[pos + 1] - weighted_cdf[pos] >= 1.0f) {\
return static_cast<T>((threshold - weighted_cdf[pos]) / (weighted_cdf[pos + 1] - weighted_cdf[pos]) * (v2 - v1) + v1); \ return static_cast<T>((threshold - weighted_cdf[pos]) / (weighted_cdf[pos + 1] - weighted_cdf[pos]) * (v2 - v1) + v1); \
} else {\ } else {\
return static_cast<T>(v2);\ return static_cast<T>(v2);\
......
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