I could easily find a description of this method before you replied:
Again, AI is mostly useful as a search engine compared to inventing new solutions.
GitHub
discrete-distribution/doc/algorithm.tex at master · DavidPal/discrete-distribution
Fast algorithm for sampling from discrete distributions - DavidPal/discrete-distribution