2

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}} \;.$$

  1. Can $E[X_m]$ be written as a closed formula?
  2. Direct computation led me to believe that $$ \lim_{m \to \infty} E[X_m] = 1-e^{-1} \;.$$ Is this correct?
Sadeq Dousti
  • 3,291
  • 1
    If we denote $A = {1, \ldots, m}$, we can see that $E[X_m]$ is the probability that a random map contains $1$ in its image. For large $m$ the probability that $1$ occurs $k$ times is given the value of Poisson distribution $P$ with mean $1$, so $E[X_m] \approx 1 - P(0) = 1 - \frac{1}{e}$. – Travis Willse Apr 21 '16 at 20:40

1 Answers1

7

We do it another way, using indicator random variables.

Let the elements of $A$ be $a_1$ to $a_m$. For $i=1$ to $m$, define random variable $Y_i$ by $Y_i=1$ if $a_i$ is in the range, and $Y_i=0$ otherwise.

Then $X_m=\sum_1^m Y_i$, so by the linearity of expectation we have $E(X_m)=\sum_1^m E(Y_i)=mE(Y_1)$.

Thus $\frac{X_m}{m}$ has expectation $E(Y_1)$.

To find $E(Y_1)$, we find the probability $\Pr(X_1=1)$ that $a_1$ is in the range. This is $1$ minus the probability that the function misses $a_1$. That is equal to $\left(\frac{m-1}{m}\right)^m$. Thus our desired expectation is $$1-\left(1-\frac{1}{m}\right)^m.$$ For large, or even not so large $m$, this is indeed very close to $1-e^{-1}$.

André Nicolas
  • 507,029