I'm trying to write a test to verify a reasonable distribution for a function that generates 4-digit pin numbers from 8 digit phone numbers. I'm not aware of any direct method of calculating this, so my approach is to (1) generate $n$ pin numbers, (2) for each $i \in \{1,\ldots,n\}$ calculate the probability that there would be $i$ unique pin numbers among the generated, and (3) test that the actual number of unique pins in the $n$ generated fall within $\pm2$ stdev of the average of the probabilities calculated in step (2).
I'm stuck on step 2.
I know that the probability of choosing only 1 distinct number from $0..k$ in $n$ tries is
$$\left(1 \over k \right)^{n-1}$$
and that the probability of choosing $n$ distinct numbers from $0..k$ in $n$ tries is
$$\prod_{i=0}^n{1-\left(i \over k \right)}$$
How do I calculate the probability when the chosen numbers aren't all the same or all distinct?