Probability of random functions where domain equals co-domain

648 Views Asked by At

Given random function defined by $f: [n] \rightarrow [n]$, chosen uniformly, what is probability that the function is injective, surjective, or bijective?

If $[n]$ is a set of discrete elements, then size of the domain is equal to the size co-domain.

Therefore the total number of functions is $n^n$.

The number of functions which have no repetition in mapping domain to co-domain is the ways to arrange the $n$ co-domain elements over the $n$ domain elements which is $n!$.

These functions with no repetition are also injective, surjective, and bijective, and all others are not. So the probability is $\frac{n!}{n^n}$ for all three possibilities?