Preamble:
The number of onto functions from a set of $m$ elements to a set of $n$ elements is, as stated in this answer, computed as follows:
$$n!{m\brace n}\;.$$
Now, let's count the number of functions $f \colon A \to A$, with $|A|=m$, such that $f$ is onto some subset of $A$ with exactly $n \le m$ elements.
To this end, we first count the number of sets $B \subseteq A$, with $|B| = n$, and multiply this by the number of onto functions $f \colon A \to B$. This results in the following formula:
$$\binom{m}{n}n!{m\brace n}\;.$$
We can now write the following identity:
$$m^m = \sum_{n=1}^{m}\binom{m}{n}n!{m\brace n}\;,$$
where $m^m$ is the total number of functions $f \colon A \to A$.
Motivation:
Let $A$ be a set of size $m$. Pick a random function $g$ from the set $F = \{f \colon A \to A\}$. Let $X_m = \frac{|\text{range}(g)|}{m}$. What is $E[X_m]$?
Example: Let $A = \{a,b\}$. Then $F = \{f_1, f_2, f_3, f_4\}$, where
$$ f_1 (a) = a,\quad f_1(b) = b\;,$$ $$ f_2 (a) = b,\quad f_2(b) = a\;,$$ $$ f_3 (a) = a,\quad f_3(b) = a\;,$$ $$ f_4 (a) = b,\quad f_4(b) = b\;.$$
$$|\text{range}(f_1)|=|\text{range}(f_2)|=2\;,$$ $$|\text{range}(f_3)|=|\text{range}(f_4)|=1\;.$$
Hence,
$$E[X_2] = \frac{2\cdot\frac{2}{2} + 2\cdot\frac{1}{2}}{2^2} = 0.75\;.$$
Question & My Results:
According to what was shown in the preamble, I computed:
$$E[X_m] = \frac{\sum_{n=1}^{m} \big(\binom{m}{n}{m\brace n}n!\times n\big)}{m^{m+1}} \;.$$
- Can $E[X_m]$ be written as a closed formula?
- Direct computation led me to believe that $$ \lim_{m \to \infty} E[X_m] = 1-e^{-1} \;.$$ Is this correct?