Counting measure

In mathematics, specifically measure theory, the counting measure is an intuitive way to put a measure on any set – the "size" of a subset is taken to be the number of elements in the subset if the subset has finitely many elements, and infinity $\infty$ if the subset is infinite.

The counting measure can be defined on any measurable space (that is, any set $$X$$ along with a sigma-algebra) but is mostly used on countable sets.

In formal notation, we can turn any set $$X$$ into a measurable space by taking the power set of $$X$$ as the sigma-algebra $$\Sigma;$$ that is, all subsets of $$X$$ are measurable sets. Then the counting measure $$\mu$$ on this measurable space $$(X,\Sigma)$$ is the positive measure $$\Sigma \to [0,+\infty]$$ defined by $$ \mu(A) = \begin{cases} \vert A \vert & \text{if } A \text{ is finite}\\ +\infty & \text{if } A \text{ is infinite} \end{cases} $$ for all $$A\in\Sigma,$$ where $$\vert A\vert$$ denotes the cardinality of the set $$A.$$

The counting measure on $$(X,\Sigma)$$ is σ-finite if and only if the space $$X$$ is countable.

Integration on $$\mathbb{N}$$ with counting measure
Take the measure space $$(\mathbb{N}, 2^\mathbb{N}, \mu)$$, where $$2^\mathbb{N}$$ is the set of all subsets of the naturals and $$\mu$$ the counting measure. Take any measurable $$f : \mathbb{N} \to [0,\infty]$$. As it is defined on $$\mathbb{N}$$, $$f$$ can be represented pointwise as $$ f(x) = \sum_{n=1}^\infty f(n) 1_{\{n\}}(x) = \lim_{M \to \infty} \underbrace{ \ \sum_{n=1}^M f(n) 1_{\{n\}}(x) \ }_{ \phi_M (x) } = \lim_{M \to \infty} \phi_M (x)  $$

Each $$\phi_M$$ is measurable. Moreover $$\phi_{M+1}(x) = \phi_M (x) + f(M+1) \cdot 1_{ \{M+1\} }(x) \geq \phi_M (x) $$. Still further, as each $$\phi_M$$ is a simple function $$ \int_\mathbb{N} \phi_M d\mu = \int_\mathbb{N} \left( \sum_{n=1}^M f(n) 1_{\{n\}} (x) \right) d\mu = \sum_{n=1}^M f(n) \mu (\{n\}) = \sum_{n=1}^M f(n) \cdot 1 = \sum_{n=1}^M f(n) $$Hence by the monotone convergence theorem $$ \int_\mathbb{N} f d\mu = \lim_{M \to \infty} \int_\mathbb{N} \phi_M d\mu = \lim_{M \to \infty} \sum_{n=1}^M f(n) = \sum_{n=1}^\infty f(n) $$

Discussion
The counting measure is a special case of a more general construction. With the notation as above, any function $$f : X \to [0, \infty)$$ defines a measure $$\mu$$ on $$(X, \Sigma)$$ via $$\mu(A):=\sum_{a \in A} f(a)\quad \text{ for all } A \subseteq X,$$ where the possibly uncountable sum of real numbers is defined to be the supremum of the sums over all finite subsets, that is, $$\sum_{y\,\in\,Y\!\ \subseteq\,\mathbb R} y\ :=\ \sup_{F \subseteq Y,\, |F| < \infty} \left\{ \sum_{y \in F} y \right\}.$$ Taking $$f(x) = 1$$ for all $$x \in X$$ gives the counting measure.