TITLE: Making 400k random choices from 400k samples seems to always end up with 63% distinct choices, why?
QUESTION [37 upvotes]: I have a very simple simulation program, the sequence is:

Create an array of 400k elements
Use a PRNG to pick an index, and mark the element (repeat 400k times)
Count number of marked elements.

An element may be picked more than once, but counted as only one "marked element".
The PRNG is properly seeded. No matter how many times I run the simulation, I always end up getting around 63% (252k) marked elements.
What is the math behind this? Or was there a fault in my PRNG?

REPLY [5 votes]: This problem was recently solved in a slightly more general form using the concept of throwing $m$ balls into $n$ boxes:
We throwing $m$ balls to $n$ cells....
Consider $n$ boxes (the fixed list in our case). We now select $m$ items from the list at random (with replacement) -- or by throwing $m$ balls into $n$ boxes. That problem found the expected fraction of non-empty or marked boxes as $1-(1-1/n)^m$ using the same approach as @WimC. So if we made $m=800k$ choices from the list of $n=400k$ items then the expected fraction of the $n$ items that are marked would be $1-(1-\frac {m/n}{m})^m\approx 1-e^{-m/n}=1-e^{-2}.$