Message316500
Supplying cum_weights allows the code to use bisection to locate the correct value to return. This is O(log n), and is significantly faster for large populations than supplying weights (which need to be totalled for the calculation).
Requiring a pre-check on cum_weights (for example, the obvious check that the sequence is nondecreasing) would add an O(n) step, and so significantly impact performance for that case. |
|
Date |
User |
Action |
Args |
2018-05-14 11:54:32 | paul.moore | set | recipients:
+ paul.moore, rhettinger, mark.dickinson, steven.daprano |
2018-05-14 11:54:32 | paul.moore | set | messageid: <1526298872.91.0.682650639539.issue33494@psf.upfronthosting.co.za> |
2018-05-14 11:54:32 | paul.moore | link | issue33494 messages |
2018-05-14 11:54:32 | paul.moore | create | |
|