# Odds of drawing at least k identical values among m after n draws?

We draw $n$ values, each equiprobably among $m$ distinct values. What are the odds $p(n,m,k)$ that at least one of the values is drawn at least $k$ times? e.g. for $n=3000$, $m=300$, $k=20$.

Note: I was passed a variant of this by a friend asking for "a statistical package usable for similar problems".

My attempt: The number of times a particular value is reached follows a binomial law with $n$ events, probability $1/m$. This is enough to get odds $q$ that a particular value is reached at least $k$ times [Excel gives $q\approx 0.00340$ with =1-BINOMDIST(20-1,3000,1/300,TRUE)]. Given that $n\gg k$, we can ignore the fact that odds of a value being reached depends on the outcome for other values, and get an approximation of $p$ as $1-(1-q)^m$ [Excel gives $p\approx 0.640$ with =1-BINOMDIST(20-1,3000,1/300,TRUE)^300].

update: the exponent was wrong in the above, that's now fixed

Is this correct? (now solved, yes, but the approximation made leads to an error in the order of 1% with the example parameters)

What methods can work for arbitrary parameters $(n,m,k)$? Is this function available in R or other package, or how could we construct it? (now solved, both exactly for moderate parameters, and theoretically for huge parameters)

I see how to do a simulation in C, what would be an example of a similar simulation in R? (now solved, a corrected simulation in R and another in Python gives $p\approx 0.647$)

-