https://akreson.github.io/en/posts/entropy-encoding-part7/
Entropy coding by a beginner for beginners - Part 7: ANS (rANS, FSE/tANS) - Akreson