Given a function $f$ from a finite set $X$ to itself, it seems natural to consider $\kappa\_f := (\sum\_{x \in X} |f^{-1}(x)|^2)/|X|$ as a measure of the non-invertibility of $f$: it equals 1 if $f$ is invertible, equals $|X|$ if $f$ is constant, and is strictly between 1 and $|X|$ otherwise. It also admits a probabilistic interpretation: $\kappa\_f / |X|$ equals the probability that two IID draws $x,x’$ chosen uniformly from $X$ satisfy $f(x)=f(x’)$. Does the quantity $\kappa$ (or the related quantities $\kappa |X|$ or $\kappa / |X|$) have a standard name?


Note: I’ve added the graph-theory tag since analogous quantities (mean-squared indegree for directed graphs, mean-squared degree for graphs) may already have been considered there.


Note: I've also added the information-theory tag since $\kappa$ is a measure of how much information (in the colloquial sense) is lost when passing from $x$ to $f(x)$ (where $x$ denotes a random draw from the uniform distribution on $X$); it seems possible that there are known results linking this sort of information to Shannon information.


Update: I'm considering calling this quantity the "degree" of $f$. If you think this is a bad choice, please post to [The degree of a (combinatorial) selfmap](https://mathoverflow.net/questions/346604/the-degree-of-a-combinatorial-selfmap) explaining why.



Quantifying the noninvertibility of a function
You're right that this is a significant quantity information-theoretically. It's essentially the Rényi entropy of order $2$, as I'll explain.


First let me generalize your setting ever so slightly, because I find it a distraction that you've made the domain and codomain the same. For any function $f: X \to Y$ between finite sets, put
$$
\kappa\_f = \sum\_{y \in Y} |f^{-1}(y)|^2/|X|.
$$
This extends your definition, and continues to have the kind of properties you want: $\kappa\_f = 1$ iff $f$ is injective, and $\kappa\_f = |X|$ iff $f$ is constant. Anyway, you can ignore my generalization if you want and stick with $Y = X$.


The function $f: X \to Y$ gives rise to a probability distribution $\mathbf{p} = (p\_y)\_{y \in Y}$ on $Y$, defined by
$$
p\_y = |f^{-1}(y)|/|X|.
$$
Like any probability distribution on any finite set, $\mathbf{p}$ has a **Rényi entropy** of order $q$ for every $q \in [-\infty, \infty]$. When $q \neq 1, \pm\infty$, this is by definition 
$$
H\_q(\mathbf{p}) = \frac{1}{1 - q} \log \sum\_y p\_y^q,
$$
where the sum runs over the support of $\mathbf{p}$. The exceptional cases are got by taking limits in $q$, which explicitly means that $H\_1$ is Shannon entropy:
$$
H\_1(\mathbf{p}) = - \sum\_y p\_y \log p\_y
$$
and that 
$$
H\_\infty(\mathbf{p}) = -\log\max\_y p\_y, 
\qquad
H\_{-\infty}(\mathbf{p}) = -\log\min\_y p\_y
$$
(where again, the min is over the support of $\mathbf{p}$). 


Many of the good properties of Shannon entropy are shared by the Rényi entropies $H\_q$. For example, over all probability distributions $\mathbf{p}$ on an $n$-element set, the maximum value of $H\_q(\mathbf{p})$ is $\log n$, which is attained when $\mathbf{p}$ is uniform, and the minimum value is $0$, which is attained when $\mathbf{p} = (0, \ldots, 0, 1, 0, \ldots, 0)$. That's true for every $q \in [-\infty, \infty]$.


Often it's better to work with the *exponentials* of the Rényi entropies, which I'll write as $D\_q = \exp H\_q$. For instance,
$$
D\_2(\mathbf{p}) = 1\Big/\sum\_y p\_y^2.
$$
(D stands for diversity, since ecologists use $D\_q$ to measure biodiversity; in ecology, $D\_q$ is called the "Hill number" of order $q$.) So the maximum value of $D\_q(\mathbf{p})$ over distributions $\mathbf{p}$ on a fixed finite set is the cardinality of that set, not its logarithm. 


Returning to your question, we had a function $f: X \to Y$ between finite sets and the induced probability distribution $\mathbf{p}$ on $Y$. It's a trivial manipulation to show that
$$
\kappa\_f = |X|/D\_2(\mathbf{p}).
$$
So as I claimed at the start, $\kappa\_f$ is essentially (up to a simple transformation) the Rényi entropy of order $2$ (of the distribution $\mathbf{p}$ induced by $f$).


You might also want to consider
$$
|X|/D\_q(\mathbf{p})
$$
for other values of $q$, especially the Shannon case $q = 1$. Although entropies of order $2$ are the easiest to manipulate (being essentially quadratic forms), it's $q = 1$ that has the really magical properties.


Incidentally, in ecology $D\_2(\mathbf{p})$ is known as the Simpson or Gini-Simpson index; there $p\_1, \ldots, p\_n$ are the relative abundances of the $n$ species in some community. [Jack Good](https://en.wikipedia.org/wiki/I._J._Good) wrote in 1982 that it should really bear the name of Turing, but also that "any statistician of this century who wanted a measure of homogeneity would have taken about two seconds to suggest $\sum p\_i^2$." Thanks, Jack.


