# Reservoir Sampling

## Use

It's useful when you have to k items out of a stream of n or infinite items, such that at the end all the items had an equal probability of being in k items.&#x20;

{% embed url="<https://youtu.be/A1iwzSew5QY>" %}

{% embed url="<https://kapilddatascience.wordpress.com/2015/06/11/how-to-randomly-pick-k-elements-from-an-infinite-stream-with-equal-probability-a-k-a-reservoir-sampling/>" %}

{% embed url="<https://florian.github.io/reservoir-sampling/>" %}

Amazing Website:

{% embed url="<https://www.keithschwarz.com/darts-dice-coins/>" %}
