Open iii-org-tw opened 4 years ago
Hi @harrelfe
Do you have time to review this PR?
Would you mind doing some tests on how this changes behavior in the non-breaking case? Also I would need changes in the help file to go along with these changes. Thanks for working on this.
Original code has two problems:
This line goes wrong. The indexing becomes descending.
For example:
It is because the cumsum is 0.3, 0.6, 3.0 and the approx function try to locate lower index 1 and upper index 2. It turns both q take the 3 value and the interpolation crush.
I find one formula to define weighted quantile. https://stats.stackexchange.com/questions/13169/defining-quantiles-over-a-weighted-sample It is well defined in boundary and the result equals to numpy quantile when weights are equal. I implement the code accordingly and this one doesn't have the above mentioned problem.
Any review is welcome.