I have memory of $k$ elements that you can imagine being represented by an array. One by one, the array receives a value corresponding to the time index, for example at $t=1$ the value will be $1$. At some point ($t=k+1$) the array will be full and we must choose a value inside the array to replace with the new one. The objective is to find an algorithm that outputs a uniform subset of $k$ elements. For example, with $k=2$ and $t=3$ it will output with uniform probability one of the following: $\{1,2\}$, $\{1,3\}$ or $\{2,3\}$. One possible algorithm is the following:
- create array of $k$ elements
- FOR $t=1,.\ldots,T$:
- if array is not full insert an empty space
- receive an input
- discard the input with probability $1 - k/t$
- else insert the input at a uniform location
- END FOR
- return array
It's easy to implement such a program and convince yourself that this is indeed a solution to the problem but how do I demonstrate it? Essentially I need to demonstrate that each subset has probability $1/\binom tk$ to be the result at the end (that's because $\binom tk$ is the number of possible subsets of $k$ elements at time $t$).