title: Is there a procedure to sample from an array according to its reversed priorities using a sum-tree?
body: <p>I am trying to sample from an array according to both its priorities and its reversed priorities. By using a sum-tree structure, it is straight-forward to have prioritized-sampling. However, I could not find out how to sample reversed-prioritized.</p>
  <p>Let's say we have an array [1,2,3,4] and I sample one element at each iteration. If I perform N iterations (and N is a very large number),I expect to get the first element N/10 times, the second element 2N/10 times etc. by using prioritized sampling. In reversed prioritized sampling setting, I expect to get the first element 12N/25 times, the second element 6N/25 times and the third element 4N/25 times, and the fourth element 3N/25 times. I could not think about an algorithm to carry out reversed-prioritized sampling.</p>
  <p>For clarity, this article explains algorithm of prioritized sampling using sum tree: <a href="https://www.fcodelabs.com/2019/03/18/Sum-Tree-Introduction/" rel="nofollow noreferrer">https://www.fcodelabs.com/2019/03/18/Sum-Tree-Introduction/</a></p>