anishmehta24 opened a new pull request, #41560: URL: https://github.com/apache/beam/pull/41560
Fixes #41559 `ApproximateQuantilesCombineFn.extract_output` used `offset = (total_weight - 1) / (num_quantiles - 1)` for weighted input too. The `- 1` is one element when every weight is 1, but with real weights it is one unit of weight, so the quantiles moved with the scale of the weights (uniform weights of 0.001 on 0..100 gave `[0, 0, 0, 0, 100]`). For weighted input the offset is now `step`, so the k-th quantile is the first element whose cumulative weight exceeds `k * total_weight / (num_quantiles - 1)`. Unweighted input is unchanged. This also makes the weighted example in the `ApproximateQuantiles` docstring give its documented output, `[0, 2, 5, 7, 100]` (master gives `[0, 2, 4, 7, 100]`). Added `test_weighted_quantiles_do_not_depend_on_weight_scale`: uniform weights of 0.001, 0.5, 1 and 1000 give `[0, 25, 50, 75, 100]`, and the docstring example gives `[0, 2, 5, 7, 100]` at each scale. It fails on master. All of `apache_beam/transforms/stats_test.py` passes (86 tests), including the existing weighted, per-key and batched weighted expectations, which didn't change. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
