Refactor outlier trimming

This commit is contained in:
Ed Addario 2025-09-27 17:25:29 +01:00
parent dd4f4bd0b8
commit d16945730e
No known key found for this signature in database
GPG Key ID: E7875815A3230993
1 changed files with 1 additions and 2 deletions

View File

@ -847,8 +847,7 @@ static std::unordered_map<std::string, ggml_type> target_bpw_type(
if (n == 0) { return 0.0; }
if (n < 50) { return std::accumulate(v.begin(), v.end(), 0.0); } // use all samples for small datasets
int64_t k = (int64_t) std::floor(0.02 * (double)n); // trim 2% from each tail of the distribution
k = std::clamp<int64_t>(k, 0, std::min(n / 32, n / 2 - 1)); // cap trimming at ~3% (1/32) or half the samples - 1
int64_t k = (int64_t) std::floor(0.025 * (double)n); // trim 2.5% from each tail of the distribution
std::sort(v.begin(), v.end());
return std::accumulate(v.begin() + k, v.begin() + (n - k), 0.0);
};