Post

✨ It's new samwho visual essay o'clock! ✨ Reservoir sampling is one of my favourite algorithms. It allows you to sample from a set without knowing the size of that set. I try to assume no prior knowledge, and use no scary math notation. Just beautiful visuals. Let me know what you think! ❤️

One potential fix would be to calculate `j` as `floor(random()*(this.n+1))`. Also, in the multi-card example, it wasn't obvious that "generate a random number between 0 and *n*" assumes that *n* is not included. This is also confusing because, up to that point in the article, we counted *n* from 1.

Fixed the off-by-one. Thank you again for pointing that out.

0 reposts1 like