Three key points:
Weighted sampling transforms into range lookup using prefix sums.
Binary search on sorted prefix sums gives lookup time per query.
This pattern appears in load balancing, random sampling, and simulation systems.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
summary
Three key points:
Weighted sampling transforms into range lookup using prefix sums.
Binary search on sorted prefix sums gives lookup time per query.
This pattern appears in load balancing, random sampling, and simulation systems.