Removing s and always computing s yields the first algorithm in Section 4.
algorithm 1 SaMPLING WITH REFINED BUCKET 1: for word w in this document do 2: sample = rand() * (s + r + q) 3: if sample < s then 4: compute s 5: sample = sample * (s + r + q)/(s + r + q) 6: if sample < s then 7: return topic k and path λ sampled from s 8: sample − = s 9: else 10: sample − = s 11: if sample < r then 12: return topic k and path λ sampled from r 13: sample − = r 14: return topic k and path λ sampled from q Sorting far, we described techniques for efficiently computing buckets, but quickly sampling assignments within a bucket is also important.